diff mbox series

[v5,04/10] usb: common: add define of usb_speed_string()

Message ID 1597650063-9313-5-git-send-email-chunfeng.yun@mediatek.com
State Superseded
Delegated to: Marek Vasut
Headers show
Series Add support MediaTek USB3 DRD driver | expand

Commit Message

Chunfeng Yun (云春峰) Aug. 17, 2020, 7:40 a.m. UTC
There is only declear of usb_speed_string(), but not define it.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v5: no changes

v4: new patch
---
 drivers/usb/common/common.c | 7 +++++++
 include/linux/usb/ch9.h     | 4 ----
 2 files changed, 7 insertions(+), 4 deletions(-)

Comments

Roger Quadros Aug. 17, 2020, 7:51 a.m. UTC | #1
Hi,

On 17/08/2020 10:40, Chunfeng Yun wrote:
> There is only declear of usb_speed_string(), but not define it.

s/declear/declaration

s/not define/no definition of/

> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> v5: no changes
> 
> v4: new patch
> ---
>   drivers/usb/common/common.c | 7 +++++++
>   include/linux/usb/ch9.h     | 4 ----
>   2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> index 76f5a9c..5e5c3c3 100644
> --- a/drivers/usb/common/common.c
> +++ b/drivers/usb/common/common.c
> @@ -49,6 +49,13 @@ static const char *const speed_names[] = {
>   	[USB_SPEED_SUPER_PLUS] = "super-speed-plus",
>   };
>   
> +const char *usb_speed_string(enum usb_device_speed speed)
> +{
> +	if (speed < 0 || speed >= ARRAY_SIZE(speed_names))
> +		speed = USB_SPEED_UNKNOWN;
> +	return speed_names[speed];
> +}
> +

But I see it already defined here

https://elixir.bootlin.com/linux/latest/source/drivers/usb/common/common.c#L72

>   enum usb_device_speed usb_get_maximum_speed(ofnode node)
>   {
>   	const char *max_speed;
> diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
> index 7d225ee..a8fa5d7 100644
> --- a/include/linux/usb/ch9.h
> +++ b/include/linux/usb/ch9.h
> @@ -959,8 +959,6 @@ enum usb_device_speed {
>   	USB_SPEED_SUPER_PLUS,			/* usb 3.1 */
>   };
>   
> -#ifdef __KERNEL__
> -

Why do you have to remove this?
>   /**
>    * usb_speed_string() - Returns human readable-name of the speed.
>    * @speed: The speed to return human-readable name for.  If it's not
> @@ -969,8 +967,6 @@ enum usb_device_speed {
>    */
>   extern const char *usb_speed_string(enum usb_device_speed speed);
>   
> -#endif
> -
>   enum usb_device_state {
>   	/* NOTATTACHED isn't in the USB spec, and this state acts
>   	 * the same as ATTACHED ... but it's clearer this way.
> 

cheers,
-roger
Roger Quadros Aug. 17, 2020, 7:54 a.m. UTC | #2
On 17/08/2020 10:51, Roger Quadros wrote:
> Hi,
> 
> On 17/08/2020 10:40, Chunfeng Yun wrote:
>> There is only declear of usb_speed_string(), but not define it.
> 
> s/declear/declaration
> 
> s/not define/no definition of/
> 
>>
>> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
>> ---
>> v5: no changes
>>
>> v4: new patch
>> ---
>>   drivers/usb/common/common.c | 7 +++++++
>>   include/linux/usb/ch9.h     | 4 ----
>>   2 files changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
>> index 76f5a9c..5e5c3c3 100644
>> --- a/drivers/usb/common/common.c
>> +++ b/drivers/usb/common/common.c
>> @@ -49,6 +49,13 @@ static const char *const speed_names[] = {
>>       [USB_SPEED_SUPER_PLUS] = "super-speed-plus",
>>   };
>> +const char *usb_speed_string(enum usb_device_speed speed)
>> +{
>> +    if (speed < 0 || speed >= ARRAY_SIZE(speed_names))
>> +        speed = USB_SPEED_UNKNOWN;
>> +    return speed_names[speed];
>> +}
>> +
> 
> But I see it already defined here
> 
> https://elixir.bootlin.com/linux/latest/source/drivers/usb/common/common.c#L72

Sorry, I didn't realize this is for u-boot :)

cheers,
-roger

> 
>>   enum usb_device_speed usb_get_maximum_speed(ofnode node)
>>   {
>>       const char *max_speed;
>> diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
>> index 7d225ee..a8fa5d7 100644
>> --- a/include/linux/usb/ch9.h
>> +++ b/include/linux/usb/ch9.h
>> @@ -959,8 +959,6 @@ enum usb_device_speed {
>>       USB_SPEED_SUPER_PLUS,            /* usb 3.1 */
>>   };
>> -#ifdef __KERNEL__
>> -
> 
> Why do you have to remove this?
>>   /**
>>    * usb_speed_string() - Returns human readable-name of the speed.
>>    * @speed: The speed to return human-readable name for.  If it's not
>> @@ -969,8 +967,6 @@ enum usb_device_speed {
>>    */
>>   extern const char *usb_speed_string(enum usb_device_speed speed);
>> -#endif
>> -
>>   enum usb_device_state {
>>       /* NOTATTACHED isn't in the USB spec, and this state acts
>>        * the same as ATTACHED ... but it's clearer this way.
>>
> 
> cheers,
> -roger
Chunfeng Yun (云春峰) Aug. 18, 2020, 1:42 a.m. UTC | #3
On Mon, 2020-08-17 at 10:54 +0300, Roger Quadros wrote:
> 
> On 17/08/2020 10:51, Roger Quadros wrote:
> > Hi,
> > 
> > On 17/08/2020 10:40, Chunfeng Yun wrote:
> >> There is only declear of usb_speed_string(), but not define it.
> > 
> > s/declear/declaration
> > 
> > s/not define/no definition of/
Ok, will modify it, thanks

> > 
> >>
> >> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> >> ---
> >> v5: no changes
> >>
> >> v4: new patch
> >> ---
> >>   drivers/usb/common/common.c | 7 +++++++
> >>   include/linux/usb/ch9.h     | 4 ----
> >>   2 files changed, 7 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> >> index 76f5a9c..5e5c3c3 100644
> >> --- a/drivers/usb/common/common.c
> >> +++ b/drivers/usb/common/common.c
> >> @@ -49,6 +49,13 @@ static const char *const speed_names[] = {
> >>       [USB_SPEED_SUPER_PLUS] = "super-speed-plus",
> >>   };
> >> +const char *usb_speed_string(enum usb_device_speed speed)
> >> +{
> >> +    if (speed < 0 || speed >= ARRAY_SIZE(speed_names))
> >> +        speed = USB_SPEED_UNKNOWN;
> >> +    return speed_names[speed];
> >> +}
> >> +
> > 
> > But I see it already defined here
> > 
> > https://elixir.bootlin.com/linux/latest/source/drivers/usb/common/common.c#L72
> 
> Sorry, I didn't realize this is for u-boot :)
> 
> cheers,
> -roger
> 
> > 
> >>   enum usb_device_speed usb_get_maximum_speed(ofnode node)
> >>   {
> >>       const char *max_speed;
> >> diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
> >> index 7d225ee..a8fa5d7 100644
> >> --- a/include/linux/usb/ch9.h
> >> +++ b/include/linux/usb/ch9.h
> >> @@ -959,8 +959,6 @@ enum usb_device_speed {
> >>       USB_SPEED_SUPER_PLUS,            /* usb 3.1 */
> >>   };
> >> -#ifdef __KERNEL__
> >> -
> > 
> > Why do you have to remove this?
> >>   /**
> >>    * usb_speed_string() - Returns human readable-name of the speed.
> >>    * @speed: The speed to return human-readable name for.  If it's not
> >> @@ -969,8 +967,6 @@ enum usb_device_speed {
> >>    */
> >>   extern const char *usb_speed_string(enum usb_device_speed speed);
> >> -#endif
> >> -
> >>   enum usb_device_state {
> >>       /* NOTATTACHED isn't in the USB spec, and this state acts
> >>        * the same as ATTACHED ... but it's clearer this way.
> >>
> > 
> > cheers,
> > -roger
>
diff mbox series

Patch

diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index 76f5a9c..5e5c3c3 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -49,6 +49,13 @@  static const char *const speed_names[] = {
 	[USB_SPEED_SUPER_PLUS] = "super-speed-plus",
 };
 
+const char *usb_speed_string(enum usb_device_speed speed)
+{
+	if (speed < 0 || speed >= ARRAY_SIZE(speed_names))
+		speed = USB_SPEED_UNKNOWN;
+	return speed_names[speed];
+}
+
 enum usb_device_speed usb_get_maximum_speed(ofnode node)
 {
 	const char *max_speed;
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index 7d225ee..a8fa5d7 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -959,8 +959,6 @@  enum usb_device_speed {
 	USB_SPEED_SUPER_PLUS,			/* usb 3.1 */
 };
 
-#ifdef __KERNEL__
-
 /**
  * usb_speed_string() - Returns human readable-name of the speed.
  * @speed: The speed to return human-readable name for.  If it's not
@@ -969,8 +967,6 @@  enum usb_device_speed {
  */
 extern const char *usb_speed_string(enum usb_device_speed speed);
 
-#endif
-
 enum usb_device_state {
 	/* NOTATTACHED isn't in the USB spec, and this state acts
 	 * the same as ATTACHED ... but it's clearer this way.