aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/supply (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-04-05power: supply: goldfish: Remove the GOLDFISH dependencyRoman Kiryanov1-3/+3
This will allow to use the BATTERY_GOLDFISH driver without enabling GOLDFISH. Signed-off-by: Roman Kiryanov <rkir@google.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-05power: supply: cpcap-charger: Simplify bool conversionYang Li1-1/+1
Fix the following coccicheck warning: ./drivers/power/supply/cpcap-charger.c:416:31-36: WARNING: conversion to bool not needed here Reported-by: Abaci Robot <abaci@linux.alibaba.com> Signed-off-by: Yang Li <yang.lee@linux.alibaba.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-05power: supply: cpcap-charger: Add usleep to cpcap charger to avoid usb plug bounceCarl Philipp Klemm1-0/+3
Adds 80000 us sleep when the usb cable is plugged in to hopefully avoid bouncing contacts. Upon pluging in the usb cable vbus will bounce for some time, causing cpcap to dissconnect charging due to detecting an undervoltage condition. This is a scope of vbus on xt894 while quickly inserting the usb cable with firm force, probed at the far side of the usb socket and vbus loaded with approx 1k: http://uvos.xyz/maserati/usbplug.jpg. As can clearly be seen, vbus is all over the place for the first 15 ms or so with a small blip at ~40 ms this causes the cpcap to trip up and disable charging again. The delay helps cpcap_usb_detect avoid the worst of this. It is, however, still not ideal as strong vibrations can cause the issue to reapear any time during charging. I have however not been able to cause the device to stop charging due to this in practice as it is hard to vibrate the device such that the vbus pins start bouncing again but cpcap_usb_detect is not called again due to a detected disconnect/reconnect event. Signed-off-by: Carl Philipp Klemm <philipp@uvos.xyz> Tested-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-05power: supply: cpcap-charger: fix small mistake in current to register conversionCarl Philipp Klemm1-1/+1
Signed-off-by: Carl Philipp Klemm <philipp@uvos.xyz> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02power: supply: core: reduce loglevel for probe defer infoSebastian Reichel1-2/+2
Avoid logging probe defer information for default loglevel configurations. This is only required for debugging probe defer issues, which requires enabling debug messages for other subsystems. This dev_info() message predates having deferred devices information available in /sys/kernel/debug/devices_deferred, which is generally more useful. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02power: supply: sbs-manager: update gpio includeSebastian Reichel1-1/+1
sbs-manager implements a GPIO chip, so include the proper gpio driver include instead of the legacy gpio.h. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02power: supply: sbs-manager: use dev_err_probeSebastian Reichel1-38/+17
Introduce usage of dev_err_probe in probe routine, which makes the code slightly more readable and removes some lines of code. It also removes PROBE_DEFER errors being logged by default. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02power: supply: sbs-manager: use managed i2c_mux_adapterSebastian Reichel1-11/+10
Simplify code by using devm_add_action_or_reset to unregister the i2c_mux_adapter. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02power: supply: sbs-charger: drop unused gpio includesSebastian Reichel1-2/+0
sbs-charger does not use any GPIOs, so no need to include gpio.h and of_gpio.h. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02power: supply: sbs-charger: use dev_err_probeSebastian Reichel1-14/+8
Introduce usage of dev_err_probe in probe routine, which makes the code slightly more readable and removes some lines of code. It also removes PROBE_DEFER errors being logged by default. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02power: supply: sbs-battery: use dev_err_probeSebastian Reichel1-19/+9
Introduce usage of dev_err_probe in probe routine, which makes the code slightly more readable and removes some lines of code. It also removes PROBE_DEFER errors being logged by default, which are common when the battery is waiting for the charger driver to be registered. This also cleans up a useless goto and instead returns directly. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02power: supply: 88pm860x_battery: Remove unnecessary int for long longMilan Djurovic1-2/+2
Change 'long long int' to 'long long' because the int is unnecessary, as suggested by checkpatch.pl. Signed-off-by: Milan Djurovic <mdjurovic@zohomail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02power: supply: max8997_charger: Switch to new bindingTimon Baetz1-4/+8
Get regulator from parent device's node and extcon by name. Signed-off-by: Timon Baetz <timon.baetz@protonmail.com> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-26power: supply: axp20x_usb_power: fix work-queue initMatti Vaittinen1-5/+5
The commit 6d0c5de2fd84 ("power: supply: Clean-up few drivers by using managed work init") Re-introduced wrong order of initializing work-queue and requesting the IRQs which was originally fixed by the commit b5e8642ed95f ("power: supply: axp20x_usb_power: Init work before enabling IRQs") In addition this caused the work queue to be initialized twice. Fix it again. Fixes: 6d0c5de2fd84 ("power: supply: Clean-up few drivers by using managed work init") Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Reported-by: Chen-Yu Tsai <wens@csie.org> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> Link: https://lore.kernel.org/r/a774ca25010b7c932c07f22ce8a548466705c023.1616574973.git.matti.vaittinen@fi.rohmeurope.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-23power: supply: Clean-up few drivers by using managed work initMatti Vaittinen4-46/+23
Few drivers implement remove call-back only for ensuring a delayed work gets cancelled prior driver removal. Clean-up these by switching to use devm_delayed_work_autocancel() instead. This change is compile-tested only. All testing is appreciated. Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Link: https://lore.kernel.org/r/e5b1b0380cdd1aa066c9ac6d7a8b1a86ba1ddbbe.1616506559.git.matti.vaittinen@fi.rohmeurope.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-23power: supply: max17042: Trivial spelling fixesBhaskar Chowdhury1-4/+4
Few trivial spelling fixes. Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-22mfd/power: ab8500: Push data to power supply codeLinus Walleij1-4/+274
There is a slew of defines, structs and enums and even a function call only relevant for the charging code that still lives in <linux/mfd/abx500.h>. Push it down to the "ab8500-bm.h" header in the power supply subsystem where it is actually used. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-03-22mfd/power: ab8500: Push algorithm to power supply codeLinus Walleij4-3/+54
The charging algorithm header is only used locally in the power supply subsystem so push this down into drivers/power/supply and rename from the confusing "ux500_chargalg.h" to "ab8500-chargalg.h" for clarity: it is only used with the AB8500. This is another remnant of non-DT code needing to pass data from boardfiles, which we don't do anymore. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-03-22mfd/power: ab8500: Push data to power supply codeLinus Walleij7-54/+479
The global definition of platform data for the battery management code has no utility after the OF conversion, move the <linux/mfd/abx500/ab8500-bm.h> to be a local file in drivers/power/supply and stop defining the platform data in drivers/power/supply/ab8500_bmdata.c and broadcast to the kernel only to have it assigned as platform data to the MFD cells and then picked back into the same subsystem that defined it in the first place. This kills off a layer of indirection. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-03-22power: ab8500: Require device treeLinus Walleij5-28/+19
The core AB8500 driver and the whole platform is completely dependent on being probed from device tree so remove the non-DT probe paths. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-03-22power: supply: max1721x: Correct spellingXiaofeng Cao1-7/+7
Change 'stanalone' to 'standalone' Change 'mesaurement' to 'measurement' Change 'nonvilatile' to 'nonvolatile' Change 'unical' to 'unique' Change 'unaccesable' to 'unaccessible' Change 'correcpondent' to 'correspond' Signed-off-by: Xiaofeng Cao <caoxiaofeng@yulong.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-22power: supply: ds2781: use kobj_to_dev()dongjian1-4/+4
Use kobj_to_dev() instead of open-coding it Signed-off-by: dongjian <dongjian@yulong.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-22power: supply: charger-manager: Fix a typoBhaskar Chowdhury1-1/+1
s/systme/system/ Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> Acked-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-22power: supply: Use IRQF_ONESHOTdongjian4-4/+4
Fixes coccicheck error: drivers/power/supply/pm2301_charger.c:1089:7-27: ERROR: drivers/power/supply/lp8788-charger.c:502:8-28: ERROR: drivers/power/supply/tps65217_charger.c:239:8-33: ERROR: drivers/power/supply/tps65090-charger.c:303:8-33: ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT Signed-off-by: dongjian <dongjian@yulong.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-21power: supply: bq27xxx: Add support for BQ78Z100LI Qingwu2-0/+46
Add support for TI BQ78Z100, I2C interface gas gauge. It provides a fully integrated safety protection and authentication for 1 to 2-series cell Li-Ion and Li-Polymer battery packs. The patch was tested with BQ78Z100 equipment. CASE I: Discharging: POWER_SUPPLY_NAME=bq78z100-0 POWER_SUPPLY_STATUS=Discharging POWER_SUPPLY_PRESENT=1 POWER_SUPPLY_VOLTAGE_NOW=3386000 POWER_SUPPLY_CURRENT_NOW=-5000 POWER_SUPPLY_CAPACITY=27 POWER_SUPPLY_CAPACITY_LEVEL=Normal POWER_SUPPLY_TEMP=269 POWER_SUPPLY_TIME_TO_EMPTY_NOW=1249920 POWER_SUPPLY_TECHNOLOGY=Li-ion POWER_SUPPLY_CHARGE_FULL=6494000 POWER_SUPPLY_CHARGE_NOW=1736000 POWER_SUPPLY_CHARGE_FULL_DESIGN=6000000 POWER_SUPPLY_CYCLE_COUNT=1 POWER_SUPPLY_POWER_AVG=-20000 POWER_SUPPLY_HEALTH=Good POWER_SUPPLY_MANUFACTURER=Texas Instruments CASE II : No discharging current: POWER_SUPPLY_NAME=bq78z100-0 POWER_SUPPLY_STATUS=Not charging POWER_SUPPLY_PRESENT=1 POWER_SUPPLY_VOLTAGE_NOW=3386000 POWER_SUPPLY_CURRENT_NOW=0 POWER_SUPPLY_CAPACITY=27 POWER_SUPPLY_CAPACITY_LEVEL=Normal POWER_SUPPLY_TEMP=270 POWER_SUPPLY_TECHNOLOGY=Li-ion POWER_SUPPLY_CHARGE_FULL=6494000 POWER_SUPPLY_CHARGE_NOW=1734000 POWER_SUPPLY_CHARGE_FULL_DESIGN=6000000 POWER_SUPPLY_CYCLE_COUNT=1 POWER_SUPPLY_POWER_AVG=0 POWER_SUPPLY_HEALTH=Good POWER_SUPPLY_MANUFACTURER=Texas Instruments Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-15power: supply: bq27xxx: make status more robustMatthias Schiffer1-45/+43
There are multiple issues in bq27xxx_battery_status(): - On BQ28Q610 is was observed that the "full" flag may be set even while the battery is charging or discharging. With the current logic to make "full" override everything else, it look a very long time (>20min) for the status to change from "full" to "discharging" after unplugging the supply on a device with low power consumption - The POWER_SUPPLY_STATUS_NOT_CHARGING check depends on power_supply_am_i_supplied(), which will not work when the supply doesn't exist as a separate device known to Linux We can solve both issues by deriving the status from the current instead of the flags field. The flags are now only used to distinguish "full" from "not charging", and to determine the sign of the current on BQ27XXX_O_ZERO devices. Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-15power: supply: bq27xxx: fix power_avg for newer ICsMatthias Schiffer1-24/+27
On all newer bq27xxx ICs, the AveragePower register contains a signed value; in addition to handling the raw value as unsigned, the driver code also didn't convert it to µW as expected. At least for the BQ28Z610, the reference manual incorrectly states that the value is in units of 1mW and not 10mW. I have no way of knowing whether the manuals of other supported ICs contain the same error, or if there are models that actually use 1mW. At least, the new code shouldn't be *less* correct than the old version for any device. power_avg is removed from the cache structure, se we don't have to extend it to store both a signed value and an error code. Always getting an up-to-date value may be desirable anyways, as it avoids inconsistent current and power readings when switching between charging and discharging. Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-15power: supply: bq27xxx: fix sign of current_now for newer ICsMatthias Schiffer1-1/+1
Commit cd060b4d0868 ("power: supply: bq27xxx: fix polarity of current_now") changed the sign of current_now for all bq27xxx variants, but on BQ28Z610 I'm now seeing negated values *with* that patch. The GTA04/Openmoko device that was used for testing uses a BQ27000 or BQ27010 IC, so I assume only the BQ27XXX_O_ZERO code path was incorrect. Revert the behaviour for newer ICs. Fixes: cd060b4d0868 "power: supply: bq27xxx: fix polarity of current_now" Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-15power: supply: axp20x_usb_power: Add missing check in axp20x_usb_power_probeDinghao Liu1-1/+3
There are two regmap_update_bits() calls but only one of them has return value check, which is odd. Add a return value check and terminate the execution flow on failure just like the other call. Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-15power: supply: z2_battery: Drop unused variableLinus Walleij1-3/+0
The kernel test robot reports an unused variable in the Z2 battery code caused by a recent commit. Fixes: a3b4388ea19b ("power: supply: z2_battery: Convert to GPIO descriptors") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-06power: supply: smb347-charger: Clean up whitespaces in the codeDmitry Osipenko1-4/+3
Improve formatting of the code by removing unnecessary whitespaces. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-06power: supply: smb347-charger: Improve interrupt initializationDmitry Osipenko1-22/+36
A previous commit attempted to fix IRQ usage in a case where interrupt is failed to initialize, but it missed couple more cases that could be improved. The interrupt could be undefined and then everything related to interrupt shouldn't be touched by driver. Secondly, we shouldn't ignore errors that aren't directly related to enabling interrupt in hardware, like enabling h/w write-access or requesting interrupt. Improve interrupt initialization in the driver in order to handle the missing cases. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-06power: supply: s3c_adc_battery: remove unused pdata in suspend/resumeKrzysztof Kozlowski1-4/+0
The "pdata" local variable is not used in suspend/resume handlers since commit 7776bcd241e0 ("power: supply: s3c-adc-battery: Convert to GPIO descriptors"): drivers/power/supply/s3c_adc_battery.c: In function ‘s3c_adc_bat_suspend’: drivers/power/supply/s3c_adc_battery.c:405:28: warning: unused variable ‘pdata’ [-Wunused-variable] drivers/power/supply/s3c_adc_battery.c: In function ‘s3c_adc_bat_resume’: drivers/power/supply/s3c_adc_battery.c:422:28: warning: unused variable ‘pdata’ [-Wunused-variable] Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-06power: supply: s3c_adc_battery: add SPDX license identifierKrzysztof Kozlowski1-10/+5
Add SPDX license identifier and replace license boilerplate. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-06power: supply: cw2015: Add CHARGE_NOW supportMartin Ashby1-0/+6
CHARGE_NOW is expected by some user software (such as waybar) instead of 'CAPACITY', in order to correctly calculate remaining battery life. Signed-off-by: Martin Ashby <martin@ashbysoft.com> Reviewed-by: Tobias Schramm <t.schramm@manjaro.org> Tested-by: Tobias Schramm <t.schramm@manjaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-06power: supply: max8997-charger: remove unneeded semicolonJiapeng Chong1-1/+1
Fix the following coccicheck warnings: ./drivers/power/supply/max8997_charger.c:266:3-4: Unneeded semicolon. Reported-by: Abaci Robot <abaci@linux.alibaba.com> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-28power-supply: use kobj_to_dev()Jian Dong1-1/+1
Use kobj_to_dev() instead of open-coding it Signed-off-by: Jian Dong <dongjian@yulong.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-25power: supply: charger-manager: fix typoJunlin Yang1-2/+2
Change 'exeeds' to 'exceeds'. Signed-off-by: Junlin Yang <yangjunlin@yulong.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-25power: supply: bq25980: Fix repetive bq25975 with bq25960xinjian1-1/+1
The i2c_device_id bq25975 is repeated, and should be bq25960. Signed-off-by: xinjian <xinjian@yulong.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-25power: supply: smb347-charger: Fix interrupt usage if interrupt is unavailableDmitry Osipenko1-4/+8
The IRQ=0 could be a valid interrupt number in kernel because interrupt numbers are virtual in a modern kernel. Hence fix the interrupt usage in a case if interrupt is unavailable by not overriding the interrupt number which is used by the driver. Note that currently Nexus 7 is the only know device which uses SMB347 kernel diver and it has a properly working interrupt, hence this patch doesn't fix any real problems, it's a minor cleanup/improvement. Fixes: 99298de5df92 ("power: supply: smb347-charger: Replace mutex with IRQ disable/enable") Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-25power: supply: axp20x_usb_power: Init work before enabling IRQsSamuel Holland1-1/+1
The IRQ handler calls mod_delayed_work() on power->vbus_detect. However, that work item is not initialized until after the IRQs are enabled. If an IRQ is already pending when the driver is probed, the driver calls mod_delayed_work() on an uninitialized work item, which causes an oops. Fixes: bcfb7ae3f50b ("power: supply: axp20x_usb_power: Only poll while offline") Signed-off-by: Samuel Holland <samuel@sholland.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-17power: supply: fix sbs-charger build, needs REGMAP_I2CRandy Dunlap1-0/+1
CHARGER_SBS should select REGMAP_I2C since it uses API(s) that are provided by that Kconfig symbol. Fixes these errors: ../drivers/power/supply/sbs-charger.c:149:21: error: variable ‘sbs_regmap’ has initializer but incomplete type static const struct regmap_config sbs_regmap = { ../drivers/power/supply/sbs-charger.c:150:3: error: ‘const struct regmap_config’ has no member named ‘reg_bits’ .reg_bits = 8, ../drivers/power/supply/sbs-charger.c:155:23: error: ‘REGMAP_ENDIAN_LITTLE’ undeclared here (not in a function) .val_format_endian = REGMAP_ENDIAN_LITTLE, /* since based on SMBus */ ../drivers/power/supply/sbs-charger.c: In function ‘sbs_probe’: ../drivers/power/supply/sbs-charger.c:183:17: error: implicit declaration of function ‘devm_regmap_init_i2c’; did you mean ‘devm_request_irq’? [-Werror=implicit-function-declaration] chip->regmap = devm_regmap_init_i2c(client, &sbs_regmap); ../drivers/power/supply/sbs-charger.c: At top level: ../drivers/power/supply/sbs-charger.c:149:35: error: storage size of ‘sbs_regmap’ isn’t known static const struct regmap_config sbs_regmap = { Fixes: feb583e37f8a ("power: supply: add sbs-charger driver") Reported-by: Martin Mokrejs <mmokrejs@fold.natur.cuni.cz> Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Tested-by: Martin Mokrejs <mmokrejs@fold.natur.cuni.cz> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-16power: supply: bq27xxx: fix polarity of current_nowAndreas Kemnade1-2/+2
current_now has to be negative during discharging and positive during charging, the behavior seen is the other way round. Tested on GTA04 with Openmoko battery. Signed-off-by: Andreas Kemnade <andreas@kemnade.info> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-16power: supply: charger-manager: fix incorrect health statusJunlin Yang1-2/+2
cm->emergency_stop will only be the value in the enumeration, and cannot be less than zero, it will get an exception value. So replace it with the corresponding value. Signed-off-by: Junlin Yang <yangjunlin@yulong.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-16power: supply: bq24190_charger: convert comma to semicolonZheng Yongjun1-1/+1
Replace a comma between expression statements by a semicolon. Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-16power: supply: ab8500_fg: convert comma to semicolonZheng Yongjun1-1/+1
Replace a comma between expression statements by a semicolon. Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-16power: supply: ds2780: Switch to using the new API kobj_to_dev()Tian Tao1-4/+4
fixed the following coccicheck: drivers/power/supply/ds2780_battery.c:627:60-61: WARNING opportunity for kobj_to_dev() drivers/power/supply/ds2780_battery.c:672:60-61: WARNING opportunity for kobj_to_dev() drivers/power/supply/ds2780_battery.c:640:60-61: WARNING opportunity for kobj_to_dev() drivers/power/supply/ds2780_battery.c:685:60-61: WARNING opportunity for kobj_to_dev() Signed-off-by: Tian Tao <tiantao6@hisilicon.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-16power: supply: bq27xxx: Support CHARGE_NOW for bq27z561/bq28z610/bq34z100Hermes Zhang1-1/+34
Currently REG_NAC (nominal available capacity) is mapped to power-supply's CHARGE_NOW property. Some chips do not have REG_NAC and do not expose CHARGE_NOW at the moment. Some bq27xxx chips also have another register REG_RM (remaining capacity). The difference between REG_NAC and REG_RM is load compensation. This patch adds register information for REG_RM for all supported fuel gauges. On systems having REG_NAC it is ignored, so behaviour does not change. On systems without REG_NAC, REG_RM will be used to provide CHARGE_NOW functionality. As a result there are three more chips exposing CHARGE_NOW: bq27z561, bq28z610 and bq34z100 Signed-off-by: Hermes Zhang <chenhuiz@axis.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-15power: supply: cpcap-charger: Fix power_supply_put on null battery pointerColin Ian King1-1/+2
Currently if the pointer battery is null there is a null pointer dereference on the call to power_supply_put. Fix this by only performing the put if battery is not null. Addresses-Coverity: ("Dereference after null check") Fixes: 4bff91bb3231 ("power: supply: cpcap-charger: Fix missing power_supply_put()") Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-15power: supply: cpcap-battery: constify psy_descSebastian Reichel1-15/+13
There is no dynamic information in cpcap-battery's power-supply description struct, so let's make it static const. Cc: Arthur Demchenkov <spinal.by@gmail.com> Cc: Carl Philipp Klemm <philipp@uvos.xyz> Cc: Merlijn Wajer <merlijn@wizzup.org> Acked-by: Pavel Machek <pavel@ucw.cz> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>