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

Re: [MiNT] [PATCH] Fix USB devices connected handling



2014-02-18 13:16 GMT+01:00 David Gálvez <dgalvez75@gmail.com>:
> 2014-02-18 12:57 GMT+01:00 Alan Hourihane <alanh@fairlite.co.uk>:
>> On 02/18/14 11:29, David Gálvez wrote:
>>
>> Hi David,
>>
>> Thanks for spotting the second part. But the first fix can't be right.
>>
>> When the devnum is allocated it's always +1, so the dev_index-- has to be
>> decremented to get to the correct structure to zero out.
>>
>> Am I missing something ?
>>
>
> Yes :-)
>
> This device index decrement was there for the static dev_index
> variable that you removed. Now it's decrementing the device index
> number (dev->devnum) in the USB device struct that is passed to the
> usb_free_device() function, now when an initialization fails and this
> function is called the data for the USB device previously installed is
> cleared, the root hub for example when the first USB device plugged
> fails.
>

Something it's wrong but my explanation above doesn't describe the
problem right.
In the fuction usb_hub_port_connect_change() the usb_free_device() is
called with the devnum from the parent not from the new device.
We should may be leave the decrement in usb_free_device() and use the
parameter usb->devnum instead dev->devnum when calling the function.