From c09c65ca5c76cc50412fc65e5c91f5dff3e401c5 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Mon, 6 Nov 2017 13:46:10 +0100 Subject: [PATCH 1/5] power: supply: max8997: Improve a size determination in probe Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Sebastian Reichel --- drivers/power/supply/max8997_charger.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c index fa861003fece..c73fb4221695 100644 --- a/drivers/power/supply/max8997_charger.c +++ b/drivers/power/supply/max8997_charger.c @@ -146,8 +146,7 @@ static int max8997_battery_probe(struct platform_device *pdev) return ret; } - charger = devm_kzalloc(&pdev->dev, sizeof(struct charger_data), - GFP_KERNEL); + charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL); if (!charger) return -ENOMEM; From 393ce139d5234a00200f9aaecb6048be138e0833 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 31 Oct 2017 10:40:00 +0000 Subject: [PATCH 2/5] power: supply: generic-adc-battery: remove redundant variable pdata Pointer pdata is assigned but never used, so remove it. Cleans up the clang warning: drivers/power/supply/generic-adc-battery.c:211:2: warning: Value stored to 'pdata' is never read Signed-off-by: Colin Ian King Signed-off-by: Sebastian Reichel --- drivers/power/supply/generic-adc-battery.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/power/supply/generic-adc-battery.c b/drivers/power/supply/generic-adc-battery.c index 37e523374fe0..28dc056eaafa 100644 --- a/drivers/power/supply/generic-adc-battery.c +++ b/drivers/power/supply/generic-adc-battery.c @@ -201,14 +201,12 @@ err: static void gab_work(struct work_struct *work) { struct gab *adc_bat; - struct gab_platform_data *pdata; struct delayed_work *delayed_work; bool is_plugged; int status; delayed_work = to_delayed_work(work); adc_bat = container_of(delayed_work, struct gab, bat_work); - pdata = adc_bat->pdata; status = adc_bat->status; is_plugged = power_supply_am_i_supplied(adc_bat->psy); From e7c984cc6f35766019039867875c788c4545147a Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 31 Oct 2017 13:48:23 +0000 Subject: [PATCH 3/5] power: supply: pcf50633-charger: remove redundant variable charging_start Variable charging_start is being set but is never read, it is therefore redundant and can be removed. Cleans up sparse warning: drivers/power/supply/pcf50633-charger.c:61:3: warning: Value stored to 'charging_start' is never read Signed-off-by: Colin Ian King Signed-off-by: Sebastian Reichel --- drivers/power/supply/pcf50633-charger.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/power/supply/pcf50633-charger.c b/drivers/power/supply/pcf50633-charger.c index 1ad7ccce6075..1aba14046a83 100644 --- a/drivers/power/supply/pcf50633-charger.c +++ b/drivers/power/supply/pcf50633-charger.c @@ -43,7 +43,6 @@ int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma) struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev); int ret = 0; u8 bits; - int charging_start = 1; u8 mbcs2, chgmod; unsigned int mbcc5; @@ -58,7 +57,6 @@ int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma) ma = 100; } else { bits = PCF50633_MBCC7_USB_SUSPEND; - charging_start = 0; ma = 0; } From 33a7067732cf1b86b5dc672cfa9bbc15460117e5 Mon Sep 17 00:00:00 2001 From: Aishwarya Pant Date: Tue, 10 Oct 2017 20:09:18 +0530 Subject: [PATCH 4/5] power: supply: replace pr_* with dev_* Use kernel preferred dev_* family of functions in place of pr_*, wherever a device object is present. Done with the help of coccinelle. Signed-off-by: Aishwarya Pant Signed-off-by: Sebastian Reichel --- drivers/power/supply/power_supply_core.c | 2 +- drivers/power/supply/twl4030_charger.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 02c6340ae36f..82f998ab5a52 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -669,7 +669,7 @@ EXPORT_SYMBOL_GPL(power_supply_powers); static void power_supply_dev_release(struct device *dev) { struct power_supply *psy = container_of(dev, struct power_supply, dev); - pr_debug("device: '%s': %s\n", dev_name(dev), __func__); + dev_dbg(dev, "%s\n", __func__); kfree(psy); } diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c index a5915f498eea..bbcaee56db9d 100644 --- a/drivers/power/supply/twl4030_charger.c +++ b/drivers/power/supply/twl4030_charger.c @@ -743,7 +743,7 @@ static int twl4030bci_state(struct twl4030_bci *bci) ret = twl4030_bci_read(TWL4030_BCIMSTATEC, &state); if (ret) { - pr_err("twl4030_bci: error reading BCIMSTATEC\n"); + dev_err(bci->dev, "error reading BCIMSTATEC\n"); return ret; } From 838c8afa67f98014970c9f56107805e767ed87ad Mon Sep 17 00:00:00 2001 From: Pan Bian Date: Sun, 12 Nov 2017 23:52:02 +0800 Subject: [PATCH 5/5] power: supply: cpcap-charger: fix incorrect return value check Function platform_get_irq_byname() returns a negative error code on failure, and a zero or positive number on success. However, in function cpcap_usb_init_irq(), positive IRQ numbers are also taken as error cases. Use "if (irq < 0)" instead of "if (!irq)" to validate the return value of platform_get_irq_byname(). Signed-off-by: Pan Bian Signed-off-by: Sebastian Reichel --- drivers/power/supply/cpcap-charger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/cpcap-charger.c b/drivers/power/supply/cpcap-charger.c index 11a07633de6c..e4905bef2663 100644 --- a/drivers/power/supply/cpcap-charger.c +++ b/drivers/power/supply/cpcap-charger.c @@ -484,7 +484,7 @@ static int cpcap_usb_init_irq(struct platform_device *pdev, int irq, error; irq = platform_get_irq_byname(pdev, name); - if (!irq) + if (irq < 0) return -ENODEV; error = devm_request_threaded_irq(ddata->dev, irq, NULL,