linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>,
	Ping Cheng <pingc-JeGq9vS6aD4AvxtiuMwx3w@public.gmane.org>
Cc: Jiri Kosina <jkosina-AlSwsSmVLrQ@public.gmane.org>,
	linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	USB list <linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [patch]suspend and autosuspend for wacom devices
Date: Fri, 11 Apr 2008 09:47:25 -0400	[thread overview]
Message-ID: <20080411094018.ZZRA012@mailhub.coreip.homeip.net> (raw)
In-Reply-To: <200804111520.57418.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>

Hi Oliver,

On Fri, Apr 11, 2008 at 03:20:56PM +0200, Oliver Neukum wrote:
> This implements suspend and autosuspend support for wacom devices.
> It works by using the usb last busy functionality triggered in the completion
> callback.
> 
> Signed-off-by: Oliver Neukum <oneukum-l3A5Bk7waGM@public.gmane.org>
> 

Please also add Ping Cheng to the list when changing wacom driver. She is in
much better position to test any changes to the driver than any of us ;)

> ---
> 
> --- linux-2.6.25-rc7-vanilla/drivers/input/tablet/wacom_sys.c	2008-03-31 15:20:58.000000000 +0200
> +++ linux-2.6.25-rc7-work/drivers/input/tablet/wacom_sys.c	2008-04-11 15:04:18.000000000 +0200
> @@ -70,6 +70,7 @@ static void wacom_sys_irq(struct urb *ur
>  		input_sync(get_input_dev(&wcombo));
>  
>   exit:
> +	usb_mark_last_busy(wacom->usbdev);
>  	retval = usb_submit_urb (urb, GFP_ATOMIC);
>  	if (retval)
>  		err ("%s - usb_submit_urb failed with result %d",
> @@ -124,10 +125,22 @@ static int wacom_open(struct input_dev *
>  {
>  	struct wacom *wacom = input_get_drvdata(dev);
>  
> +	mutex_lock(&wacom->lock);
>  	wacom->irq->dev = wacom->usbdev;
> -	if (usb_submit_urb(wacom->irq, GFP_KERNEL))
> +
> +	if (usb_autopm_get_interface(wacom->intf) < 0) {
> +		mutex_unlock(&wacom->lock);
> +		return -EIO;
> +	}
> +	if (usb_submit_urb(wacom->irq, GFP_KERNEL)) {
> +		usb_autopm_put_interface(wacom->intf);
> +		mutex_unlock(&wacom->lock);
>  		return -EIO;
> +	}
> +	wacom->open = 1;
> +	wacom->intf->needs_remote_wakeup = 1;
>  
> +	mutex_unlock(&wacom->lock);
>  	return 0;
>  }
>  
> @@ -135,7 +148,11 @@ static void wacom_close(struct input_dev
>  {
>  	struct wacom *wacom = input_get_drvdata(dev);
>  
> +	mutex_lock(&wacom->lock);
>  	usb_kill_urb(wacom->irq);
> +	wacom->open = 0;
> +	wacom->intf->needs_remote_wakeup = 0;
> +	mutex_unlock(&wacom->lock);
>  }
>  
>  void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
> @@ -243,6 +260,8 @@ static int wacom_probe(struct usb_interf
>  
>  	wacom->usbdev = dev;
>  	wacom->dev = input_dev;
> +	wacom->intf = intf;
> +	mutex_init(&wacom->lock);
>  	usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
>  	strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
>  
> @@ -307,20 +326,54 @@ static void wacom_disconnect(struct usb_
>  	struct wacom *wacom = usb_get_intfdata (intf);
>  
>  	usb_set_intfdata(intf, NULL);
> -	if (wacom) {
> -		usb_kill_urb(wacom->irq);
> -		input_unregister_device(wacom->dev);
> -		usb_free_urb(wacom->irq);
> -		usb_buffer_free(interface_to_usbdev(intf), 10, wacom->wacom_wac->data, wacom->data_dma);
> -		kfree(wacom->wacom_wac);
> -		kfree(wacom);
> -	}
> +
> +	usb_kill_urb(wacom->irq);
> +	input_unregister_device(wacom->dev);
> +	usb_free_urb(wacom->irq);
> +	usb_buffer_free(interface_to_usbdev(intf), 10, wacom->wacom_wac->data, wacom->data_dma);
> +	kfree(wacom->wacom_wac);
> +	kfree(wacom);
> +}
> +
> +static int wacom_suspend(struct usb_interface *intf, pm_message_t message)
> +{
> +	struct wacom *wacom = usb_get_intfdata (intf);
> +
> +	mutex_lock(&wacom->lock);
> +	usb_kill_urb(wacom->irq);
> +	mutex_unlock(&wacom->lock);
> +
> +	return 0;
> +}
> +
> +static int wacom_resume(struct usb_interface *intf)
> +{
> +	struct wacom *wacom = usb_get_intfdata (intf);
> +	int rv;
> +
> +	mutex_lock(&wacom->lock);
> +	if (wacom->open)
> +		rv = usb_submit_urb(wacom->irq, GFP_NOIO);
> +	else
> +		rv = 0;
> +	mutex_unlock(&wacom->lock);
> +
> +	return rv;
> +}
> +
> +static int wacom_reset_resume(struct usb_interface *intf)
> +{
> +	return wacom_resume(intf);
>  }
>  
>  static struct usb_driver wacom_driver = {
>  	.name =		"wacom",
>  	.probe =	wacom_probe,
>  	.disconnect =	wacom_disconnect,
> +	.suspend =	wacom_suspend,
> +	.resume =	wacom_resume,
> +	.reset_resume =	wacom_reset_resume,
> +	.supports_autosuspend = 1,
>  };
>  
>  static int __init wacom_init(void)
> --- linux-2.6.25-rc7-vanilla/drivers/input/tablet/wacom.h	2008-03-31 15:20:58.000000000 +0200
> +++ linux-2.6.25-rc7-work/drivers/input/tablet/wacom.h	2008-04-11 13:19:50.000000000 +0200
> @@ -101,8 +101,11 @@ struct wacom {
>  	dma_addr_t data_dma;
>  	struct input_dev *dev;
>  	struct usb_device *usbdev;
> +	struct usb_interface *intf;
>  	struct urb *irq;
>  	struct wacom_wac * wacom_wac;
> +	struct mutex lock;
> +	int open:1;
>  	char phys[32];
>  };
>  

-- 
Dmitry
--
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

  parent reply	other threads:[~2008-04-11 13:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-11 13:20 [patch]suspend and autosuspend for wacom devices Oliver Neukum
     [not found] ` <200804111520.57418.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-04-11 13:47   ` Dmitry Torokhov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-04-11 14:58 Oliver Neukum
2008-04-13 18:04 ` Ping Cheng

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=20080411094018.ZZRA012@mailhub.coreip.homeip.net \
    --to=dmitry.torokhov-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=jkosina-AlSwsSmVLrQ@public.gmane.org \
    --cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org \
    --cc=pingc-JeGq9vS6aD4AvxtiuMwx3w@public.gmane.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;
as well as URLs for NNTP newsgroup(s).