Re: [RFC v2 4/7] HID: i2c-hid: Move i2c_hid_finish_hwreset() to after reading the report-descriptor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, Nov 20, 2023 at 11:33 AM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
>
> @@ -741,12 +741,9 @@ static int i2c_hid_parse(struct hid_device *hid)
>                 return -EINVAL;
>         }
>
> +       mutex_lock(&ihid->reset_lock);
>         do {
> -               mutex_lock(&ihid->reset_lock);
>                 ret = i2c_hid_start_hwreset(ihid);
> -               if (ret == 0)
> -                       ret = i2c_hid_finish_hwreset(ihid);
> -               mutex_unlock(&ihid->reset_lock);
>                 if (ret)
>                         msleep(1000);
>         } while (tries-- > 0 && ret);

Right after this loop, you have:

if (ret)
  return ret;

That will return with the mutex held. It needs to be a "goto
abort_reset". You'd also need to init `use_override` then, I think.

I'll also note that it seems awkward that
`clear_bit(I2C_HID_RESET_PENDING, &ihid->flags)` is scattered in so
many places for error handling, but I couldn't really find a better
way to do it. :-P

-Doug





[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux