Re: [PATCH 2/6] usb: typec: add typec_find_pwr_opmode

From: Heikki Krogerus
Date: Tue Jun 16 2020 - 06:56:21 EST


On Mon, Jun 15, 2020 at 06:15:08PM +0200, Amelie Delaunay wrote:
> This patch adds a function that converts power operation mode string into
> power operation mode value.
>
> It is useful to configure power operation mode through device tree
> property, as power capabilities may be linked to hardware design.
>
> Signed-off-by: Amelie Delaunay <amelie.delaunay@xxxxxx>

Acked-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>

> ---
> drivers/usb/typec/class.c | 15 +++++++++++++++
> include/linux/usb/typec.h | 1 +
> 2 files changed, 16 insertions(+)
>
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index c9234748537a..59e1837ef85e 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -1448,6 +1448,21 @@ void typec_set_pwr_opmode(struct typec_port *port,
> }
> EXPORT_SYMBOL_GPL(typec_set_pwr_opmode);
>
> +/**
> + * typec_find_pwr_opmode - Get the typec power operation mode capability
> + * @name: power operation mode string
> + *
> + * This routine is used to find the typec_pwr_opmode by its string @name.
> + *
> + * Returns typec_pwr_opmode if success, otherwise negative error code.
> + */
> +int typec_find_pwr_opmode(const char *name)
> +{
> + return match_string(typec_pwr_opmodes,
> + ARRAY_SIZE(typec_pwr_opmodes), name);
> +}
> +EXPORT_SYMBOL_GPL(typec_find_pwr_opmode);
> +
> /**
> * typec_find_orientation - Convert orientation string to enum typec_orientation
> * @name: Orientation string
> diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
> index 5daa1c49761c..f7c63ee3d443 100644
> --- a/include/linux/usb/typec.h
> +++ b/include/linux/usb/typec.h
> @@ -254,6 +254,7 @@ int typec_set_mode(struct typec_port *port, int mode);
>
> void *typec_get_drvdata(struct typec_port *port);
>
> +int typec_find_pwr_opmode(const char *name);
> int typec_find_orientation(const char *name);
> int typec_find_port_power_role(const char *name);
> int typec_find_power_role(const char *name);
> --
> 2.17.1

thanks,

--
heikki