Re: Bug#244207: kernel-source-2.6.5: mwave gives warning on suspend
From: Herbert Xu
Date: Sun Apr 18 2004 - 05:33:19 EST
On Sat, Apr 17, 2004 at 10:29:54PM +1000, herbert wrote:
>
> Please scrap that one, it just makes the module unloadable.
This patch resolves the problem of the module getting unloaded before
the device is released by waiting in the module_exit function.
Cheers,
--
Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ )
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Index: drivers/char/mwave/mwavedd.c
===================================================================
RCS file: /home/gondolin/herbert/src/CVS/debian/kernel-source-2.5/drivers/char/mwave/mwavedd.c,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 mwavedd.c
--- a/drivers/char/mwave/mwavedd.c 28 Sep 2003 04:44:12 -0000 1.1.1.7
+++ b/drivers/char/mwave/mwavedd.c 18 Apr 2004 10:26:41 -0000
@@ -57,6 +57,7 @@
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/delay.h>
+#include <linux/completion.h>
#include "smapi.h"
#include "mwavedd.h"
#include "3780i.h"
@@ -470,7 +471,17 @@
* sysfs support <paulsch@xxxxxxxxxx>
*/
-struct device mwave_device;
+static DECLARE_COMPLETION(mwave_device_released);
+
+static void mwave_device_release(struct device *dev)
+{
+ complete(&mwave_device_released);
+}
+
+static struct device mwave_device = {
+ .bus_id = "mwave",
+ .release = mwave_device_release,
+};
/* Prevent code redundancy, create a macro for mwave_show_* functions. */
#define mwave_show_function(attr_name, format_string, field) \
@@ -518,7 +529,9 @@
pDrvData->nr_registered_attrs = 0;
if (pDrvData->device_registered) {
+ INIT_COMPLETION(mwave_device_released);
device_unregister(&mwave_device);
+ wait_for_completion(&mwave_device_released);
pDrvData->device_registered = FALSE;
}
@@ -639,9 +652,6 @@
/* uart is registered */
/* sysfs */
- memset(&mwave_device, 0, sizeof (struct device));
- snprintf(mwave_device.bus_id, BUS_ID_SIZE, "mwave");
-
if (device_register(&mwave_device))
goto cleanup_error;
pDrvData->device_registered = TRUE;