* Re: suspend [not found] ` <e79639220804030153q46fa82c7jb79bedbe88b30df7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2008-04-03 10:31 ` Oliver Neukum [not found] ` <200804031231.19193.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org> 0 siblings, 1 reply; 16+ messages in thread From: Oliver Neukum @ 2008-04-03 10:31 UTC (permalink / raw) To: Stefan Schweizer Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-input-u79uwXL29TY76Z2rM5mHXA Am Donnerstag, 3. April 2008 10:53:53 schrieb Stefan Schweizer: > > On second thought, this should be fixed by usb persist if the appletouch > > driver supported reset_resume. Would you be willing to test a kernel patch > > that implements reset_resume in the appletouch driver? > > Sure, I would love to have this fixed :-) Then, here's the patch. Testing this is not trivial. Please compile your kernel with CONFIG_USB_SUSPEND and CONFIG_USB_PERSIST. To use the feature you need to switch it on as described in Documentation/usb/persist.txt Regards Oliver ---- --- linux-2.6.25-rc7-vanilla/drivers/input/mouse/appletouch.c 2008-03-31 15:16:40.000000000 +0200 +++ linux-2.6.25-rc7-work/drivers/input/mouse/appletouch.c 2008-04-03 12:17:01.000000000 +0200 @@ -32,6 +32,7 @@ #include <linux/init.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/usb/input.h> /* Apple has powerbooks which have the keyboard with different Product IDs */ @@ -158,6 +159,7 @@ struct atp { int datalen; /* size of an USB urb transfer */ int idlecount; /* number of empty packets */ struct work_struct work; + struct mutex lock; }; #define dbg_dump(msg, tab) \ @@ -562,10 +564,14 @@ static int atp_open(struct input_dev *in { struct atp *dev = input_get_drvdata(input); - if (usb_submit_urb(dev->urb, GFP_ATOMIC)) + mutex_lock(&dev->lock); + if (usb_submit_urb(dev->urb, GFP_KERNEL)) { + mutex_unlock(&dev->lock); return -EIO; + } dev->open = 1; + mutex_unlock(&dev->lock); return 0; } @@ -573,9 +579,25 @@ static void atp_close(struct input_dev * { struct atp *dev = input_get_drvdata(input); + mutex_lock(&dev->lock); usb_kill_urb(dev->urb); cancel_work_sync(&dev->work); dev->open = 0; + mutex_unlock(&dev->lock); +} + +static int handle_geyser(struct atp *dev) +{ + struct usb_device *udev = dev->udev; + + if (!atp_is_fountain(dev)) { + /* switch to raw sensor mode */ + if (atp_geyser_init(udev)) + return -EIO; + + printk(KERN_INFO "appletouch: Geyser mode initialized.\n"); + } + return 0; } static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) @@ -612,6 +634,7 @@ static int atp_probe(struct usb_interfac goto err_free_devs; } + mutex_init(&dev->lock); dev->udev = udev; dev->input = input_dev; dev->overflowwarn = 0; @@ -622,13 +645,8 @@ static int atp_probe(struct usb_interfac else dev->datalen = 81; - if (!atp_is_fountain(dev)) { - /* switch to raw sensor mode */ - if (atp_geyser_init(udev)) - goto err_free_devs; - - printk(KERN_INFO "appletouch: Geyser mode initialized.\n"); - } + if (handle_geyser(dev) < 0) + goto err_free_devs; dev->urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->urb) @@ -747,18 +765,63 @@ static int atp_resume(struct usb_interfa { struct atp *dev = usb_get_intfdata(iface); - if (dev->open && usb_submit_urb(dev->urb, GFP_ATOMIC)) + if (dev->open && usb_submit_urb(dev->urb, GFP_NOIO)) return -EIO; return 0; } +static int recover_dev(struct atp *dev) +{ + int rv; + + rv = handle_geyser(dev); + if (rv < 0) + return rv; + + if (dev->open && usb_submit_urb(dev->urb, GFP_NOIO)) + return -EIO; + + return 0; +} + +static int atp_pre_reset(struct usb_interface *iface) +{ + struct atp *dev = usb_get_intfdata(iface); + + mutex_lock(&dev->lock); + if (dev->open) + usb_kill_urb(dev->urb); + + return 0; +} + +static int atp_post_reset(struct usb_interface *iface) +{ + struct atp *dev = usb_get_intfdata(iface); + int rv; + + rv = recover_dev(dev); + mutex_unlock(&dev->lock); + return rv; +} + +static int atp_reset_resume(struct usb_interface *iface) +{ + struct atp *dev = usb_get_intfdata(iface); + + return recover_dev(dev); +} + static struct usb_driver atp_driver = { .name = "appletouch", .probe = atp_probe, .disconnect = atp_disconnect, .suspend = atp_suspend, .resume = atp_resume, + .reset_resume = atp_reset_resume, + .pre_reset = atp_pre_reset, + .post_reset = atp_post_reset, .id_table = atp_table, }; -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <200804031231.19193.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>]
* Re: suspend [not found] ` <200804031231.19193.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org> @ 2008-04-03 15:44 ` Stefan Schweizer 2008-04-03 20:42 ` suspend Oliver Neukum 0 siblings, 1 reply; 16+ messages in thread From: Stefan Schweizer @ 2008-04-03 15:44 UTC (permalink / raw) To: Oliver Neukum Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-input-u79uwXL29TY76Z2rM5mHXA Cannot seem to find the persist attribute even after this patch applied :(( CONFIG_USB_PERSIST is enabled, but other drivers do not provide it. However this is 2.6.24 - I will try it on 2.6.25 now. macbook linux # ls -dl /sys/bus/usb/devices/1-2\:1.1/driver lrwxrwxrwx 1 root root 0 3. Apr 17:12 /sys/bus/usb/devices/1-2:1.1/driver -> ../../../../../../bus/usb/drivers/appletouch macbook linux # find /sys/bus/usb/devices/1-2\:1.1/ | grep power /sys/bus/usb/devices/1-2:1.1/power /sys/bus/usb/devices/1-2:1.1/power/wakeup /sys/bus/usb/devices/1-2:1.1/input/input7/power /sys/bus/usb/devices/1-2:1.1/input/input7/power/wakeup /sys/bus/usb/devices/1-2:1.1/input/input7/mouse2/power /sys/bus/usb/devices/1-2:1.1/input/input7/mouse2/power/wakeup /sys/bus/usb/devices/1-2:1.1/input/input7/event7/power /sys/bus/usb/devices/1-2:1.1/input/input7/event7/power/wakeup /sys/bus/usb/devices/1-2:1.1/usb_endpoint/usbdev1.5_ep81/power /sys/bus/usb/devices/1-2:1.1/usb_endpoint/usbdev1.5_ep81/power/wakeup Best regards, Stefan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: suspend 2008-04-03 15:44 ` suspend Stefan Schweizer @ 2008-04-03 20:42 ` Oliver Neukum [not found] ` <200804032242.36493.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org> 0 siblings, 1 reply; 16+ messages in thread From: Oliver Neukum @ 2008-04-03 20:42 UTC (permalink / raw) To: Stefan Schweizer, Alan Stern; +Cc: linux-usb, linux-input Am Donnerstag, 3. April 2008 17:44:19 schrieb Stefan Schweizer: > Cannot seem to find the persist attribute even after this patch applied :(( > > CONFIG_USB_PERSIST is enabled, but other drivers do not provide it. > However this is 2.6.24 - I will try it on 2.6.25 now. Odd, I can't reproduce it. Alan? Regards Oliver oneukum@tranquility:/sys/bus/usb/devices/6-1/power> ll insgesamt 0 -r--r--r-- 1 root root 4096 3. Apr 22:40 active_duration -rw-r--r-- 1 root root 4096 3. Apr 22:40 autosuspend -r--r--r-- 1 root root 4096 3. Apr 22:40 connected_duration -rw-r--r-- 1 root root 4096 3. Apr 22:40 level -rw-r--r-- 1 root root 4096 3. Apr 22:40 persist -rw-r--r-- 1 root root 4096 3. Apr 22:40 wakeup ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <200804032242.36493.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>]
* Re: suspend [not found] ` <200804032242.36493.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org> @ 2008-04-03 21:41 ` Alan Stern 2008-04-03 22:06 ` suspend Stefan Schweizer 0 siblings, 1 reply; 16+ messages in thread From: Alan Stern @ 2008-04-03 21:41 UTC (permalink / raw) To: Oliver Neukum Cc: Stefan Schweizer, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-input-u79uwXL29TY76Z2rM5mHXA On Thu, 3 Apr 2008, Oliver Neukum wrote: > Am Donnerstag, 3. April 2008 17:44:19 schrieb Stefan Schweizer: > > Cannot seem to find the persist attribute even after this patch applied :(( > > > > CONFIG_USB_PERSIST is enabled, but other drivers do not provide it. > > However this is 2.6.24 - I will try it on 2.6.25 now. > > Odd, I can't reproduce it. Alan? > > Regards > Oliver > > oneukum@tranquility:/sys/bus/usb/devices/6-1/power> ll > insgesamt 0 > -r--r--r-- 1 root root 4096 3. Apr 22:40 active_duration > -rw-r--r-- 1 root root 4096 3. Apr 22:40 autosuspend > -r--r--r-- 1 root root 4096 3. Apr 22:40 connected_duration > -rw-r--r-- 1 root root 4096 3. Apr 22:40 level > -rw-r--r-- 1 root root 4096 3. Apr 22:40 persist > -rw-r--r-- 1 root root 4096 3. Apr 22:40 wakeup Sometimes people run into problems when rebuilding usbcore. Depending on the distribution, the usbcore.ko module is sometimes loaded as part of an initramfs image. Merely installing the new modules won't change the image. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: suspend 2008-04-03 21:41 ` suspend Alan Stern @ 2008-04-03 22:06 ` Stefan Schweizer 2008-04-04 8:59 ` suspend Oliver Neukum 0 siblings, 1 reply; 16+ messages in thread From: Stefan Schweizer @ 2008-04-03 22:06 UTC (permalink / raw) To: Alan Stern; +Cc: Oliver Neukum, linux-usb, linux-input Hi, the problem was that I did not identify the correct /sys entry. Anyways with for i in $(find /sys -name persist); do echo 1 > '$i'; done it works perfectly :-) Thank you very much! Finally working touchpad after resume :-) Best regards, Stefan ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: suspend 2008-04-03 22:06 ` suspend Stefan Schweizer @ 2008-04-04 8:59 ` Oliver Neukum 2008-04-04 9:20 ` suspend Stefan Schweizer 0 siblings, 1 reply; 16+ messages in thread From: Oliver Neukum @ 2008-04-04 8:59 UTC (permalink / raw) To: Stefan Schweizer; +Cc: Alan Stern, linux-usb, linux-input Am Freitag, 4. April 2008 00:06:48 schrieb Stefan Schweizer: > Hi, > > the problem was that I did not identify the correct /sys entry. Anyways with > > for i in $(find /sys -name persist); do echo 1 > '$i'; done > > it works perfectly :-) > > Thank you very much! Finally working touchpad after resume :-) Good. Did you test the first patch or the second? Can you test whether the device autosuspends with the combined patch I sent you? Regards Oliver ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: suspend 2008-04-04 8:59 ` suspend Oliver Neukum @ 2008-04-04 9:20 ` Stefan Schweizer [not found] ` <e79639220804040220g560e94b4l418724ff1653780d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 16+ messages in thread From: Stefan Schweizer @ 2008-04-04 9:20 UTC (permalink / raw) To: Oliver Neukum; +Cc: Alan Stern, linux-usb, linux-input Yeah, I tested it with the combined patch. How can I test if autosuspend works? Seems to work fine so far but does not write in my logfile. No problems found when testing. Best regards, Stefan ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <e79639220804040220g560e94b4l418724ff1653780d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: suspend [not found] ` <e79639220804040220g560e94b4l418724ff1653780d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2008-04-04 11:36 ` Oliver Neukum 2008-04-04 22:40 ` suspend Stefan Schweizer 0 siblings, 1 reply; 16+ messages in thread From: Oliver Neukum @ 2008-04-04 11:36 UTC (permalink / raw) To: Stefan Schweizer Cc: Alan Stern, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-input-u79uwXL29TY76Z2rM5mHXA Am Freitag, 4. April 2008 11:20:51 schrieb Stefan Schweizer: > Yeah, I tested it with the combined patch. How can I test if > autosuspend works? Seems to work fine so far but does not write in my > logfile. No problems found when testing. Please compile your kernel with CONFIG_PM_DEBUG and follow the instructions in Documentation/usb. You should see something in the log. Regards Oliver -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: suspend 2008-04-04 11:36 ` suspend Oliver Neukum @ 2008-04-04 22:40 ` Stefan Schweizer 2008-04-05 8:00 ` suspend Oliver Neukum 0 siblings, 1 reply; 16+ messages in thread From: Stefan Schweizer @ 2008-04-04 22:40 UTC (permalink / raw) To: Oliver Neukum; +Cc: Alan Stern, linux-usb, linux-input On Fri, Apr 4, 2008 at 1:36 PM, Oliver Neukum <oliver@neukum.org> wrote: > Am Freitag, 4. April 2008 11:20:51 schrieb Stefan Schweizer: > > > Yeah, I tested it with the combined patch. How can I test if > > autosuspend works? Seems to work fine so far but does not write in my > > logfile. No problems found when testing. > > Please compile your kernel with CONFIG_PM_DEBUG and follow the > instructions in Documentation/usb. You should see something in the log. there is still no information in dmesg when I use the device. Do I need more debugging maybe? That is one rmmod; modprobe cycle: usbcore: deregistering interface driver appletouch PM: Removing info for No Bus:mouse1 PM: Removing info for No Bus:event5 PM: Removing info for No Bus:input5 input: appletouch disconnected appletouch: Geyser mode initialized. PM: Adding info for No Bus:input12 input: appletouch as /devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2:1.1/input/input12 PM: Adding info for No Bus:mouse1 PM: Adding info for No Bus:event5 usbcore: registered new interface driver appletouch Best regards, Stefan ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: suspend 2008-04-04 22:40 ` suspend Stefan Schweizer @ 2008-04-05 8:00 ` Oliver Neukum 2008-04-05 9:15 ` suspend Stefan Schweizer 2008-04-05 14:13 ` suspend Alan Stern 0 siblings, 2 replies; 16+ messages in thread From: Oliver Neukum @ 2008-04-05 8:00 UTC (permalink / raw) To: Stefan Schweizer; +Cc: Alan Stern, linux-usb, linux-input Am Samstag, 5. April 2008 00:40:35 schrieb Stefan Schweizer: > On Fri, Apr 4, 2008 at 1:36 PM, Oliver Neukum <oliver@neukum.org> wrote: > > Am Freitag, 4. April 2008 11:20:51 schrieb Stefan Schweizer: > > > > > Yeah, I tested it with the combined patch. How can I test if > > > autosuspend works? Seems to work fine so far but does not write in my > > > logfile. No problems found when testing. > > > > Please compile your kernel with CONFIG_PM_DEBUG and follow the > > instructions in Documentation/usb. You should see something in the log. > > there is still no information in dmesg when I use the device. Do I > need more debugging maybe? Ok, please locate the directory for your touchpad in sysfs and post all files in the power subdirectory. Regards Oliver ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: suspend 2008-04-05 8:00 ` suspend Oliver Neukum @ 2008-04-05 9:15 ` Stefan Schweizer [not found] ` <e79639220804050215j42829de7iab99b51e85683a53-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2008-04-05 14:13 ` suspend Alan Stern 1 sibling, 1 reply; 16+ messages in thread From: Stefan Schweizer @ 2008-04-05 9:15 UTC (permalink / raw) To: Oliver Neukum; +Cc: Alan Stern, linux-usb, linux-input On Sat, Apr 5, 2008 at 10:00 AM, Oliver Neukum <oliver@neukum.org> wrote: > Ok, please locate the directory for your touchpad in sysfs and post all > files in the power subdirectory. The kernel documentation says that "auto" is default for level. Why is it "on" here? Simple startup line to make it right: for i in $(find /sys | grep power/level); do echo auto > "$i"; done But still no extra info in dmesg :( # ls /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-2/power/ autosuspend level persist wakeup power # for i in *; do echo $i: $(<$i); done autosuspend: 2 level: on persist: 1 wakeup: enabled 2-2 # for i in *; do echo $i: $(<$i); done 2-2:1.0: 2-2:1.1: 2-2:1.2: authorized: 1 bcdDevice: 0064 bConfigurationValue: 1 bDeviceClass: 00 bDeviceProtocol: 00 bDeviceSubClass: 00 bmAttributes: a0 bMaxPacketSize0: 8 bMaxPower: 40mA bNumConfigurations: 1 bNumInterfaces: 3 busnum: 2 configuration: " !"Y� !"��▒d T� ! dev: 189:136 devnum: 9 driver: ep_00: idProduct: 0218 idVendor: 05ac manufacturer: Apple Computer maxchild: 0 power: product: Apple Internal Keyboard / Trackpad quirks: 0x0 speed: 12 subsystem: uevent: MAJOR=189 MINOR=136 DEVTYPE=usb_device DRIVER=usb DEVICE=/proc/bus/usb/002/009 PRODUCT=5ac/218/64 TYPE=0/0/0 BUSNUM=002 DEVNUM=009 urbnum: 3615 usb_endpoint: version: 2.00 Regards, Stefan ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <e79639220804050215j42829de7iab99b51e85683a53-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: suspend [not found] ` <e79639220804050215j42829de7iab99b51e85683a53-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2008-04-05 9:12 ` Oliver Neukum 0 siblings, 0 replies; 16+ messages in thread From: Oliver Neukum @ 2008-04-05 9:12 UTC (permalink / raw) To: Stefan Schweizer Cc: Alan Stern, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-input-u79uwXL29TY76Z2rM5mHXA Am Samstag, 5. April 2008 11:15:55 schrieb Stefan Schweizer: > The kernel documentation says that "auto" is default for level. Why is > it "on" here? Simple startup line to make it right: Which kernel version are you using? In modern kernels the default is "on". Regards Oliver -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: suspend 2008-04-05 8:00 ` suspend Oliver Neukum 2008-04-05 9:15 ` suspend Stefan Schweizer @ 2008-04-05 14:13 ` Alan Stern 1 sibling, 0 replies; 16+ messages in thread From: Alan Stern @ 2008-04-05 14:13 UTC (permalink / raw) To: Oliver Neukum; +Cc: Stefan Schweizer, linux-usb, linux-input On Sat, 5 Apr 2008, Oliver Neukum wrote: > Am Samstag, 5. April 2008 00:40:35 schrieb Stefan Schweizer: > > On Fri, Apr 4, 2008 at 1:36 PM, Oliver Neukum <oliver@neukum.org> wrote: > > > Am Freitag, 4. April 2008 11:20:51 schrieb Stefan Schweizer: > > > > > > > Yeah, I tested it with the combined patch. How can I test if > > > > autosuspend works? Seems to work fine so far but does not write in my > > > > logfile. No problems found when testing. > > > > > > Please compile your kernel with CONFIG_PM_DEBUG and follow the > > > instructions in Documentation/usb. You should see something in the log. Note that CONFIG_PM_DEBUG has nothing to do with autosuspend. You shouldn't expect to see anything unless you set CONFIG_USB_DEBUG. > > there is still no information in dmesg when I use the device. Do I > > need more debugging maybe? > > Ok, please locate the directory for your touchpad in sysfs and post all > files in the power subdirectory. Alan Stern ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: suspend [not found] ` <e79639220804030153q46fa82c7jb79bedbe88b30df7@mail.gmail.com> [not found] ` <e79639220804030153q46fa82c7jb79bedbe88b30df7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2008-04-03 10:58 ` Oliver Neukum 2008-04-03 14:14 ` suspend Stefan Schweizer 1 sibling, 1 reply; 16+ messages in thread From: Oliver Neukum @ 2008-04-03 10:58 UTC (permalink / raw) To: Stefan Schweizer; +Cc: linux-usb, linux-input Am Donnerstag, 3. April 2008 10:53:53 schrieb Stefan Schweizer: > > On second thought, this should be fixed by usb persist if the appletouch > > driver supported reset_resume. Would you be willing to test a kernel patch > > that implements reset_resume in the appletouch driver? > > Sure, I would love to have this fixed :-) Hi, here I have another test request. This patch on top of the earlier patch implements autosuspend for the appletouch driver. Can you try it? You also need to activate it as described in Documentation/usb/power-management.txt Regards Oliver --- --- linux-2.6.25-rc7-work/drivers/input/mouse/appletouch.c.alt 2008-04-03 12:46:06.000000000 +0200 +++ linux-2.6.25-rc7-work/drivers/input/mouse/appletouch.c 2008-04-03 12:46:24.000000000 +0200 @@ -572,16 +572,26 @@ exit: static int atp_open(struct input_dev *input) { struct atp *dev = input_get_drvdata(input); + int rv; mutex_lock(&dev->lock); - if (usb_submit_urb(dev->urb, GFP_KERNEL)) { - mutex_unlock(&dev->lock); - return -EIO; - } + + rv = usb_autopm_get_interface(dev->intf); + if ( rv < 0) + goto err_out; + + rv = usb_submit_urb(dev->urb, GFP_KERNEL); + if (rv < 0) + goto err_put; dev->open = 1; + dev->intf->needs_remote_wakeup = 1; + +err_put: + usb_autopm_put_interface(dev->intf); +err_out: mutex_unlock(&dev->lock); - return 0; + return rv; } static void atp_close(struct input_dev *input) @@ -592,6 +602,7 @@ static void atp_close(struct input_dev * usb_kill_urb(dev->urb); cancel_work_sync(&dev->work); dev->open = 0; + dev->intf->needs_remote_wakeup = 0; mutex_unlock(&dev->lock); } ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: suspend 2008-04-03 10:58 ` suspend Oliver Neukum @ 2008-04-03 14:14 ` Stefan Schweizer 2008-04-03 21:07 ` suspend Oliver Neukum 0 siblings, 1 reply; 16+ messages in thread From: Stefan Schweizer @ 2008-04-03 14:14 UTC (permalink / raw) To: Oliver Neukum; +Cc: linux-usb, linux-input On Thu, Apr 3, 2008 at 12:58 PM, Oliver Neukum <oliver@neukum.org> wrote: > here I have another test request. This patch on top of the earlier patch > implements autosuspend for the appletouch driver. Can you try it? You > also need to activate it as described in Documentation/usb/power-management.txt this one fails to build with several struct atp has no element intf errors. trying the other one only now regards, Stefan ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: suspend 2008-04-03 14:14 ` suspend Stefan Schweizer @ 2008-04-03 21:07 ` Oliver Neukum 0 siblings, 0 replies; 16+ messages in thread From: Oliver Neukum @ 2008-04-03 21:07 UTC (permalink / raw) To: Stefan Schweizer; +Cc: linux-usb, linux-input Am Donnerstag, 3. April 2008 16:14:29 schrieb Stefan Schweizer: > On Thu, Apr 3, 2008 at 12:58 PM, Oliver Neukum <oliver@neukum.org> wrote: > > here I have another test request. This patch on top of the earlier patch > > implements autosuspend for the appletouch driver. Can you try it? You > > also need to activate it as described in Documentation/usb/power-management.txt > > this one fails to build with several > struct atp has no element intf > errors. Sorry. Here's a full patch. Regards Oliver --- --- linux-2.6.25-rc7-vanilla/drivers/input/mouse/appletouch.c 2008-03-31 15:16:40.000000000 +0200 +++ linux-2.6.25-rc7-work/drivers/input/mouse/appletouch.c 2008-04-03 12:46:24.000000000 +0200 @@ -32,6 +32,7 @@ #include <linux/init.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/usb/input.h> /* Apple has powerbooks which have the keyboard with different Product IDs */ @@ -140,6 +141,7 @@ MODULE_DEVICE_TABLE (usb, atp_table); struct atp { char phys[64]; struct usb_device * udev; /* usb device */ + struct usb_interface * intf; /* usb interface */ struct urb * urb; /* usb request block */ signed char * data; /* transferred data */ struct input_dev * input; /* input dev */ @@ -158,6 +160,7 @@ struct atp { int datalen; /* size of an USB urb transfer */ int idlecount; /* number of empty packets */ struct work_struct work; + struct mutex lock; }; #define dbg_dump(msg, tab) \ @@ -345,6 +348,11 @@ static inline void atp_report_fingers(st input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2); } +static void atp_mark_busy(struct atp *dev) +{ + usb_mark_last_busy(dev->udev); +} + static void atp_complete(struct urb* urb) { int x, y, x_z, y_z, x_f, y_f; @@ -384,6 +392,9 @@ static void atp_complete(struct urb* urb goto exit; } + /* mark busy for autosuspend purposes */ + atp_mark_busy(dev); + /* reorder the sensors values */ if (atp_is_geyser_3(dev)) { memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); @@ -561,21 +572,52 @@ exit: static int atp_open(struct input_dev *input) { struct atp *dev = input_get_drvdata(input); + int rv; - if (usb_submit_urb(dev->urb, GFP_ATOMIC)) - return -EIO; + mutex_lock(&dev->lock); + + rv = usb_autopm_get_interface(dev->intf); + if ( rv < 0) + goto err_out; + + rv = usb_submit_urb(dev->urb, GFP_KERNEL); + if (rv < 0) + goto err_put; dev->open = 1; - return 0; + dev->intf->needs_remote_wakeup = 1; + +err_put: + usb_autopm_put_interface(dev->intf); +err_out: + mutex_unlock(&dev->lock); + return rv; } static void atp_close(struct input_dev *input) { struct atp *dev = input_get_drvdata(input); + mutex_lock(&dev->lock); usb_kill_urb(dev->urb); cancel_work_sync(&dev->work); dev->open = 0; + dev->intf->needs_remote_wakeup = 0; + mutex_unlock(&dev->lock); +} + +static int handle_geyser(struct atp *dev) +{ + struct usb_device *udev = dev->udev; + + if (!atp_is_fountain(dev)) { + /* switch to raw sensor mode */ + if (atp_geyser_init(udev)) + return -EIO; + + printk(KERN_INFO "appletouch: Geyser mode initialized.\n"); + } + return 0; } static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) @@ -612,7 +654,9 @@ static int atp_probe(struct usb_interfac goto err_free_devs; } + mutex_init(&dev->lock); dev->udev = udev; + dev->intf = iface; dev->input = input_dev; dev->overflowwarn = 0; if (atp_is_geyser_3(dev)) @@ -622,13 +666,8 @@ static int atp_probe(struct usb_interfac else dev->datalen = 81; - if (!atp_is_fountain(dev)) { - /* switch to raw sensor mode */ - if (atp_geyser_init(udev)) - goto err_free_devs; - - printk(KERN_INFO "appletouch: Geyser mode initialized.\n"); - } + if (handle_geyser(dev) < 0) + goto err_free_devs; dev->urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->urb) @@ -747,19 +786,65 @@ static int atp_resume(struct usb_interfa { struct atp *dev = usb_get_intfdata(iface); - if (dev->open && usb_submit_urb(dev->urb, GFP_ATOMIC)) + if (dev->open && usb_submit_urb(dev->urb, GFP_NOIO)) return -EIO; return 0; } +static int recover_dev(struct atp *dev) +{ + int rv; + + rv = handle_geyser(dev); + if (rv < 0) + return rv; + + if (dev->open && usb_submit_urb(dev->urb, GFP_NOIO)) + return -EIO; + + return 0; +} + +static int atp_pre_reset(struct usb_interface *iface) +{ + struct atp *dev = usb_get_intfdata(iface); + + mutex_lock(&dev->lock); + if (dev->open) + usb_kill_urb(dev->urb); + + return 0; +} + +static int atp_post_reset(struct usb_interface *iface) +{ + struct atp *dev = usb_get_intfdata(iface); + int rv; + + rv = recover_dev(dev); + mutex_unlock(&dev->lock); + return rv; +} + +static int atp_reset_resume(struct usb_interface *iface) +{ + struct atp *dev = usb_get_intfdata(iface); + + return recover_dev(dev); +} + static struct usb_driver atp_driver = { .name = "appletouch", .probe = atp_probe, .disconnect = atp_disconnect, .suspend = atp_suspend, .resume = atp_resume, + .reset_resume = atp_reset_resume, + .pre_reset = atp_pre_reset, + .post_reset = atp_post_reset, .id_table = atp_table, + .supports_autosuspend = 1, }; static int __init atp_init(void) ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2008-04-05 14:13 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <dd18b0c30804012331oc548416k113e492d7dc9c189@mail.gmail.com> [not found] ` <200804031029.26635.oliver@neukum.org> [not found] ` <e79639220804030153q46fa82c7jb79bedbe88b30df7@mail.gmail.com> [not found] ` <e79639220804030153q46fa82c7jb79bedbe88b30df7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2008-04-03 10:31 ` suspend Oliver Neukum [not found] ` <200804031231.19193.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org> 2008-04-03 15:44 ` suspend Stefan Schweizer 2008-04-03 20:42 ` suspend Oliver Neukum [not found] ` <200804032242.36493.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org> 2008-04-03 21:41 ` suspend Alan Stern 2008-04-03 22:06 ` suspend Stefan Schweizer 2008-04-04 8:59 ` suspend Oliver Neukum 2008-04-04 9:20 ` suspend Stefan Schweizer [not found] ` <e79639220804040220g560e94b4l418724ff1653780d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2008-04-04 11:36 ` suspend Oliver Neukum 2008-04-04 22:40 ` suspend Stefan Schweizer 2008-04-05 8:00 ` suspend Oliver Neukum 2008-04-05 9:15 ` suspend Stefan Schweizer [not found] ` <e79639220804050215j42829de7iab99b51e85683a53-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2008-04-05 9:12 ` suspend Oliver Neukum 2008-04-05 14:13 ` suspend Alan Stern 2008-04-03 10:58 ` suspend Oliver Neukum 2008-04-03 14:14 ` suspend Stefan Schweizer 2008-04-03 21:07 ` suspend Oliver Neukum
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).