# Re: \[PATCH 2/2\] ati\_remote2: Add autosuspend support

- From: Oliver Neukum \<oliver@neukum.org\>
- Date: 2008-06-03 20:10:59 
- List: linux-input
- Page: https://ratatoskr.run/linux-input/2008/06/8909874
- Thread: https://ratatoskr.run/linux-input/2008/06/8909872/t.md

```text
Am Dienstag 03 Juni 2008 20:45:47 schrieb Ville Syrjala:
> +static int ati_remote2_open(struct input_dev *idev)
> +{
> +       struct ati_remote2 *ar2 = input_get_drvdata(idev);
> +       int r;
> +
> +       dev_dbg(&ar2->intf[0]->dev, "%s()\n", __FUNCTION__);
> +
> +       r = usb_autopm_get_interface(ar2->intf[0]);
> +       if (r) {
> +               dev_err(&ar2->intf[0]->dev,
> +                       "%s(): usb_autopm_get_interface() = %d\n", __FUNCTION__, r);
> +               goto fail1;
> +       }
> +       r = usb_autopm_get_interface(ar2->intf[1]);
> +       if (r) {
> +               dev_err(&ar2->intf[1]->dev,
> +                       "%s(): usb_autopm_get_interface() = %d\n", __FUNCTION__, r);
> +               goto fail2;
> +       }

If you have two interfaces on one device upping the count for one of them
is enough.

> +
> +       mutex_lock(&ati_remote2_mutex);

Too late. You can race with disconnect()

And you should set needs_remote_wakeup.

	Regards
		Oliver
```
