From: Rupesh Gujare <rgujare@ozmodevices.com>
To: <devel@driverdev.osuosl.org>
Cc: <gregkh@linuxfoundation.org>, <linux-kernel@vger.kernel.org>,
Rupesh Gujare <rgujare@ozmodevices.com>
Subject: [PATCH 1/3] staging: ozwpan: Unregister with sysfs while unloading.
Date: Tue, 26 Jun 2012 13:03:39 +0100 [thread overview]
Message-ID: <1340712221-6750-2-git-send-email-rgujare@ozmodevices.com> (raw)
In-Reply-To: <1340712221-6750-1-git-send-email-rgujare@ozmodevices.com>
Destroy device node & unregister device class from sysfs while unloading
driver
Signed-off-by: Rupesh Gujare <rgujare@ozmodevices.com>
---
drivers/staging/ozwpan/ozcdev.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c
index 929756a..d983219 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;
}
/*------------------------------------------------------------------------------
--
1.7.5.4
next prev parent reply other threads:[~2012-06-26 12:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-26 12:03 [PATCH 0/3] staging: ozwpan: Update TODO & fixes Rupesh Gujare
2012-06-26 12:03 ` Rupesh Gujare [this message]
2012-06-26 12:03 ` [PATCH 2/3] staging: ozwpan: Fix compilation issue due to export.h Rupesh Gujare
2012-06-26 22:07 ` Greg KH
2012-06-27 9:55 ` Rupesh Gujare
2012-06-26 12:03 ` [PATCH 3/3] staging: ozwpan: Update TODO file Rupesh Gujare
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1340712221-6750-2-git-send-email-rgujare@ozmodevices.com \
--to=rgujare@ozmodevices.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®