Skip to content

Commit

Permalink
Staging: ti-st: cleanup sysfs code
Browse files Browse the repository at this point in the history
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: Naveen Jain <naveen_jain@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Naveen Jain authored and Greg Kroah-Hartman committed Jun 18, 2010
1 parent 4f62e69 commit b38fc2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 47 deletions.
49 changes: 6 additions & 43 deletions drivers/staging/ti-st/st_kim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*attr, char *buf);
static ssize_t store_pid(struct device *dev, struct device_attribute
Expand All @@ -80,12 +79,11 @@ static struct attribute *uim_attrs[] = {
static struct attribute_group uim_attr_grp = {
.attrs = uim_attrs,
};
#else

static int kim_toggle_radio(void*, bool);
static const struct rfkill_ops kim_rfkill_ops = {
.set_block = kim_toggle_radio,
};
#endif /* LEGACY_RFKILL_SUPPORT */

/* strings to be used for rfkill entries and by
* ST Core to be used for sysfs debug entry
Expand Down Expand Up @@ -436,32 +434,29 @@ long st_kim_start(void)
pr_info(" %s", __func__);

do {
#ifdef LEGACY_RFKILL_SUPPORT
/* TODO: this is only because rfkill sub-system
* doesn't send events to user-space if the state
* isn't changed
*/
rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 1);
#endif
/* Configure BT nShutdown to HIGH state */
gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_LOW);
mdelay(5); /* FIXME: a proper toggle */
gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_HIGH);
mdelay(100);
/* re-initialize the completion */
INIT_COMPLETION(kim_gdata->ldisc_installed);
#ifndef LEGACY_RFKILL_SUPPORT
#if 0 /* older way of signalling user-space UIM */
/* send signal to UIM */
err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 0);
if (err != 0) {
pr_info(" sending SIGUSR2 to uim failed %ld", err);
err = ST_ERR_FAILURE;
continue;
}
#else
#endif
/* unblock and send event to UIM via /dev/rfkill */
rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 0);
#endif
/* wait for ldisc to be installed */
err = wait_for_completion_timeout(&kim_gdata->ldisc_installed,
msecs_to_jiffies(LDISC_TIME));
Expand Down Expand Up @@ -491,17 +486,16 @@ long st_kim_stop(void)
long err = ST_SUCCESS;

INIT_COMPLETION(kim_gdata->ldisc_installed);
#ifndef LEGACY_RFKILL_SUPPORT
#if 0 /* older way of signalling user-space UIM */
/* send signal to UIM */
err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 1);
if (err != 0) {
pr_err("sending SIGUSR2 to uim failed %ld", err);
return ST_ERR_FAILURE;
}
#else
#endif
/* set BT rfkill to be blocked */
err = rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 1);
#endif

/* wait for ldisc to be un-installed */
err = wait_for_completion_timeout(&kim_gdata->ldisc_installed,
Expand All @@ -523,7 +517,6 @@ long st_kim_stop(void)
/**********************************************************************/
/* functions called from subsystems */

#ifndef LEGACY_RFKILL_SUPPORT
/* called when sysfs entry is written to */
static ssize_t store_pid(struct device *dev, struct device_attribute
*devattr, char *buf, size_t count)
Expand Down Expand Up @@ -551,8 +544,6 @@ static ssize_t show_list(struct device *dev, struct device_attribute
return strlen(buf);
}

#else /* LEGACY_RFKILL_SUPPORT */

/* function called from rfkill subsystem, when someone from
* user space would write 0/1 on the sysfs entry
* /sys/class/rfkill/rfkill0,1,3/state
Expand Down Expand Up @@ -580,8 +571,6 @@ static int kim_toggle_radio(void *data, bool blocked)
return ST_SUCCESS;
}

#endif /* LEGACY_RFKILL_SUPPORT */

void st_kim_ref(struct st_data_s **core_data)
{
*core_data = kim_gdata->core_data;
Expand Down Expand Up @@ -639,30 +628,12 @@ static int kim_probe(struct platform_device *pdev)
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
*/
kim_gdata->kim_pdev = pdev;
init_completion(&kim_gdata->kim_rcvd);
init_completion(&kim_gdata->ldisc_installed);
#ifdef LEGACY_RFKILL_SUPPORT

for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) {
/* TODO: should all types be rfkill_type_bt ? */
kim_gdata->rf_protos[proto] = proto;
Expand All @@ -685,7 +656,6 @@ static int kim_probe(struct platform_device *pdev)
}
pr_info("rfkill entry created for %ld", gpios[proto]);
}
#endif
return ST_SUCCESS;
}

Expand All @@ -701,18 +671,11 @@ static int kim_remove(struct platform_device *pdev)
* nShutdown gpio from the system
*/
gpio_free(gpios[proto]);
#ifdef LEGACY_RFKILL_SUPPORT
rfkill_unregister(kim_gdata->rfkill[proto]);
rfkill_destroy(kim_gdata->rfkill[proto]);
kim_gdata->rfkill[proto] = NULL;
#endif
}
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;
st_core_exit(kim_gdata->core_data);
return ST_SUCCESS;
Expand Down
4 changes: 0 additions & 4 deletions drivers/staging/ti-st/st_kim.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
* devices are created for the 3 gpios
* that ST has requested
*/
#define LEGACY_RFKILL_SUPPORT
/*
* header file for ST provided by KIM
*/
Expand All @@ -60,15 +59,12 @@ struct kim_data_s {
char resp_buffer[30];
const struct firmware *fw_entry;
long gpios[ST_MAX];
struct kobject *kim_kobj;
/* used by kim_int_recv to validate fw response */
unsigned long rx_state;
unsigned long rx_count;
struct sk_buff *rx_skb;
#ifdef LEGACY_RFKILL_SUPPORT
struct rfkill *rfkill[ST_MAX];
enum proto_type rf_protos[ST_MAX];
#endif
struct st_data_s *core_data;
};

Expand Down

0 comments on commit b38fc2d

Please sign in to comment.