Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754433AbcC1GpR (ORCPT ); Mon, 28 Mar 2016 02:45:17 -0400 Received: from mail-qk0-f176.google.com ([209.85.220.176]:33586 "EHLO mail-qk0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753009AbcC1GpL (ORCPT ); Mon, 28 Mar 2016 02:45:11 -0400 MIME-Version: 1.0 In-Reply-To: References: <3609d98d4603efab7b2e50635efa9e36f64017a8.1458822334.git.baolin.wang@linaro.org> Date: Mon, 28 Mar 2016 14:45:10 +0800 Message-ID: Subject: Re: [PATCH v8 4/4] power: wm831x_power: Support USB charger current limit management From: Baolin Wang To: Geert Uytterhoeven Cc: Felipe Balbi , Greg KH , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Peter Chen , Alan Stern , r.baldyga@samsung.com, Yoshihiro Shimoda , Lee Jones , Mark Brown , Charles Keepax , patches@opensource.wolfsonmicro.com, Linux PM list , USB list , device-mainlining@lists.linuxfoundation.org, "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2437 Lines: 89 On 27 March 2016 at 16:22, Geert Uytterhoeven wrote: > On Thu, Mar 24, 2016 at 1:35 PM, Baolin Wang wrote: >> --- a/drivers/power/wm831x_power.c >> +++ b/drivers/power/wm831x_power.c >> @@ -13,6 +13,7 @@ >> #include >> #include >> #include >> +#include >> >> #include >> #include >> @@ -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 OK. > >> + 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 OK. > >> + >> + /* 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 OK. Thanks for your comments. > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-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 -- Baolin.wang Best Regards