Re: [PATCH v5 3/3] usb: otg: utils: devres: Add API's to associate a device with the phy

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

 



Hi Chen,

On Wed, Jun 13, 2012 at 11:27 AM, Chen Peter-B29397
<B29397@xxxxxxxxxxxxx> wrote:
>
>
>
>>
>> Used devres API's to associate the phy with a device so that on
>> driver detach, release function is invoked on the devres data(usb_phy)
>> and devres data(usb_phy) is released.
>>
> Sorry, I not understand, you would like to say the usb_phy will be released
> on its user's detach routine automatically?

Yes. It's similar to any devres API already existing in the kernel.
You can have a look at *[PATCH 4/5] usb: musb: omap: use devres API to
allocate resources*
on how I intend to use this API.
You can also have a look at Documentation/driver-model/devres.txt to
know about devres API.

>
>
>>
>> @@ -34,6 +35,48 @@ static struct usb_phy *__usb_find_phy(struct list_head
>> *list,
>>       return ERR_PTR(-ENODEV);
>>  }
>>
>> +static void devm_usb_phy_release(struct device *dev, void *res)
>> +{
>> +     struct usb_phy *phy = *(struct usb_phy **)res;
>> +
>> +     usb_put_phy(phy);
>> +}
>> +
>> +static int devm_usb_phy_match(struct device *dev, void *res, void
>> *match_data)
>> +{
>> +     return res == match_data;
>> +}
>> +
>> +/**
>> + * devm_usb_get_phy - find the USB PHY
>> + * @dev - device that requests this phy
>> + * @type - the type of the phy the controller requires
>> + *
>> + * Gets the phy using usb_get_phy(), and associates a device with it
>> using
>> + * devres. On driver detach, release function is invoked on the devres
>> data,
>> + * then, devres data is freed.
>> + *
>> + * For use by USB host and peripheral drivers.
>> + */
> It may not be used by host and peripheral driver only, other drivers(otg?)
> like handing id interrupt may also use it.

I think I have to fix the comment then.

Thanks
Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux