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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdVUwbp4bJDYWjw6QyfngxYJgJCBe4=DN53tpFhjxUagcA@mail.gmail.com>
Date:	Sun, 27 Mar 2016 10:22:37 +0200
From:	Geert Uytterhoeven <geert@...ux-m68k.org>
To:	Baolin Wang <baolin.wang@...aro.org>
Cc:	Felipe Balbi <balbi@...nel.org>,
	Greg KH <gregkh@...uxfoundation.org>,
	Sebastian Reichel <sre@...nel.org>,
	Dmitry Eremin-Solenikov <dbaryshkov@...il.com>,
	David Woodhouse <dwmw2@...radead.org>,
	Peter Chen <peter.chen@...escale.com>,
	Alan Stern <stern@...land.harvard.edu>, r.baldyga@...sung.com,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>,
	Lee Jones <lee.jones@...aro.org>,
	Mark Brown <broonie@...nel.org>,
	Charles Keepax <ckeepax@...nsource.wolfsonmicro.com>,
	patches@...nsource.wolfsonmicro.com,
	Linux PM list <linux-pm@...r.kernel.org>,
	USB list <linux-usb@...r.kernel.org>,
	device-mainlining@...ts.linuxfoundation.org,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v8 4/4] power: wm831x_power: Support USB charger current
 limit management

On Thu, Mar 24, 2016 at 1:35 PM, Baolin Wang <baolin.wang@...aro.org> wrote:
> --- a/drivers/power/wm831x_power.c
> +++ b/drivers/power/wm831x_power.c
> @@ -13,6 +13,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/power_supply.h>
>  #include <linux/slab.h>
> +#include <linux/usb/usb_charger.h>
>
>  #include <linux/mfd/wm831x/core.h>
>  #include <linux/mfd/wm831x/auxadc.h>
> @@ -31,6 +32,8 @@ struct wm831x_power {
>         char usb_name[20];
>         char battery_name[20];
>         bool have_battery;
> +       struct usb_charger *usb_charger;
> +       struct notifier_block usb_notify;
>  };
>
>  static int wm831x_power_check_online(struct wm831x *wm831x, int supply,
> @@ -125,6 +128,43 @@ static enum power_supply_property wm831x_usb_props[] = {
>         POWER_SUPPLY_PROP_VOLTAGE_NOW,
>  };
>
> +/* In milliamps */
> +static unsigned int wm831x_usb_limits[] = {

const

> +       0,
> +       2,
> +       100,
> +       500,
> +       900,
> +       1500,
> +       1800,
> +       550,
> +};
> +
> +static int wm831x_usb_limit_change(struct notifier_block *nb,
> +                                  unsigned long limit, void *data)
> +{
> +       struct wm831x_power *wm831x_power = container_of(nb,
> +                                                        struct wm831x_power,
> +                                                        usb_notify);
> +       int i, best;

unsigned int

> +
> +       /* Find the highest supported limit */
> +       best = 0;
> +       for (i = 0; i < ARRAY_SIZE(wm831x_usb_limits); i++) {
> +               if (limit >= wm831x_usb_limits[i] &&
> +                   wm831x_usb_limits[best] < wm831x_usb_limits[i])
> +                       best = i;
> +       }
> +
> +       dev_dbg(wm831x_power->wm831x->dev,
> +               "Limiting USB current to %dmA", wm831x_usb_limits[best]);

%u

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ