Linux Power Management development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: linux-pm@vger.kernel.org,
	Enric Balletbo Serra <enric.balletbo@collabora.com>,
	Chris Healy <cphealy@gmail.com>,
	Lucas Stach <l.stach@pengutronix.de>,
	Fabio Estevam <fabio.estevam@nxp.com>,
	Sebastian Reichel <sre@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] power: supply: Add driver for Microchip UCS1002
Date: Mon, 29 Apr 2019 13:36:01 -0700	[thread overview]
Message-ID: <20190429203601.GA22613@roeck-us.net> (raw)
In-Reply-To: <20190429195349.20335-3-andrew.smirnov@gmail.com>

On Mon, Apr 29, 2019 at 12:53:48PM -0700, Andrey Smirnov wrote:
> Add driver for Microchip UCS1002 Programmable USB Port Power
> Controller with Charger Emulation. The driver exposed a power supply
> device to control/monitor various parameter of the device as well as a
> regulator to allow controlling VBUS line.
> 
> Signed-off-by: Enric Balletbo Serra <enric.balletbo@collabora.com>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> Cc: Chris Healy <cphealy@gmail.com>
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Cc: Fabio Estevam <fabio.estevam@nxp.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Sebastian Reichel <sre@kernel.org>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> ---
>  drivers/power/supply/Kconfig         |   9 +
>  drivers/power/supply/Makefile        |   1 +
>  drivers/power/supply/ucs1002_power.c | 646 +++++++++++++++++++++++++++
>  3 files changed, 656 insertions(+)
>  create mode 100644 drivers/power/supply/ucs1002_power.c
> 
> diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
> index e901b9879e7e..c614c8a196f3 100644
> --- a/drivers/power/supply/Kconfig
> +++ b/drivers/power/supply/Kconfig
> @@ -660,4 +660,13 @@ config FUEL_GAUGE_SC27XX
>  	 Say Y here to enable support for fuel gauge with SC27XX
>  	 PMIC chips.
>  
> +config CHARGER_UCS1002
> +        tristate "Microchip UCS1002 USB Port Power Controller"
> +	depends on I2C
> +	depends on OF
> +	select REGMAP_I2C
> +	help
> +	  Say Y to enable support for Microchip UCS1002 Programmable
> +	  USB Port Power Controller with Charger Emulation.
> +
>  endif # POWER_SUPPLY
> diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile
> index b731c2a9b695..c56803a9e4fe 100644
> --- a/drivers/power/supply/Makefile
> +++ b/drivers/power/supply/Makefile
> @@ -87,3 +87,4 @@ obj-$(CONFIG_AXP288_CHARGER)	+= axp288_charger.o
>  obj-$(CONFIG_CHARGER_CROS_USBPD)	+= cros_usbpd-charger.o
>  obj-$(CONFIG_CHARGER_SC2731)	+= sc2731_charger.o
>  obj-$(CONFIG_FUEL_GAUGE_SC27XX)	+= sc27xx_fuel_gauge.o
> +obj-$(CONFIG_CHARGER_UCS1002)	+= ucs1002_power.o
> diff --git a/drivers/power/supply/ucs1002_power.c b/drivers/power/supply/ucs1002_power.c
> new file mode 100644
> index 000000000000..677f20a4d76f
> --- /dev/null
> +++ b/drivers/power/supply/ucs1002_power.c
> @@ -0,0 +1,646 @@
...
> +
> +static enum power_supply_usb_type ucs1002_usb_types[] = {
> +	POWER_SUPPLY_USB_TYPE_PD,
> +	POWER_SUPPLY_USB_TYPE_SDP,
> +	POWER_SUPPLY_USB_TYPE_DCP,
> +	POWER_SUPPLY_USB_TYPE_CDP,
> +	POWER_SUPPLY_USB_TYPE_UNKNOWN,
> +};
> +
> +static int ucs1002_set_usb_type(struct ucs1002_info *info, int val)
> +{
> +	unsigned int mode;
> +
> +	if (val >= ARRAY_SIZE(ucs1002_usb_types))
> +		return -EINVAL;
> +
I hate to bring it up that late, but I don't see a check
against val being negative anywhere in the calling code.

Guenter

  parent reply	other threads:[~2019-04-29 20:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-29 19:53 [PATCH v3 0/3] Driver for UCS1002 Andrey Smirnov
2019-04-29 19:53 ` Andrey Smirnov
2019-04-29 19:53 ` [PATCH v3 1/3] power: supply: core: Add POWER_SUPPLY_HEALTH_OVERCURRENT constant Andrey Smirnov
2019-04-29 19:53   ` Andrey Smirnov
2019-04-29 19:53 ` [PATCH v3 2/3] power: supply: Add driver for Microchip UCS1002 Andrey Smirnov
2019-04-29 19:53   ` Andrey Smirnov
2019-04-29 20:36   ` Guenter Roeck [this message]
2019-04-29 20:36     ` Guenter Roeck
2019-04-30  1:16     ` Andrey Smirnov
2019-04-30  1:16       ` Andrey Smirnov
2019-04-29 19:53 ` [PATCH v3 3/3] dt-bindings: power: supply: Add bindings " Andrey Smirnov
2019-04-29 19:53   ` Andrey Smirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190429203601.GA22613@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=andrew.smirnov@gmail.com \
    --cc=cphealy@gmail.com \
    --cc=enric.balletbo@collabora.com \
    --cc=fabio.estevam@nxp.com \
    --cc=l.stach@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox