Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power: supply: ab8500_fg: silence uninitialized variable warnings

If kstrtoul() fails then we print "charge_full" when it's uninitialized.
The debug printk doesn't add anything so I deleted it and cleaned these
two functions up a bit.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Dan Carpenter and committed by
Sebastian Reichel
54baff8d 87a2b65f

+12 -19
+12 -19
drivers/power/supply/ab8500_fg.c
··· 2433 2433 size_t count) 2434 2434 { 2435 2435 unsigned long charge_full; 2436 - ssize_t ret; 2436 + int ret; 2437 2437 2438 2438 ret = kstrtoul(buf, 10, &charge_full); 2439 + if (ret) 2440 + return ret; 2439 2441 2440 - dev_dbg(di->dev, "Ret %zd charge_full %lu", ret, charge_full); 2441 - 2442 - if (!ret) { 2443 - di->bat_cap.max_mah = (int) charge_full; 2444 - ret = count; 2445 - } 2446 - return ret; 2442 + di->bat_cap.max_mah = (int) charge_full; 2443 + return count; 2447 2444 } 2448 2445 2449 2446 static ssize_t charge_now_show(struct ab8500_fg *di, char *buf) ··· 2452 2455 size_t count) 2453 2456 { 2454 2457 unsigned long charge_now; 2455 - ssize_t ret; 2458 + int ret; 2456 2459 2457 2460 ret = kstrtoul(buf, 10, &charge_now); 2461 + if (ret) 2462 + return ret; 2458 2463 2459 - dev_dbg(di->dev, "Ret %zd charge_now %lu was %d", 2460 - ret, charge_now, di->bat_cap.prev_mah); 2461 - 2462 - if (!ret) { 2463 - di->bat_cap.user_mah = (int) charge_now; 2464 - di->flags.user_cap = true; 2465 - ret = count; 2466 - queue_delayed_work(di->fg_wq, &di->fg_periodic_work, 0); 2467 - } 2468 - return ret; 2464 + di->bat_cap.user_mah = (int) charge_now; 2465 + di->flags.user_cap = true; 2466 + queue_delayed_work(di->fg_wq, &di->fg_periodic_work, 0); 2467 + return count; 2469 2468 } 2470 2469 2471 2470 static struct ab8500_fg_sysfs_entry charge_full_attr =