* [PATCH 1/2] usb: roles: add helper usb_role_string()
@ 2021-05-25 8:53 ` Chunfeng Yun
0 siblings, 0 replies; 9+ messages in thread
From: Chunfeng Yun @ 2021-05-25 8:53 UTC (permalink / raw)
To: Greg Kroah-Hartman, Heikki Krogerus
Cc: Matthias Brugger, Chunfeng Yun, Thierry Reding, Paul Cercueil,
Lee Jones, Guenter Roeck, Hans de Goede, linux-usb, linux-kernel,
linux-arm-kernel, linux-mediatek
Introduces usb_role_string() function, which returns a
human-readable name of provided usb role, it's useful to
make the log readable.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
drivers/usb/roles/class.c | 9 +++++++++
include/linux/usb/role.h | 6 ++++++
2 files changed, 15 insertions(+)
diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index 33b637d0d8d9..dfaed7eee94f 100644
--- a/drivers/usb/roles/class.c
+++ b/drivers/usb/roles/class.c
@@ -214,6 +214,15 @@ static const char * const usb_roles[] = {
[USB_ROLE_DEVICE] = "device",
};
+const char *usb_role_string(enum usb_role role)
+{
+ if (role < 0 || role >= ARRAY_SIZE(usb_roles))
+ return "unknown";
+
+ return usb_roles[role];
+}
+EXPORT_SYMBOL_GPL(usb_role_string);
+
static ssize_t
role_show(struct device *dev, struct device_attribute *attr, char *buf)
{
diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h
index 0164fed31b06..031f148ab373 100644
--- a/include/linux/usb/role.h
+++ b/include/linux/usb/role.h
@@ -65,6 +65,7 @@ void usb_role_switch_unregister(struct usb_role_switch *sw);
void usb_role_switch_set_drvdata(struct usb_role_switch *sw, void *data);
void *usb_role_switch_get_drvdata(struct usb_role_switch *sw);
+const char *usb_role_string(enum usb_role role);
#else
static inline int usb_role_switch_set_role(struct usb_role_switch *sw,
enum usb_role role)
@@ -109,6 +110,11 @@ static inline void *usb_role_switch_get_drvdata(struct usb_role_switch *sw)
return NULL;
}
+static inline const char *usb_role_string(enum usb_role role)
+{
+ return "unknown";
+}
+
#endif
#endif /* __LINUX_USB_ROLE_H */
--
2.18.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 1/2] usb: roles: add helper usb_role_string()
@ 2021-05-25 8:53 ` Chunfeng Yun
0 siblings, 0 replies; 9+ messages in thread
From: Chunfeng Yun @ 2021-05-25 8:53 UTC (permalink / raw)
To: Greg Kroah-Hartman, Heikki Krogerus
Cc: Matthias Brugger, Chunfeng Yun, Thierry Reding, Paul Cercueil,
Lee Jones, Guenter Roeck, Hans de Goede, linux-usb, linux-kernel,
linux-arm-kernel, linux-mediatek
Introduces usb_role_string() function, which returns a
human-readable name of provided usb role, it's useful to
make the log readable.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
drivers/usb/roles/class.c | 9 +++++++++
include/linux/usb/role.h | 6 ++++++
2 files changed, 15 insertions(+)
diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index 33b637d0d8d9..dfaed7eee94f 100644
--- a/drivers/usb/roles/class.c
+++ b/drivers/usb/roles/class.c
@@ -214,6 +214,15 @@ static const char * const usb_roles[] = {
[USB_ROLE_DEVICE] = "device",
};
+const char *usb_role_string(enum usb_role role)
+{
+ if (role < 0 || role >= ARRAY_SIZE(usb_roles))
+ return "unknown";
+
+ return usb_roles[role];
+}
+EXPORT_SYMBOL_GPL(usb_role_string);
+
static ssize_t
role_show(struct device *dev, struct device_attribute *attr, char *buf)
{
diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h
index 0164fed31b06..031f148ab373 100644
--- a/include/linux/usb/role.h
+++ b/include/linux/usb/role.h
@@ -65,6 +65,7 @@ void usb_role_switch_unregister(struct usb_role_switch *sw);
void usb_role_switch_set_drvdata(struct usb_role_switch *sw, void *data);
void *usb_role_switch_get_drvdata(struct usb_role_switch *sw);
+const char *usb_role_string(enum usb_role role);
#else
static inline int usb_role_switch_set_role(struct usb_role_switch *sw,
enum usb_role role)
@@ -109,6 +110,11 @@ static inline void *usb_role_switch_get_drvdata(struct usb_role_switch *sw)
return NULL;
}
+static inline const char *usb_role_string(enum usb_role role)
+{
+ return "unknown";
+}
+
#endif
#endif /* __LINUX_USB_ROLE_H */
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 1/2] usb: roles: add helper usb_role_string()
@ 2021-05-25 8:53 ` Chunfeng Yun
0 siblings, 0 replies; 9+ messages in thread
From: Chunfeng Yun @ 2021-05-25 8:53 UTC (permalink / raw)
To: Greg Kroah-Hartman, Heikki Krogerus
Cc: Matthias Brugger, Chunfeng Yun, Thierry Reding, Paul Cercueil,
Lee Jones, Guenter Roeck, Hans de Goede, linux-usb, linux-kernel,
linux-arm-kernel, linux-mediatek
Introduces usb_role_string() function, which returns a
human-readable name of provided usb role, it's useful to
make the log readable.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
drivers/usb/roles/class.c | 9 +++++++++
include/linux/usb/role.h | 6 ++++++
2 files changed, 15 insertions(+)
diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index 33b637d0d8d9..dfaed7eee94f 100644
--- a/drivers/usb/roles/class.c
+++ b/drivers/usb/roles/class.c
@@ -214,6 +214,15 @@ static const char * const usb_roles[] = {
[USB_ROLE_DEVICE] = "device",
};
+const char *usb_role_string(enum usb_role role)
+{
+ if (role < 0 || role >= ARRAY_SIZE(usb_roles))
+ return "unknown";
+
+ return usb_roles[role];
+}
+EXPORT_SYMBOL_GPL(usb_role_string);
+
static ssize_t
role_show(struct device *dev, struct device_attribute *attr, char *buf)
{
diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h
index 0164fed31b06..031f148ab373 100644
--- a/include/linux/usb/role.h
+++ b/include/linux/usb/role.h
@@ -65,6 +65,7 @@ void usb_role_switch_unregister(struct usb_role_switch *sw);
void usb_role_switch_set_drvdata(struct usb_role_switch *sw, void *data);
void *usb_role_switch_get_drvdata(struct usb_role_switch *sw);
+const char *usb_role_string(enum usb_role role);
#else
static inline int usb_role_switch_set_role(struct usb_role_switch *sw,
enum usb_role role)
@@ -109,6 +110,11 @@ static inline void *usb_role_switch_get_drvdata(struct usb_role_switch *sw)
return NULL;
}
+static inline const char *usb_role_string(enum usb_role role)
+{
+ return "unknown";
+}
+
#endif
#endif /* __LINUX_USB_ROLE_H */
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] usb: common: usb-conn-gpio: use usb_role_string() to print role status
2021-05-25 8:53 ` Chunfeng Yun
(?)
@ 2021-05-25 8:53 ` Chunfeng Yun
-1 siblings, 0 replies; 9+ messages in thread
From: Chunfeng Yun @ 2021-05-25 8:53 UTC (permalink / raw)
To: Greg Kroah-Hartman, Heikki Krogerus
Cc: Matthias Brugger, Chunfeng Yun, Thierry Reding, Paul Cercueil,
Lee Jones, Guenter Roeck, Hans de Goede, linux-usb, linux-kernel,
linux-arm-kernel, linux-mediatek
Use usb_role_string() to print role status, make the log readable.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
drivers/usb/common/usb-conn-gpio.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c
index 65d89140cd19..7dbe8baed029 100644
--- a/drivers/usb/common/usb-conn-gpio.c
+++ b/drivers/usb/common/usb-conn-gpio.c
@@ -83,11 +83,11 @@ static void usb_conn_detect_cable(struct work_struct *work)
else
role = USB_ROLE_NONE;
- dev_dbg(info->dev, "role %d/%d, gpios: id %d, vbus %d\n",
- info->last_role, role, id, vbus);
+ dev_dbg(info->dev, "role %s -> %s, gpios: id %d, vbus %d\n",
+ usb_role_string(info->last_role), usb_role_string(role), id, vbus);
if (info->last_role == role) {
- dev_warn(info->dev, "repeated role: %d\n", role);
+ dev_warn(info->dev, "repeated role: %s\n", usb_role_string(role));
return;
}
--
2.18.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] usb: common: usb-conn-gpio: use usb_role_string() to print role status
@ 2021-05-25 8:53 ` Chunfeng Yun
0 siblings, 0 replies; 9+ messages in thread
From: Chunfeng Yun @ 2021-05-25 8:53 UTC (permalink / raw)
To: Greg Kroah-Hartman, Heikki Krogerus
Cc: Matthias Brugger, Chunfeng Yun, Thierry Reding, Paul Cercueil,
Lee Jones, Guenter Roeck, Hans de Goede, linux-usb, linux-kernel,
linux-arm-kernel, linux-mediatek
Use usb_role_string() to print role status, make the log readable.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
drivers/usb/common/usb-conn-gpio.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c
index 65d89140cd19..7dbe8baed029 100644
--- a/drivers/usb/common/usb-conn-gpio.c
+++ b/drivers/usb/common/usb-conn-gpio.c
@@ -83,11 +83,11 @@ static void usb_conn_detect_cable(struct work_struct *work)
else
role = USB_ROLE_NONE;
- dev_dbg(info->dev, "role %d/%d, gpios: id %d, vbus %d\n",
- info->last_role, role, id, vbus);
+ dev_dbg(info->dev, "role %s -> %s, gpios: id %d, vbus %d\n",
+ usb_role_string(info->last_role), usb_role_string(role), id, vbus);
if (info->last_role == role) {
- dev_warn(info->dev, "repeated role: %d\n", role);
+ dev_warn(info->dev, "repeated role: %s\n", usb_role_string(role));
return;
}
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] usb: common: usb-conn-gpio: use usb_role_string() to print role status
@ 2021-05-25 8:53 ` Chunfeng Yun
0 siblings, 0 replies; 9+ messages in thread
From: Chunfeng Yun @ 2021-05-25 8:53 UTC (permalink / raw)
To: Greg Kroah-Hartman, Heikki Krogerus
Cc: Matthias Brugger, Chunfeng Yun, Thierry Reding, Paul Cercueil,
Lee Jones, Guenter Roeck, Hans de Goede, linux-usb, linux-kernel,
linux-arm-kernel, linux-mediatek
Use usb_role_string() to print role status, make the log readable.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
drivers/usb/common/usb-conn-gpio.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c
index 65d89140cd19..7dbe8baed029 100644
--- a/drivers/usb/common/usb-conn-gpio.c
+++ b/drivers/usb/common/usb-conn-gpio.c
@@ -83,11 +83,11 @@ static void usb_conn_detect_cable(struct work_struct *work)
else
role = USB_ROLE_NONE;
- dev_dbg(info->dev, "role %d/%d, gpios: id %d, vbus %d\n",
- info->last_role, role, id, vbus);
+ dev_dbg(info->dev, "role %s -> %s, gpios: id %d, vbus %d\n",
+ usb_role_string(info->last_role), usb_role_string(role), id, vbus);
if (info->last_role == role) {
- dev_warn(info->dev, "repeated role: %d\n", role);
+ dev_warn(info->dev, "repeated role: %s\n", usb_role_string(role));
return;
}
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] usb: roles: add helper usb_role_string()
2021-05-25 8:53 ` Chunfeng Yun
(?)
@ 2021-05-26 6:31 ` Heikki Krogerus
-1 siblings, 0 replies; 9+ messages in thread
From: Heikki Krogerus @ 2021-05-26 6:31 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Greg Kroah-Hartman, Matthias Brugger, Thierry Reding,
Paul Cercueil, Lee Jones, Guenter Roeck, Hans de Goede,
linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
On Tue, May 25, 2021 at 04:53:05PM +0800, Chunfeng Yun wrote:
> Introduces usb_role_string() function, which returns a
> human-readable name of provided usb role, it's useful to
> make the log readable.
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/roles/class.c | 9 +++++++++
> include/linux/usb/role.h | 6 ++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
> index 33b637d0d8d9..dfaed7eee94f 100644
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -214,6 +214,15 @@ static const char * const usb_roles[] = {
> [USB_ROLE_DEVICE] = "device",
> };
>
> +const char *usb_role_string(enum usb_role role)
> +{
> + if (role < 0 || role >= ARRAY_SIZE(usb_roles))
> + return "unknown";
> +
> + return usb_roles[role];
> +}
> +EXPORT_SYMBOL_GPL(usb_role_string);
> +
> static ssize_t
> role_show(struct device *dev, struct device_attribute *attr, char *buf)
> {
> diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h
> index 0164fed31b06..031f148ab373 100644
> --- a/include/linux/usb/role.h
> +++ b/include/linux/usb/role.h
> @@ -65,6 +65,7 @@ void usb_role_switch_unregister(struct usb_role_switch *sw);
>
> void usb_role_switch_set_drvdata(struct usb_role_switch *sw, void *data);
> void *usb_role_switch_get_drvdata(struct usb_role_switch *sw);
> +const char *usb_role_string(enum usb_role role);
> #else
> static inline int usb_role_switch_set_role(struct usb_role_switch *sw,
> enum usb_role role)
> @@ -109,6 +110,11 @@ static inline void *usb_role_switch_get_drvdata(struct usb_role_switch *sw)
> return NULL;
> }
>
> +static inline const char *usb_role_string(enum usb_role role)
> +{
> + return "unknown";
> +}
> +
> #endif
>
> #endif /* __LINUX_USB_ROLE_H */
> --
> 2.18.0
--
heikki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] usb: roles: add helper usb_role_string()
@ 2021-05-26 6:31 ` Heikki Krogerus
0 siblings, 0 replies; 9+ messages in thread
From: Heikki Krogerus @ 2021-05-26 6:31 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Greg Kroah-Hartman, Matthias Brugger, Thierry Reding,
Paul Cercueil, Lee Jones, Guenter Roeck, Hans de Goede,
linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
On Tue, May 25, 2021 at 04:53:05PM +0800, Chunfeng Yun wrote:
> Introduces usb_role_string() function, which returns a
> human-readable name of provided usb role, it's useful to
> make the log readable.
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/roles/class.c | 9 +++++++++
> include/linux/usb/role.h | 6 ++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
> index 33b637d0d8d9..dfaed7eee94f 100644
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -214,6 +214,15 @@ static const char * const usb_roles[] = {
> [USB_ROLE_DEVICE] = "device",
> };
>
> +const char *usb_role_string(enum usb_role role)
> +{
> + if (role < 0 || role >= ARRAY_SIZE(usb_roles))
> + return "unknown";
> +
> + return usb_roles[role];
> +}
> +EXPORT_SYMBOL_GPL(usb_role_string);
> +
> static ssize_t
> role_show(struct device *dev, struct device_attribute *attr, char *buf)
> {
> diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h
> index 0164fed31b06..031f148ab373 100644
> --- a/include/linux/usb/role.h
> +++ b/include/linux/usb/role.h
> @@ -65,6 +65,7 @@ void usb_role_switch_unregister(struct usb_role_switch *sw);
>
> void usb_role_switch_set_drvdata(struct usb_role_switch *sw, void *data);
> void *usb_role_switch_get_drvdata(struct usb_role_switch *sw);
> +const char *usb_role_string(enum usb_role role);
> #else
> static inline int usb_role_switch_set_role(struct usb_role_switch *sw,
> enum usb_role role)
> @@ -109,6 +110,11 @@ static inline void *usb_role_switch_get_drvdata(struct usb_role_switch *sw)
> return NULL;
> }
>
> +static inline const char *usb_role_string(enum usb_role role)
> +{
> + return "unknown";
> +}
> +
> #endif
>
> #endif /* __LINUX_USB_ROLE_H */
> --
> 2.18.0
--
heikki
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] usb: roles: add helper usb_role_string()
@ 2021-05-26 6:31 ` Heikki Krogerus
0 siblings, 0 replies; 9+ messages in thread
From: Heikki Krogerus @ 2021-05-26 6:31 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Greg Kroah-Hartman, Matthias Brugger, Thierry Reding,
Paul Cercueil, Lee Jones, Guenter Roeck, Hans de Goede,
linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
On Tue, May 25, 2021 at 04:53:05PM +0800, Chunfeng Yun wrote:
> Introduces usb_role_string() function, which returns a
> human-readable name of provided usb role, it's useful to
> make the log readable.
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/roles/class.c | 9 +++++++++
> include/linux/usb/role.h | 6 ++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
> index 33b637d0d8d9..dfaed7eee94f 100644
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -214,6 +214,15 @@ static const char * const usb_roles[] = {
> [USB_ROLE_DEVICE] = "device",
> };
>
> +const char *usb_role_string(enum usb_role role)
> +{
> + if (role < 0 || role >= ARRAY_SIZE(usb_roles))
> + return "unknown";
> +
> + return usb_roles[role];
> +}
> +EXPORT_SYMBOL_GPL(usb_role_string);
> +
> static ssize_t
> role_show(struct device *dev, struct device_attribute *attr, char *buf)
> {
> diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h
> index 0164fed31b06..031f148ab373 100644
> --- a/include/linux/usb/role.h
> +++ b/include/linux/usb/role.h
> @@ -65,6 +65,7 @@ void usb_role_switch_unregister(struct usb_role_switch *sw);
>
> void usb_role_switch_set_drvdata(struct usb_role_switch *sw, void *data);
> void *usb_role_switch_get_drvdata(struct usb_role_switch *sw);
> +const char *usb_role_string(enum usb_role role);
> #else
> static inline int usb_role_switch_set_role(struct usb_role_switch *sw,
> enum usb_role role)
> @@ -109,6 +110,11 @@ static inline void *usb_role_switch_get_drvdata(struct usb_role_switch *sw)
> return NULL;
> }
>
> +static inline const char *usb_role_string(enum usb_role role)
> +{
> + return "unknown";
> +}
> +
> #endif
>
> #endif /* __LINUX_USB_ROLE_H */
> --
> 2.18.0
--
heikki
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-05-26 6:33 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25 8:53 [PATCH 1/2] usb: roles: add helper usb_role_string() Chunfeng Yun
2021-05-25 8:53 ` Chunfeng Yun
2021-05-25 8:53 ` Chunfeng Yun
2021-05-25 8:53 ` [PATCH 2/2] usb: common: usb-conn-gpio: use usb_role_string() to print role status Chunfeng Yun
2021-05-25 8:53 ` Chunfeng Yun
2021-05-25 8:53 ` Chunfeng Yun
2021-05-26 6:31 ` [PATCH 1/2] usb: roles: add helper usb_role_string() Heikki Krogerus
2021-05-26 6:31 ` Heikki Krogerus
2021-05-26 6:31 ` Heikki Krogerus
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.