Commit b38fc2d9 authored by Naveen Jain's avatar Naveen Jain Committed by Greg Kroah-Hartman

Staging: ti-st: cleanup sysfs code

Remove the older way of communicating with user-space
daemon UIM.
The older way involved creating of a new kobj and pid
sysfs file under it, and sending signal using that pid.

Now we communicate via rfkill to user-space UIM.

Background: UIM is the user-space daemon which upon
notification from ldisc driver, opens the tty, sets
default baud and then installs (tiocsetd) the ldisc.
Signed-off-by: default avatarNaveen Jain <naveen_jain@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4f62e69b
...@@ -55,7 +55,6 @@ static struct platform_driver kim_platform_driver = { ...@@ -55,7 +55,6 @@ static struct platform_driver kim_platform_driver = {
}, },
}; };
#ifndef LEGACY_RFKILL_SUPPORT
static ssize_t show_pid(struct device *dev, struct device_attribute static ssize_t show_pid(struct device *dev, struct device_attribute
*attr, char *buf); *attr, char *buf);
static ssize_t store_pid(struct device *dev, struct device_attribute static ssize_t store_pid(struct device *dev, struct device_attribute
...@@ -80,12 +79,11 @@ static struct attribute *uim_attrs[] = { ...@@ -80,12 +79,11 @@ static struct attribute *uim_attrs[] = {
static struct attribute_group uim_attr_grp = { static struct attribute_group uim_attr_grp = {
.attrs = uim_attrs, .attrs = uim_attrs,
}; };
#else
static int kim_toggle_radio(void*, bool); static int kim_toggle_radio(void*, bool);
static const struct rfkill_ops kim_rfkill_ops = { static const struct rfkill_ops kim_rfkill_ops = {
.set_block = kim_toggle_radio, .set_block = kim_toggle_radio,
}; };
#endif /* LEGACY_RFKILL_SUPPORT */
/* strings to be used for rfkill entries and by /* strings to be used for rfkill entries and by
* ST Core to be used for sysfs debug entry * ST Core to be used for sysfs debug entry
...@@ -436,13 +434,11 @@ long st_kim_start(void) ...@@ -436,13 +434,11 @@ long st_kim_start(void)
pr_info(" %s", __func__); pr_info(" %s", __func__);
do { do {
#ifdef LEGACY_RFKILL_SUPPORT
/* TODO: this is only because rfkill sub-system /* TODO: this is only because rfkill sub-system
* doesn't send events to user-space if the state * doesn't send events to user-space if the state
* isn't changed * isn't changed
*/ */
rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 1); rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 1);
#endif
/* Configure BT nShutdown to HIGH state */ /* Configure BT nShutdown to HIGH state */
gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_LOW); gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_LOW);
mdelay(5); /* FIXME: a proper toggle */ mdelay(5); /* FIXME: a proper toggle */
...@@ -450,7 +446,7 @@ long st_kim_start(void) ...@@ -450,7 +446,7 @@ long st_kim_start(void)
mdelay(100); mdelay(100);
/* re-initialize the completion */ /* re-initialize the completion */
INIT_COMPLETION(kim_gdata->ldisc_installed); INIT_COMPLETION(kim_gdata->ldisc_installed);
#ifndef LEGACY_RFKILL_SUPPORT #if 0 /* older way of signalling user-space UIM */
/* send signal to UIM */ /* send signal to UIM */
err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 0); err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 0);
if (err != 0) { if (err != 0) {
...@@ -458,10 +454,9 @@ long st_kim_start(void) ...@@ -458,10 +454,9 @@ long st_kim_start(void)
err = ST_ERR_FAILURE; err = ST_ERR_FAILURE;
continue; continue;
} }
#else #endif
/* unblock and send event to UIM via /dev/rfkill */ /* unblock and send event to UIM via /dev/rfkill */
rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 0); rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 0);
#endif
/* wait for ldisc to be installed */ /* wait for ldisc to be installed */
err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, err = wait_for_completion_timeout(&kim_gdata->ldisc_installed,
msecs_to_jiffies(LDISC_TIME)); msecs_to_jiffies(LDISC_TIME));
...@@ -491,17 +486,16 @@ long st_kim_stop(void) ...@@ -491,17 +486,16 @@ long st_kim_stop(void)
long err = ST_SUCCESS; long err = ST_SUCCESS;
INIT_COMPLETION(kim_gdata->ldisc_installed); INIT_COMPLETION(kim_gdata->ldisc_installed);
#ifndef LEGACY_RFKILL_SUPPORT #if 0 /* older way of signalling user-space UIM */
/* send signal to UIM */ /* send signal to UIM */
err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 1); err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 1);
if (err != 0) { if (err != 0) {
pr_err("sending SIGUSR2 to uim failed %ld", err); pr_err("sending SIGUSR2 to uim failed %ld", err);
return ST_ERR_FAILURE; return ST_ERR_FAILURE;
} }
#else #endif
/* set BT rfkill to be blocked */ /* set BT rfkill to be blocked */
err = rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 1); err = rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 1);
#endif
/* wait for ldisc to be un-installed */ /* wait for ldisc to be un-installed */
err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, err = wait_for_completion_timeout(&kim_gdata->ldisc_installed,
...@@ -523,7 +517,6 @@ long st_kim_stop(void) ...@@ -523,7 +517,6 @@ long st_kim_stop(void)
/**********************************************************************/ /**********************************************************************/
/* functions called from subsystems */ /* functions called from subsystems */
#ifndef LEGACY_RFKILL_SUPPORT
/* called when sysfs entry is written to */ /* called when sysfs entry is written to */
static ssize_t store_pid(struct device *dev, struct device_attribute static ssize_t store_pid(struct device *dev, struct device_attribute
*devattr, char *buf, size_t count) *devattr, char *buf, size_t count)
...@@ -551,8 +544,6 @@ static ssize_t show_list(struct device *dev, struct device_attribute ...@@ -551,8 +544,6 @@ static ssize_t show_list(struct device *dev, struct device_attribute
return strlen(buf); return strlen(buf);
} }
#else /* LEGACY_RFKILL_SUPPORT */
/* function called from rfkill subsystem, when someone from /* function called from rfkill subsystem, when someone from
* user space would write 0/1 on the sysfs entry * user space would write 0/1 on the sysfs entry
* /sys/class/rfkill/rfkill0,1,3/state * /sys/class/rfkill/rfkill0,1,3/state
...@@ -580,8 +571,6 @@ static int kim_toggle_radio(void *data, bool blocked) ...@@ -580,8 +571,6 @@ static int kim_toggle_radio(void *data, bool blocked)
return ST_SUCCESS; return ST_SUCCESS;
} }
#endif /* LEGACY_RFKILL_SUPPORT */
void st_kim_ref(struct st_data_s **core_data) void st_kim_ref(struct st_data_s **core_data)
{ {
*core_data = kim_gdata->core_data; *core_data = kim_gdata->core_data;
...@@ -639,30 +628,12 @@ static int kim_probe(struct platform_device *pdev) ...@@ -639,30 +628,12 @@ static int kim_probe(struct platform_device *pdev)
return status; return status;
} }
} }
#ifndef LEGACY_RFKILL_SUPPORT
/* pdev to contain BT, FM and GPS enable/N-Shutdown GPIOs
* execute request_gpio, set output direction
*/
kim_gdata->kim_kobj = kobject_create_and_add("uim", NULL);
/* create the sysfs entry for UIM to put in pid */
if (sysfs_create_group(kim_gdata->kim_kobj, &uim_attr_grp)) {
pr_err(" sysfs entry creation failed");
kobject_put(kim_gdata->kim_kobj);
/* free requested GPIOs and fail probe */
for (proto = ST_BT; proto < ST_MAX; proto++) {
if (gpios[proto] != -1)
gpio_free(gpios[proto]);
}
return -1; /* fail insmod */
}
pr_info(" sysfs entry created ");
#endif
/* get reference of pdev for request_firmware /* get reference of pdev for request_firmware
*/ */
kim_gdata->kim_pdev = pdev; kim_gdata->kim_pdev = pdev;
init_completion(&kim_gdata->kim_rcvd); init_completion(&kim_gdata->kim_rcvd);
init_completion(&kim_gdata->ldisc_installed); init_completion(&kim_gdata->ldisc_installed);
#ifdef LEGACY_RFKILL_SUPPORT
for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) { for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) {
/* TODO: should all types be rfkill_type_bt ? */ /* TODO: should all types be rfkill_type_bt ? */
kim_gdata->rf_protos[proto] = proto; kim_gdata->rf_protos[proto] = proto;
...@@ -685,7 +656,6 @@ static int kim_probe(struct platform_device *pdev) ...@@ -685,7 +656,6 @@ static int kim_probe(struct platform_device *pdev)
} }
pr_info("rfkill entry created for %ld", gpios[proto]); pr_info("rfkill entry created for %ld", gpios[proto]);
} }
#endif
return ST_SUCCESS; return ST_SUCCESS;
} }
...@@ -701,18 +671,11 @@ static int kim_remove(struct platform_device *pdev) ...@@ -701,18 +671,11 @@ static int kim_remove(struct platform_device *pdev)
* nShutdown gpio from the system * nShutdown gpio from the system
*/ */
gpio_free(gpios[proto]); gpio_free(gpios[proto]);
#ifdef LEGACY_RFKILL_SUPPORT
rfkill_unregister(kim_gdata->rfkill[proto]); rfkill_unregister(kim_gdata->rfkill[proto]);
rfkill_destroy(kim_gdata->rfkill[proto]); rfkill_destroy(kim_gdata->rfkill[proto]);
kim_gdata->rfkill[proto] = NULL; kim_gdata->rfkill[proto] = NULL;
#endif
} }
pr_info("kim: GPIO Freed"); pr_info("kim: GPIO Freed");
#ifndef LEGACY_RFKILL_SUPPORT
/* delete the sysfs entries */
sysfs_remove_group(kim_gdata->kim_kobj, &uim_attr_grp);
kobject_put(kim_gdata->kim_kobj);
#endif
kim_gdata->kim_pdev = NULL; kim_gdata->kim_pdev = NULL;
st_core_exit(kim_gdata->core_data); st_core_exit(kim_gdata->core_data);
return ST_SUCCESS; return ST_SUCCESS;
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
* devices are created for the 3 gpios * devices are created for the 3 gpios
* that ST has requested * that ST has requested
*/ */
#define LEGACY_RFKILL_SUPPORT
/* /*
* header file for ST provided by KIM * header file for ST provided by KIM
*/ */
...@@ -60,15 +59,12 @@ struct kim_data_s { ...@@ -60,15 +59,12 @@ struct kim_data_s {
char resp_buffer[30]; char resp_buffer[30];
const struct firmware *fw_entry; const struct firmware *fw_entry;
long gpios[ST_MAX]; long gpios[ST_MAX];
struct kobject *kim_kobj;
/* used by kim_int_recv to validate fw response */ /* used by kim_int_recv to validate fw response */
unsigned long rx_state; unsigned long rx_state;
unsigned long rx_count; unsigned long rx_count;
struct sk_buff *rx_skb; struct sk_buff *rx_skb;
#ifdef LEGACY_RFKILL_SUPPORT
struct rfkill *rfkill[ST_MAX]; struct rfkill *rfkill[ST_MAX];
enum proto_type rf_protos[ST_MAX]; enum proto_type rf_protos[ST_MAX];
#endif
struct st_data_s *core_data; struct st_data_s *core_data;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment