aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/ozwpan
diff options
context:
space:
mode:
authorRupesh Gujare <rgujare@ozmodevices.com>2012-06-26 13:03:39 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-26 15:07:56 -0700
commitba0a7ae713c89c7be204646d9a34c7f612743f51 (patch)
tree89d5412e6003a00c3ffbd1b519c0b9df76cf5000 /drivers/staging/ozwpan
parentf204739736fecee77280c7743b5409dd158a49a6 (diff)
downloadlinaro-lsk-ba0a7ae713c89c7be204646d9a34c7f612743f51.tar.gz
staging: ozwpan: Unregister with sysfs while unloading.
Destroy device node & unregister device class from sysfs while unloading driver Signed-off-by: Rupesh Gujare <rgujare@ozmodevices.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/ozwpan')
-rw-r--r--drivers/staging/ozwpan/ozcdev.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c
index 929756abf02..d9832194580 100644
--- a/drivers/staging/ozwpan/ozcdev.c
+++ b/drivers/staging/ozwpan/ozcdev.c
@@ -42,6 +42,7 @@ struct oz_serial_ctx {
/*------------------------------------------------------------------------------
*/
static struct oz_cdev g_cdev;
+struct class *g_oz_class;
/*------------------------------------------------------------------------------
* Context: process and softirq
*/
@@ -330,7 +331,6 @@ const struct file_operations oz_fops = {
int oz_cdev_register(void)
{
int err;
- struct class *cl;
struct device *dev;
memset(&g_cdev, 0, sizeof(g_cdev));
err = alloc_chrdev_region(&g_cdev.devnum, 0, 1, "ozwpan");
@@ -348,12 +348,12 @@ int oz_cdev_register(void)
oz_trace("Failed to add cdev\n");
goto out2;
}
- cl = class_create(THIS_MODULE, "ozmo_wpan");
- if (IS_ERR(cl)) {
+ g_oz_class = class_create(THIS_MODULE, "ozmo_wpan");
+ if (IS_ERR(g_oz_class)) {
oz_trace("Failed to register ozmo_wpan class\n");
goto out1;
}
- dev = device_create(cl, NULL, g_cdev.devnum, NULL, "ozwpan");
+ dev = device_create(g_oz_class, NULL, g_cdev.devnum, NULL, "ozwpan");
if (IS_ERR(dev)) {
oz_trace("Failed to create sysfs entry for cdev\n");
goto out1;
@@ -373,6 +373,10 @@ int oz_cdev_deregister(void)
{
cdev_del(&g_cdev.cdev);
unregister_chrdev_region(g_cdev.devnum, 1);
+ if (g_oz_class) {
+ device_destroy(g_oz_class, g_cdev.devnum);
+ class_destroy(g_oz_class);
+ }
return 0;
}
/*------------------------------------------------------------------------------