[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20080813164530.82528a4d.akpm@linux-foundation.org>
Date: Wed, 13 Aug 2008 16:45:30 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Rodolfo Giometti <giometti@...eenne.com>
Cc: linux-kernel@...r.kernel.org, cbouatmailru@...il.com,
dwmw2@...radead.org, giometti@...ux.it
Subject: Re: [PATCH 1/1] power: support for Texas Instruments BQ27x00
battery managers.
On Fri, 1 Aug 2008 11:53:55 +0200
Rodolfo Giometti <giometti@...eenne.com> wrote:
> From: Rodolfo Giometti <giometti@...ux.it>
>
> These battery managers came in two different packages: one for I2C
> busses (BQ27200) and one for HDQ busses (BQ27000).
>
> This driver currently supports only the I2C chip version but the code
> is designed in order to easily allow the HDQ chip version integration.
>
>
> ...
>
> +/* If the system has several batteries we need a different name for each
> + * of them...
> + */
> +DEFINE_IDR(battery_id);
> +DEFINE_MUTEX(battery_mutex);
These should be static.
>
> ...
>
> +static int bq27200_battery_probe(struct i2c_client *client,
> + const struct i2c_device_id *id)
> +{
> + char *name;
> + struct bq27x00_device_info *di;
> + struct bq27x00_access_methods *bus;
> + int num, retval = 0;
> +
> + /* Get new ID for the new battery device */
> + retval = idr_pre_get(&battery_id, GFP_KERNEL);
> + if (retval == 0)
> + return -ENOMEM;
> + mutex_lock(&battery_mutex);
> + retval = idr_get_new(&battery_id, client, &num);
> + mutex_unlock(&battery_mutex);
> + if (retval < 0)
> + return retval;
> +
> + name = kmalloc(16, GFP_KERNEL);
> + if (!name) {
> + dev_err(&client->dev, "failed to allocate device name\n");
> + retval = -ENOMEM;
> + goto batt_failed_1;
> + }
> + sprintf(name, "bq27200-%d", num);
Use kasprintf()
> + di = kzalloc(sizeof(*di), GFP_KERNEL);
> + if (!di) {
> + dev_err(&client->dev, "failed to allocate device info data\n");
> + retval = -ENOMEM;
> + goto batt_failed_2;
> + }
> + di->id = num;
> +
Please review:
From: Andrew Morton <akpm@...ux-foundation.org>
ERROR: space prohibited before that ':' (ctx:WxE)
#227: FILE: drivers/power/bq27x00_battery.c:175:
+ case POWER_SUPPLY_PROP_VOLTAGE_NOW :
^
ERROR: space prohibited before that ':' (ctx:WxE)
#228: FILE: drivers/power/bq27x00_battery.c:176:
+ case POWER_SUPPLY_PROP_PRESENT :
^
ERROR: space prohibited before that ':' (ctx:WxE)
#235: FILE: drivers/power/bq27x00_battery.c:183:
+ case POWER_SUPPLY_PROP_CURRENT_NOW :
^
ERROR: space prohibited before that ':' (ctx:WxE)
#240: FILE: drivers/power/bq27x00_battery.c:188:
+ case POWER_SUPPLY_PROP_CAPACITY :
^
ERROR: space prohibited before that ':' (ctx:WxE)
#245: FILE: drivers/power/bq27x00_battery.c:193:
+ case POWER_SUPPLY_PROP_TEMP :
^
total: 5 errors, 0 warnings, 412 lines checked
./patches/power-support-for-texas-instruments-bq27x00-battery-managers.patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Please run checkpatch prior to sending patches
Cc: Anton Vorontsov <cbouatmailru@...il.com>
Cc: David Woodhouse <dwmw2@...radead.org>
Cc: Rodolfo Giometti <giometti@...ux.it>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
---
drivers/power/bq27x00_battery.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff -puN drivers/power/Kconfig~power-support-for-texas-instruments-bq27x00-battery-managers-checkpatch-fixes drivers/power/Kconfig
diff -puN drivers/power/Makefile~power-support-for-texas-instruments-bq27x00-battery-managers-checkpatch-fixes drivers/power/Makefile
diff -puN drivers/power/bq27x00_battery.c~power-support-for-texas-instruments-bq27x00-battery-managers-checkpatch-fixes drivers/power/bq27x00_battery.c
--- a/drivers/power/bq27x00_battery.c~power-support-for-texas-instruments-bq27x00-battery-managers-checkpatch-fixes
+++ a/drivers/power/bq27x00_battery.c
@@ -172,25 +172,25 @@ static int bq27x00_battery_get_property(
struct bq27x00_device_info *di = to_bq27x00_device_info(psy);
switch (psp) {
- case POWER_SUPPLY_PROP_VOLTAGE_NOW :
- case POWER_SUPPLY_PROP_PRESENT :
+ case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+ case POWER_SUPPLY_PROP_PRESENT:
val->intval = bq27x00_battery_voltage(di);
if (psp == POWER_SUPPLY_PROP_PRESENT)
val->intval = val->intval <= 0 ? 0 : 1;
break;
- case POWER_SUPPLY_PROP_CURRENT_NOW :
+ case POWER_SUPPLY_PROP_CURRENT_NOW:
val->intval = bq27x00_battery_current(di);
break;
- case POWER_SUPPLY_PROP_CAPACITY :
+ case POWER_SUPPLY_PROP_CAPACITY:
val->intval = bq27x00_battery_rsoc(di);
break;
- case POWER_SUPPLY_PROP_TEMP :
+ case POWER_SUPPLY_PROP_TEMP:
val->intval = bq27x00_battery_temperature(di);
break;
_
From: Andrew Morton <akpm@...ux-foundation.org>
- make things static
- use kasprintf()
Cc: Anton Vorontsov <cbouatmailru@...il.com>
Cc: David Woodhouse <dwmw2@...radead.org>
Cc: Rodolfo Giometti <giometti@...ux.it>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
---
drivers/power/bq27x00_battery.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff -puN drivers/power/Kconfig~power-support-for-texas-instruments-bq27x00-battery-managers-tweaks drivers/power/Kconfig
diff -puN drivers/power/Makefile~power-support-for-texas-instruments-bq27x00-battery-managers-tweaks drivers/power/Makefile
diff -puN drivers/power/bq27x00_battery.c~power-support-for-texas-instruments-bq27x00-battery-managers-tweaks drivers/power/bq27x00_battery.c
--- a/drivers/power/bq27x00_battery.c~power-support-for-texas-instruments-bq27x00-battery-managers-tweaks
+++ a/drivers/power/bq27x00_battery.c
@@ -40,8 +40,8 @@
/* If the system has several batteries we need a different name for each
* of them...
*/
-DEFINE_IDR(battery_id);
-DEFINE_MUTEX(battery_mutex);
+static DEFINE_IDR(battery_id);
+static DEFINE_MUTEX(battery_mutex);
struct bq27x00_device_info;
struct bq27x00_access_methods {
@@ -275,13 +275,12 @@ static int bq27200_battery_probe(struct
if (retval < 0)
return retval;
- name = kmalloc(16, GFP_KERNEL);
+ name = kasprintf(GFP_KERNEL, "bq27200-%d", num);
if (!name) {
dev_err(&client->dev, "failed to allocate device name\n");
retval = -ENOMEM;
goto batt_failed_1;
}
- sprintf(name, "bq27200-%d", num);
di = kzalloc(sizeof(*di), GFP_KERNEL);
if (!di) {
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists