On Sunday 26 September 2004 08:58 am, Jan Steinhoff wrote:
> On Fri, 24 Sep 2004 00:09:23 -0500, Dmitry Torokhov wrote:
>
> > Jan Steinhoff wrote:
> >
> > > Hi,
> > >
> > > I'm working on a kernel 2.6 driver for Synaptics cPad. With kernel >=
> > > 2.6.7 'rmmod cpad' hangs if called from xterm. This is because Synaptics
> > > TouchPad driver for XFree86 holds the evdev device of the cPad open, even
> > > if read errors like ENODEV occur. When switching to console the device is
> > > closed an rmmod finally returns.
> > >
> > > The same thing happens with usbhid.ko and an ordinary USB mouse, if I hold
> > > the evdev device open with less. driver_unregister in function
> > > usb_deregister does not return, although the disconnect function in the
> > > usb device driver already returned.
> > >
> >
> > Hi,
> >
> > I think it is a problem with USB because I can rmmod psmouse while using
> > Synaptics (PS/2 flavor) in X without any problems (except for loosing the
> > mouse of course. That means that input core can handle such removal.
>
> psmouse->dev.dev is set to NULL in psmouse_connect() in psmouse-base.c, but
> in usbmouse.c, mouse->dev.dev is set to &intf->dev. I think the kobject's
> refcount is then increased by class_simple_device_add() in evdev_connect()
> for an USB mouse, but not for a ps2 mouse. If the evdev is open, then
> evdev_disconnect() does not call class_simple_device_remove() (I think the
> open counter will not work then), so 'rmmod usbhid' hangs until
> class_simple_device_remove() is called in evdev_release().
>
> I have not the faintest idea if anything should be fixed here. Making a
> patch for Synaptics XFree driver should be much simpler.
>
I think we just need to destroy class device earlier - in reality device is
gone not when last reader drops off but when I yank it from the port.
Could you please try the patch below and verify that it works for you.
Thanks!
--
Dmitry
===================================================================
[EMAIL PROTECTED], 2004-09-30 01:49:20-05:00, [EMAIL PROTECTED]
Input: evdev, joydev, mousedev, tsdev - remove class device and devfs
entry when hardware driver disconnects instead of waiting for
the last user to drop off. This way hardware drivers can be
unloaded at any time.
Signed-off-by: Dmitry Torokhov <[EMAIL PROTECTED]>
evdev.c | 4 ++--
joydev.c | 4 ++--
mousedev.c | 4 ++--
tsdev.c | 10 +++++-----
4 files changed, 11 insertions(+), 11 deletions(-)
===================================================================
diff -Nru a/drivers/input/evdev.c b/drivers/input/evdev.c
--- a/drivers/input/evdev.c 2004-09-30 01:50:26 -05:00
+++ b/drivers/input/evdev.c 2004-09-30 01:50:26 -05:00
@@ -91,8 +91,6 @@
static void evdev_free(struct evdev *evdev)
{
- devfs_remove("input/event%d", evdev->minor);
- class_simple_device_remove(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE +
evdev->minor));
evdev_table[evdev->minor] = NULL;
kfree(evdev);
}
@@ -441,6 +439,8 @@
{
struct evdev *evdev = handle->private;
+ class_simple_device_remove(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE +
evdev->minor));
+ devfs_remove("input/event%d", evdev->minor);
evdev->exist = 0;
if (evdev->open) {
diff -Nru a/drivers/input/joydev.c b/drivers/input/joydev.c
--- a/drivers/input/joydev.c 2004-09-30 01:50:26 -05:00
+++ b/drivers/input/joydev.c 2004-09-30 01:50:26 -05:00
@@ -143,9 +143,7 @@
static void joydev_free(struct joydev *joydev)
{
- devfs_remove("input/js%d", joydev->minor);
joydev_table[joydev->minor] = NULL;
- class_simple_device_remove(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE +
joydev->minor));
kfree(joydev);
}
@@ -466,6 +464,8 @@
{
struct joydev *joydev = handle->private;
+ class_simple_device_remove(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE +
joydev->minor));
+ devfs_remove("input/js%d", joydev->minor);
joydev->exist = 0;
if (joydev->open)
diff -Nru a/drivers/input/mousedev.c b/drivers/input/mousedev.c
--- a/drivers/input/mousedev.c 2004-09-30 01:50:26 -05:00
+++ b/drivers/input/mousedev.c 2004-09-30 01:50:26 -05:00
@@ -335,8 +335,6 @@
static void mousedev_free(struct mousedev *mousedev)
{
- devfs_remove("input/mouse%d", mousedev->minor);
- class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE +
mousedev->minor));
mousedev_table[mousedev->minor] = NULL;
kfree(mousedev);
}
@@ -646,6 +644,8 @@
{
struct mousedev *mousedev = handle->private;
+ class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE +
mousedev->minor));
+ devfs_remove("input/mouse%d", mousedev->minor);
mousedev->exist = 0;
if (mousedev->open) {
diff -Nru a/drivers/input/tsdev.c b/drivers/input/tsdev.c
--- a/drivers/input/tsdev.c 2004-09-30 01:50:26 -05:00
+++ b/drivers/input/tsdev.c 2004-09-30 01:50:26 -05:00
@@ -1,7 +1,7 @@
/*
* $Id: tsdev.c,v 1.15 2002/04/10 16:50:19 jsimmons Exp $
*
- * Copyright (c) 2001 "Crazy" james Simmons
+ * Copyright (c) 2001 "Crazy" james Simmons
*
* Compaq touchscreen protocol driver. The protocol emulated by this driver
* is obsolete; for new programs use the tslib library which can read directly
@@ -177,8 +177,6 @@
static void tsdev_free(struct tsdev *tsdev)
{
- devfs_remove("input/ts%d", tsdev->minor);
- class_simple_device_remove(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE +
tsdev->minor));
tsdev_table[tsdev->minor] = NULL;
kfree(tsdev);
}
@@ -418,7 +416,7 @@
S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor);
devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor + TSDEV_MINORS/2),
S_IFCHR|S_IRUGO|S_IWUSR, "input/tsraw%d", minor);
- class_simple_device_add(input_class,
+ class_simple_device_add(input_class,
MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
dev->dev, "ts%d", minor);
@@ -429,6 +427,9 @@
{
struct tsdev *tsdev = handle->private;
+ class_simple_device_remove(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE +
tsdev->minor));
+ devfs_remove("input/ts%d", tsdev->minor);
+ devfs_remove("input/tsraw%d", tsdev->minor);
tsdev->exist = 0;
if (tsdev->open) {
@@ -436,7 +437,6 @@
wake_up_interruptible(&tsdev->wait);
} else
tsdev_free(tsdev);
- devfs_remove("input/tsraw%d", tsdev->minor);
}
static struct input_device_id tsdev_ids[] = {
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel