lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YK3rW6NjED+07IdC@kuha.fi.intel.com>
Date:   Wed, 26 May 2021 09:31:55 +0300
From:   Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To:     Chunfeng Yun <chunfeng.yun@...iatek.com>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Matthias Brugger <matthias.bgg@...il.com>,
        Thierry Reding <treding@...dia.com>,
        Paul Cercueil <paul@...pouillou.net>,
        Lee Jones <lee.jones@...aro.org>,
        Guenter Roeck <linux@...ck-us.net>,
        Hans de Goede <hdegoede@...hat.com>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH 1/2] usb: roles: add helper usb_role_string()

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@...iatek.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@...ux.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ