* autosuspend for appletouch driver @ 2007-09-21 8:47 Oliver Neukum [not found] ` <d120d5000709261317u13dfce0dn5538f54425d5e225@mail.gmail.com> 0 siblings, 1 reply; 7+ messages in thread From: Oliver Neukum @ 2007-09-21 8:47 UTC (permalink / raw) To: Richard Guenther, linux-usb-devel, linux-input Hi, here's the first version of a patch to do autosuspend for the appletouch driver. It is against 2.6.23-rc6. It compiles. More I can't guarantee. Regards Oliver ----- --- a/drivers/input/mouse/appletouch.c 2007-09-20 14:14:46.000000000 +0200 +++ b/drivers/input/mouse/appletouch.c 2007-09-21 10:39:21.000000000 +0200 @@ -140,6 +140,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 */ int open; /* non-zero if opened */ @@ -324,6 +325,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; @@ -362,6 +368,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)); @@ -528,12 +537,20 @@ exit: static int atp_open(struct input_dev *input) { struct atp *dev = input_get_drvdata(input); + int rv = 0; - if (usb_submit_urb(dev->urb, GFP_ATOMIC)) + if (usb_autopm_get_interface(dev->intf) < 0) return -EIO; + dev->intf->needs_remote_wakeup = 1; + if (usb_submit_urb(dev->urb, GFP_KERNEL)) { + rv = -EIO; + dev->intf->needs_remote_wakeup = 0; + goto err; dev->open = 1; - return 0; +err: + usb_autopm_put_interface(dev->intf); + return rv; } static void atp_close(struct input_dev *input) @@ -543,6 +560,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; } static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) @@ -580,6 +598,7 @@ static int atp_probe(struct usb_interfac } dev->udev = udev; + dev->intf = iface; dev->input = input_dev; dev->overflowwarn = 0; if (atp_is_geyser_3(dev)) @@ -714,7 +733,7 @@ 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; @@ -727,6 +746,7 @@ static struct usb_driver atp_driver = { .suspend = atp_suspend, .resume = atp_resume, .id_table = atp_table, + .supports_autosuspend = 1, }; static int __init atp_init(void) ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <d120d5000709261317u13dfce0dn5538f54425d5e225@mail.gmail.com>]
* Re: Fwd: [linux-usb-devel] autosuspend for appletouch driver [not found] ` <d120d5000709261317u13dfce0dn5538f54425d5e225@mail.gmail.com> @ 2007-09-27 6:29 ` Oliver Neukum 2007-09-27 15:59 ` [linux-usb-devel] Fwd: " Alan Stern 0 siblings, 1 reply; 7+ messages in thread From: Oliver Neukum @ 2007-09-27 6:29 UTC (permalink / raw) To: Dmitry Torokhov, linux-input, linux-usb-devel, Richard Guenther Cc: Matthew Garrett, Soeren Sonnenburg, Thomas Rohwer Am Mittwoch 26 September 2007 schrieb Dmitry Torokhov: > Guys, > > Have you seen this? Is anyone willingto give this patch a try? And promptly I see a bug. Please try this code. I don't understand why the original even compiled. Regards Oliver ---- --- a/drivers/input/mouse/appletouch.c 2007-09-20 14:14:46.000000000 +0200 +++ b/drivers/input/mouse/appletouch.c 2007-09-27 08:22:13.000000000 +0200 @@ -140,6 +140,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 */ int open; /* non-zero if opened */ @@ -324,6 +325,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; @@ -362,6 +368,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)); @@ -528,12 +537,20 @@ exit: static int atp_open(struct input_dev *input) { struct atp *dev = input_get_drvdata(input); + int rv = 0; - if (usb_submit_urb(dev->urb, GFP_ATOMIC)) + if (usb_autopm_get_interface(dev->intf) < 0) return -EIO; + dev->intf->needs_remote_wakeup = 1; + if (usb_submit_urb(dev->urb, GFP_KERNEL)) { + rv = -EIO; + dev->intf->needs_remote_wakeup = 0; + goto err; dev->open = 1; - return 0; +err: + usb_autopm_put_interface(dev->intf); + return rv; } static void atp_close(struct input_dev *input) @@ -543,6 +560,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; } static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) @@ -580,6 +598,7 @@ static int atp_probe(struct usb_interfac } dev->udev = udev; + dev->intf = iface; dev->input = input_dev; dev->overflowwarn = 0; if (atp_is_geyser_3(dev)) @@ -714,7 +733,7 @@ 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; @@ -727,6 +746,7 @@ static struct usb_driver atp_driver = { .suspend = atp_suspend, .resume = atp_resume, .id_table = atp_table, + .supports_autosuspend = 1, }; static int __init atp_init(void) ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [linux-usb-devel] Fwd: autosuspend for appletouch driver 2007-09-27 6:29 ` Fwd: [linux-usb-devel] " Oliver Neukum @ 2007-09-27 15:59 ` Alan Stern 2007-09-27 18:05 ` Oliver Neukum 0 siblings, 1 reply; 7+ messages in thread From: Alan Stern @ 2007-09-27 15:59 UTC (permalink / raw) To: Oliver Neukum Cc: Dmitry Torokhov, linux-input, linux-usb-devel, Richard Guenther, Matthew Garrett, Soeren Sonnenburg, Thomas Rohwer On Thu, 27 Sep 2007, Oliver Neukum wrote: > @@ -528,12 +537,20 @@ exit: > static int atp_open(struct input_dev *input) > { > struct atp *dev = input_get_drvdata(input); > + int rv = 0; > > - if (usb_submit_urb(dev->urb, GFP_ATOMIC)) > + if (usb_autopm_get_interface(dev->intf) < 0) > return -EIO; > + dev->intf->needs_remote_wakeup = 1; > + if (usb_submit_urb(dev->urb, GFP_KERNEL)) { > + rv = -EIO; > + dev->intf->needs_remote_wakeup = 0; > + goto err; > > dev->open = 1; > - return 0; > +err: > + usb_autopm_put_interface(dev->intf); > + return rv; > } > > static void atp_close(struct input_dev *input) > @@ -543,6 +560,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; > } Doesn't atp_close() need to call usb_autopm_put_interface(), to balance the usb_autopm_get_interface() call in atp_open()? Alan Stern ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Fwd: autosuspend for appletouch driver 2007-09-27 15:59 ` [linux-usb-devel] Fwd: " Alan Stern @ 2007-09-27 18:05 ` Oliver Neukum 2007-09-27 18:39 ` [linux-usb-devel] " Alan Stern 0 siblings, 1 reply; 7+ messages in thread From: Oliver Neukum @ 2007-09-27 18:05 UTC (permalink / raw) To: Alan Stern Cc: Matthew Garrett, Soeren Sonnenburg, Thomas Rohwer, Richard Guenther, linux-usb-devel, Dmitry Torokhov, linux-input Am Donnerstag 27 September 2007 schrieb Alan Stern: > On Thu, 27 Sep 2007, Oliver Neukum wrote: > > > @@ -528,12 +537,20 @@ exit: > > static int atp_open(struct input_dev *input) > > { > > struct atp *dev = input_get_drvdata(input); > > + int rv = 0; > > > > - if (usb_submit_urb(dev->urb, GFP_ATOMIC)) > > + if (usb_autopm_get_interface(dev->intf) < 0) > > return -EIO; > > + dev->intf->needs_remote_wakeup = 1; > > + if (usb_submit_urb(dev->urb, GFP_KERNEL)) { > > + rv = -EIO; > > + dev->intf->needs_remote_wakeup = 0; > > + goto err; > > > > dev->open = 1; > > - return 0; > > +err: > > + usb_autopm_put_interface(dev->intf); > > + return rv; > > } > > > > static void atp_close(struct input_dev *input) > > @@ -543,6 +560,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; > > } > > Doesn't atp_close() need to call usb_autopm_put_interface(), to balance > the usb_autopm_get_interface() call in atp_open()? No, the get is balanced in atp_open() itself. The patch uses the last_busy mechanism the same way the version for generic hid does. In fact, it is only necessary because there's no nice API call for setting needs_remote_wakeup. Regards Oliver ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [linux-usb-devel] Fwd: autosuspend for appletouch driver 2007-09-27 18:05 ` Oliver Neukum @ 2007-09-27 18:39 ` Alan Stern 2007-09-27 18:43 ` Oliver Neukum 0 siblings, 1 reply; 7+ messages in thread From: Alan Stern @ 2007-09-27 18:39 UTC (permalink / raw) To: Oliver Neukum Cc: Dmitry Torokhov, linux-input, linux-usb-devel, Richard Guenther, Matthew Garrett, Soeren Sonnenburg, Thomas Rohwer On Thu, 27 Sep 2007, Oliver Neukum wrote: > Am Donnerstag 27 September 2007 schrieb Alan Stern: > > On Thu, 27 Sep 2007, Oliver Neukum wrote: > > > > > @@ -528,12 +537,20 @@ exit: > > > static int atp_open(struct input_dev *input) > > > { > > > struct atp *dev = input_get_drvdata(input); > > > + int rv = 0; > > > > > > - if (usb_submit_urb(dev->urb, GFP_ATOMIC)) > > > + if (usb_autopm_get_interface(dev->intf) < 0) > > > return -EIO; > > > + dev->intf->needs_remote_wakeup = 1; > > > + if (usb_submit_urb(dev->urb, GFP_KERNEL)) { > > > + rv = -EIO; > > > + dev->intf->needs_remote_wakeup = 0; > > > + goto err; > > > > > > dev->open = 1; > > > - return 0; > > > +err: > > > + usb_autopm_put_interface(dev->intf); > > > + return rv; > > > } > > > > > > static void atp_close(struct input_dev *input) > > > @@ -543,6 +560,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; > > > } > > > > Doesn't atp_close() need to call usb_autopm_put_interface(), to balance > > the usb_autopm_get_interface() call in atp_open()? > > No, the get is balanced in atp_open() itself. I see; I misread the patch. > The patch uses the last_busy > mechanism the same way the version for generic hid does. In fact, it is > only necessary because there's no nice API call for setting > needs_remote_wakeup. That's okay; even if there were a nice API call for setting needs_remote_wakeup you would still have to call usb_autopm_get_interface(). This is because we don't keep track of whether or not remote wakeup is currently enabled on a suspended device; we only keep track of whether it should be enabled when the next suspend occurs. Alan Stern ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [linux-usb-devel] Fwd: autosuspend for appletouch driver 2007-09-27 18:39 ` [linux-usb-devel] " Alan Stern @ 2007-09-27 18:43 ` Oliver Neukum 2007-09-27 18:54 ` Alan Stern 0 siblings, 1 reply; 7+ messages in thread From: Oliver Neukum @ 2007-09-27 18:43 UTC (permalink / raw) To: Alan Stern Cc: Dmitry Torokhov, linux-input, linux-usb-devel, Richard Guenther, Matthew Garrett, Soeren Sonnenburg, Thomas Rohwer Am Donnerstag 27 September 2007 schrieb Alan Stern: > > mechanism the same way the version for generic hid does. In fact, it is > > only necessary because there's no nice API call for setting > > needs_remote_wakeup. > > That's okay; even if there were a nice API call for setting > needs_remote_wakeup you would still have to call > usb_autopm_get_interface(). This is because we don't keep track of > whether or not remote wakeup is currently enabled on a suspended Is it worth doing so? Regards Oliver ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [linux-usb-devel] Fwd: autosuspend for appletouch driver 2007-09-27 18:43 ` Oliver Neukum @ 2007-09-27 18:54 ` Alan Stern 0 siblings, 0 replies; 7+ messages in thread From: Alan Stern @ 2007-09-27 18:54 UTC (permalink / raw) To: Oliver Neukum Cc: Dmitry Torokhov, linux-input, linux-usb-devel, Richard Guenther, Matthew Garrett, Soeren Sonnenburg, Thomas Rohwer On Thu, 27 Sep 2007, Oliver Neukum wrote: > Am Donnerstag 27 September 2007 schrieb Alan Stern: > > > mechanism the same way the version for generic hid does. In fact, it is > > > only necessary because there's no nice API call for setting > > > needs_remote_wakeup. > > > > That's okay; even if there were a nice API call for setting > > needs_remote_wakeup you would still have to call > > usb_autopm_get_interface(). This is because we don't keep track of > > whether or not remote wakeup is currently enabled on a suspended > > Is it worth doing so? If enough drivers need it. ("Enough" might mean >= 1.) Alan Stern ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-09-27 18:54 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-09-21 8:47 autosuspend for appletouch driver Oliver Neukum [not found] ` <d120d5000709261317u13dfce0dn5538f54425d5e225@mail.gmail.com> 2007-09-27 6:29 ` Fwd: [linux-usb-devel] " Oliver Neukum 2007-09-27 15:59 ` [linux-usb-devel] Fwd: " Alan Stern 2007-09-27 18:05 ` Oliver Neukum 2007-09-27 18:39 ` [linux-usb-devel] " Alan Stern 2007-09-27 18:43 ` Oliver Neukum 2007-09-27 18:54 ` Alan Stern
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).