diff mbox series

[05/10] usb: dwc3-generic: Use dev_read_addr() instead of devfdt_get_addr()

Message ID 20200219015447.19392-6-kever.yang@rock-chips.com
State Superseded
Headers show
Series usb: Covert to support Live DT | expand

Commit Message

Kever Yang Feb. 19, 2020, 1:54 a.m. UTC
Use more common API so that we can support live DT.

Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
---

 drivers/usb/dwc3/dwc3-generic.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Marek Vasut Feb. 19, 2020, 5:07 p.m. UTC | #1
On 2/19/20 2:54 AM, Kever Yang wrote:
> Use more common API so that we can support live DT.
> 
> Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
> ---
> 
>  drivers/usb/dwc3/dwc3-generic.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index 820cc7075c..ced0f53bfd 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -88,17 +88,17 @@ static int dwc3_generic_remove(struct udevice *dev,
>  static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
>  {
>  	struct dwc3_generic_plat *plat = dev_get_platdata(dev);
> -	int node = dev_of_offset(dev);
> +	ofnode node = dev->node;

Can't you just do ofnode_of_offset() here, once , instead of having it
all over the function ?
Kever Yang Feb. 20, 2020, 1:51 a.m. UTC | #2
Hi Marek,

On 2020/2/20 ??1:07, Marek Vasut wrote:
> On 2/19/20 2:54 AM, Kever Yang wrote:
>> Use more common API so that we can support live DT.
>>
>> Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
>> ---
>>
>>   drivers/usb/dwc3/dwc3-generic.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
>> index 820cc7075c..ced0f53bfd 100644
>> --- a/drivers/usb/dwc3/dwc3-generic.c
>> +++ b/drivers/usb/dwc3/dwc3-generic.c
>> @@ -88,17 +88,17 @@ static int dwc3_generic_remove(struct udevice *dev,
>>   static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
>>   {
>>   	struct dwc3_generic_plat *plat = dev_get_platdata(dev);
>> -	int node = dev_of_offset(dev);
>> +	ofnode node = dev->node;
> Can't you just do ofnode_of_offset() here, once , instead of having it
> all over the function ?


The "all over the function" is only twice, and this convert will removed 
at follow up patch which

update the function parameter from offset to ofnode.

So I think this change is acceptable for this patch.


Thanks,

- Kever
Simon Glass Feb. 20, 2020, 2:23 a.m. UTC | #3
Hi Kever,

On Tue, 18 Feb 2020 at 18:55, Kever Yang <kever.yang at rock-chips.com> wrote:
>
> Use more common API so that we can support live DT.
>
> Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
> ---
>
>  drivers/usb/dwc3/dwc3-generic.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index 820cc7075c..ced0f53bfd 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -88,17 +88,17 @@ static int dwc3_generic_remove(struct udevice *dev,
>  static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
>  {
>         struct dwc3_generic_plat *plat = dev_get_platdata(dev);
> -       int node = dev_of_offset(dev);
> +       ofnode node = dev->node;
>
> -       plat->base = devfdt_get_addr(dev);
> +       plat->base = dev_read_addr(dev);
>
> -       plat->maximum_speed = usb_get_maximum_speed(node);
> +       plat->maximum_speed = usb_get_maximum_speed(ofnode_to_offset(node));
>         if (plat->maximum_speed == USB_SPEED_UNKNOWN) {
>                 pr_info("No USB maximum speed specified. Using super speed\n");
>                 plat->maximum_speed = USB_SPEED_SUPER;
>         }
>
> -       plat->dr_mode = usb_get_dr_mode(node);
> +       plat->dr_mode = usb_get_dr_mode(ofnode_to_offset(node));

This won't work with livetree. Can you convert usb_get_dr_mode() to
use livetree? Then you can pass the dev or the node.

>         if (plat->dr_mode == USB_DR_MODE_UNKNOWN) {
>                 pr_err("Invalid usb mode setup\n");
>                 return -ENODEV;
> --
> 2.17.1
>

Regards,
Simon
Kever Yang Feb. 27, 2020, 7:33 a.m. UTC | #4
Hi Simon,

On 2020/2/20 ??10:23, Simon Glass wrote:
> Hi Kever,
>
> On Tue, 18 Feb 2020 at 18:55, Kever Yang <kever.yang at rock-chips.com> wrote:
>> Use more common API so that we can support live DT.
>>
>> Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
>> ---
>>
>>   drivers/usb/dwc3/dwc3-generic.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
>> index 820cc7075c..ced0f53bfd 100644
>> --- a/drivers/usb/dwc3/dwc3-generic.c
>> +++ b/drivers/usb/dwc3/dwc3-generic.c
>> @@ -88,17 +88,17 @@ static int dwc3_generic_remove(struct udevice *dev,
>>   static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
>>   {
>>          struct dwc3_generic_plat *plat = dev_get_platdata(dev);
>> -       int node = dev_of_offset(dev);
>> +       ofnode node = dev->node;
>>
>> -       plat->base = devfdt_get_addr(dev);
>> +       plat->base = dev_read_addr(dev);
>>
>> -       plat->maximum_speed = usb_get_maximum_speed(node);
>> +       plat->maximum_speed = usb_get_maximum_speed(ofnode_to_offset(node));
>>          if (plat->maximum_speed == USB_SPEED_UNKNOWN) {
>>                  pr_info("No USB maximum speed specified. Using super speed\n");
>>                  plat->maximum_speed = USB_SPEED_SUPER;
>>          }
>>
>> -       plat->dr_mode = usb_get_dr_mode(node);
>> +       plat->dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
> This won't work with livetree. Can you convert usb_get_dr_mode() to
> use livetree? Then you can pass the dev or the node.


I do convert usb_get_dr_mode() to use livetree at 9/10 of this patch set.

I have to clean all the related code first, and then convert 
usb_get_dr_mode() and

usb_get_maximum_speed() to livetree one by one. If the convert happen first,

I have to merge the 3rd~10th patches into one patch and not so good for 
review.


Thanks,

- Kever

>
>>          if (plat->dr_mode == USB_DR_MODE_UNKNOWN) {
>>                  pr_err("Invalid usb mode setup\n");
>>                  return -ENODEV;
>> --
>> 2.17.1
>>
> Regards,
> Simon
>
>
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 820cc7075c..ced0f53bfd 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -88,17 +88,17 @@  static int dwc3_generic_remove(struct udevice *dev,
 static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
 {
 	struct dwc3_generic_plat *plat = dev_get_platdata(dev);
-	int node = dev_of_offset(dev);
+	ofnode node = dev->node;
 
-	plat->base = devfdt_get_addr(dev);
+	plat->base = dev_read_addr(dev);
 
-	plat->maximum_speed = usb_get_maximum_speed(node);
+	plat->maximum_speed = usb_get_maximum_speed(ofnode_to_offset(node));
 	if (plat->maximum_speed == USB_SPEED_UNKNOWN) {
 		pr_info("No USB maximum speed specified. Using super speed\n");
 		plat->maximum_speed = USB_SPEED_SUPER;
 	}
 
-	plat->dr_mode = usb_get_dr_mode(node);
+	plat->dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
 	if (plat->dr_mode == USB_DR_MODE_UNKNOWN) {
 		pr_err("Invalid usb mode setup\n");
 		return -ENODEV;