Re: [PATCH 1/2] usb: dwc3: adapt to use dr_mode device tree helper

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

 



On 07/10/2013 04:35 PM, Felipe Balbi wrote:
> Hi,
> 
> On Wed, Jul 10, 2013 at 04:11:52PM +0300, Roger Quadros wrote:
>> On 07/10/2013 02:42 PM, Felipe Balbi wrote:
>>> On Tue, Jul 09, 2013 at 02:16:32PM +0300, Roger Quadros wrote:
>>>> Hi,
>>>>
>>>> On 07/06/2013 03:52 PM, Ruchika Kharwar wrote:
>>>>> This patch adapts the dwc3 to use the device tree helper
>>>>> "of_usb_get_dr_mode" for the mode of operation of the dwc3 instance
>>>>> being probed.
>>>>>
>>>>> Signed-off-by: Ruchika Kharwar <ruchika@xxxxxx>
>>>>> ---
>>>>>  drivers/usb/dwc3/core.c |   51 +++++++++++++++++++++++++----------------------
>>>>>  drivers/usb/dwc3/core.h |    5 -----
>>>>>  2 files changed, 27 insertions(+), 29 deletions(-)
>>>>>
>>>>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>>>>> index c35d49d..7b98e4f 100644
>>>>> --- a/drivers/usb/dwc3/core.c
>>>>> +++ b/drivers/usb/dwc3/core.c
>>>>> @@ -517,14 +517,17 @@ static int dwc3_probe(struct platform_device *pdev)
>>>>>  	}
>>>>>  
>>>>>  	if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
>>>>> -		mode = DWC3_MODE_HOST;
>>>>> +		mode = USB_DR_MODE_HOST;
>>>>>  	else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
>>>>> -		mode = DWC3_MODE_DEVICE;
>>>>> +		mode = USB_DR_MODE_PERIPHERAL;
>>>>>  	else
>>>>> -		mode = DWC3_MODE_DRD;
>>>>> +		mode = of_usb_get_dr_mode(node);
>>>>
>>>> You need to check if "node" is not NULL before using
>>>> of_usb_get_dr_mode.
>>>>
>>>> Also what would happen if DT passes a mode which can't be supported
>>>> due to missing device driver? e.g. DT passes mode = "host" whereas
>>>> HOST is not enabled.
>>>
>>> hmm... look closely, she's already handling that, right ? If DWC3
>>> Host-only, then mode is hardcoded to host, if DWC3 is Gadget-only, then
>>> mode is hardcoded to peripheral and if DWC3 is DRD, then she checks
>>> DeviceTree.
>>>
>>
>> In the above example if DT passes mode = "host" but
>> CONFIG_USB_DWC3_GADGET is enabled in config, the dwc3 driver will work
>> in gadget only mode.
>> There is no warning/information to the user that it can't be enabled
>> in host mode.
>>
>> All I'm saying is that there must be some kind of indication about the
>> requested mode not being available because of a configuration issue.
> 
> oh, alright. But that's not part of $subject ;-)

Agreed. Warning the user can be a different patch.
> 
> So there are just two fixes which needs to be made to this patch:
> 
> 1) call of_usb_get_dr_mode() conditionally on dev->of_node
> 2) make sure platform_data can be used to pass the mode

perfect :)

cheers,
-roger
--
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