summaryrefslogtreecommitdiff
path: root/drivers/power (unfollow)
Commit message (Collapse)Author
2023-07-16power: smb-lib: Fix mutex acquisition deadlock on PD hard resetUmang Agrawal
Mutex acquisition deadlock can happen while cancelling cc_dettach work during pd_hard_reset from the function usbin_plugin_hard_reset _locked on vbus rise which is called in the same lock context that we try to acquire in the cc_dettach work routine. Check if cc_dettach work is running during pd_hard_reset and use trylock instead of mutex_lock to prevent any deadlock if mutext is already held. Change-Id: I5530deb9e654d3d12ba1b4bc6876f36127a0d5a5 Signed-off-by: Umang Agrawal <uagrawal@codeaurora.org>
2023-06-09power: qpnp-smb2: Implement battery charging_enabled nodeMichael Bestas
Change-Id: Id08c169f0c507390eab070d1ae77bfb992b50b81
2022-11-01fixup! BACKPORT: treewide: Fix function prototypes for module_param_call()Nolen Johnson
Change-Id: Id4056255732a1865e4b97a443ba936a51954e407
2022-07-27power: qpnp-fg: Implement SUPPORT_SOC_SHOW_OPTIMIZATIONDavide Garberi
* Without this the battery is sometimes being reported as charged when it is at 98% or 99% Change-Id: I81e70d1a044c642716b3a920b49f8583c083d4a5
2022-07-27power: qpnp-smbcharger: Limit the charging to 5V for z2_plusDavide Garberi
* Apparently the z2_plus doesn't support this * Thanks YaroST12 for the suggestion Signed-off-by: Davide Garberi <dade.garberi@gmail.com> Change-Id: I820a7eac25c8a437d40885dd36577ccb218e36a0
2022-07-27power: qpnp-fg: Use default DELTA_SOC without rounding the valueBruno Martins
* Using soc_to_setpoint function to determine DELTA_SOC value is resulting into a value of 3, which sometimes causes the battery percentage to instantly drop 2% instead of 1% Change-Id: I56156a51dbd8c67e362fce28e408234bbf6211cb Signed-off-by: Harsh Shandilya <harsh@prjkt.io> Signed-off-by: Yaroslav Furman <yaro330@gmail.com> Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
2022-07-27power: qpnp-smbcharger: init power supply type as USBdukwung.kim
If power supply type is POWER_SUPPLY_TYPE_UNKNOWN at bootup, some userspace apps, such as heathd, fail to parse power supply properties. So, set power supply type to USB when the charger is not plugged during bootup. Change-Id: Iad3881b0fadb36ace6e5f2de6eaeac11f33a532c Signed-off-by: dukwung.kim <dukwung.kim@lge.com> Signed-off-by: choongryeol.lee <choongryeol.lee@lge.com> Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
2022-07-27power: qpnp-smbcharger: Update current_now correctlyLuK1337
* /sys/class/power_supply/battery/current_now wasn't being updated unless device is booted with USB cable connected. Change-Id: Ie55a56943970313b7d6680f8f6c46bc838d40ab6 Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
2022-07-27power: supply: Import minimal edits from zukDavide Garberi
* Re-apply in the new directories for 4.4 Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
2022-07-27cclogic: Add some edits from ZUKDavide Garberi
* Reworked from ZUK sources to make it looks a bit better * Also adapted to 4.4 and moved to the new directory Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
2022-07-27power: reset: msm: Don't use download mode by defaultSultanxda
2022-01-27power: bq25890: Enable continuous conversion for ADC at chargingYauhen Kharuzhy
[ Upstream commit 80211be1b9dec04cc2805d3d81e2091ecac289a1 ] Instead of one shot run of ADC at beginning of charging, run continuous conversion to ensure that all charging-related values are monitored properly (input voltage, input current, themperature etc.). Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-11power: reset: ltc2952: Fix use of floating point literalsNathan Chancellor
commit 644106cdb89844be2496b21175b7c0c2e0fab381 upstream. A new commit in LLVM causes an error on the use of 'long double' when '-mno-x87' is used, which the kernel does through an alias, '-mno-80387' (see the LLVM commit below for more details around why it does this). drivers/power/reset/ltc2952-poweroff.c:162:28: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux-gnu' does not support it data->wde_interval = 300L * 1E6L; ^ drivers/power/reset/ltc2952-poweroff.c:162:21: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux-gnu' does not support it data->wde_interval = 300L * 1E6L; ^ drivers/power/reset/ltc2952-poweroff.c:163:41: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux-gnu' does not support it data->trigger_delay = ktime_set(2, 500L*1E6L); ^ 3 errors generated. This happens due to the use of a 'long double' literal. The 'E6' part of '1E6L' causes the literal to be a 'double' then the 'L' suffix promotes it to 'long double'. There is no visible reason for floating point values in this driver, as the values are only assigned to integer types. Use NSEC_PER_MSEC, which is the same integer value as '1E6L', to avoid changing functionality but fix the error. Fixes: 6647156c00cc ("power: reset: add LTC2952 poweroff driver") Link: https://github.com/ClangBuiltLinux/linux/issues/1497 Link: https://github.com/llvm/llvm-project/commit/a8083d42b1c346e21623a1d36d1f0cadd7801d83 Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> [nathan: Resolve conflict due to lack of 8b0e195314fab] Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-11-26power: supply: rt5033_battery: Change voltage values to µVJakob Hauser
[ Upstream commit bf895295e9a73411889816f1a0c1f4f1a2d9c678 ] Currently the rt5033_battery driver provides voltage values in mV. It should be µV as stated in Documentation/power/power_supply_class.rst. Fixes: b847dd96e659 ("power: rt5033_battery: Add RT5033 Fuel gauge device driver") Cc: Beomho Seo <beomho.seo@samsung.com> Cc: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Jakob Hauser <jahau@rocketmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-11-26power: supply: max17042_battery: use VFSOC for capacity when no rsnsHenrik Grimler
commit 223a3b82834f036a62aa831f67cbf1f1d644c6e2 upstream. On Galaxy S3 (i9300/i9305), which has the max17047 fuel gauge and no current sense resistor (rsns), the RepSOC register does not provide an accurate state of charge value. The reported value is wrong, and does not change over time. VFSOC however, which uses the voltage fuel gauge to determine the state of charge, always shows an accurate value. For devices without current sense, VFSOC is already used for the soc-alert (0x0003 is written to MiscCFG register), so with this change the source of the alert and the PROP_CAPACITY value match. Fixes: 359ab9f5b154 ("power_supply: Add MAX17042 Fuel Gauge Driver") Cc: <stable@vger.kernel.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Suggested-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> Signed-off-by: Henrik Grimler <henrik@grimler.se> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-11-26power: supply: max17042_battery: Prevent int underflow in set_soc_thresholdSebastian Krzyszkowiak
commit e660dbb68c6b3f7b9eb8b9775846a44f9798b719 upstream. max17042_set_soc_threshold gets called with offset set to 1, which means that minimum threshold value would underflow once SOC got down to 0, causing invalid alerts from the gauge. Fixes: e5f3872d2044 ("max17042: Add support for signalling change in SOC") Cc: <stable@vger.kernel.org> Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-22power: supply: max17042: handle fails of reading status registerKrzysztof Kozlowski
commit 54784ffa5b267f57161eb8fbb811499f22a0a0bf upstream. Reading status register can fail in the interrupt handler. In such case, the regmap_read() will not store anything useful under passed 'val' variable and random stack value will be used to determine type of interrupt. Handle the regmap_read() failure to avoid handling interrupt type and triggering changed power supply event based on random stack value. Fixes: 39e7213edc4f ("max17042_battery: Support regmap to access device's registers") Cc: <stable@vger.kernel.org> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-22power: supply: max17042_battery: fix typo in MAx17042_TOFFSebastian Krzyszkowiak
[ Upstream commit ed0d0a0506025f06061325cedae1bbebd081620a ] Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-20power: supply: ab8500: add missing MODULE_DEVICE_TABLEZou Wei
[ Upstream commit dfe52db13ab8d24857a9840ec7ca75eef800c26c ] This patch adds missing MODULE_DEVICE_TABLE definition which generates correct modalias for automatic loading of this driver when it is built as an external module. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Zou Wei <zou_wei@huawei.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-20power: supply: charger-manager: add missing MODULE_DEVICE_TABLEZou Wei
[ Upstream commit 073b5d5b1f9cc94a3eea25279fbafee3f4f5f097 ] This patch adds missing MODULE_DEVICE_TABLE definition which generates correct modalias for automatic loading of this driver when it is built as an external module. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Zou Wei <zou_wei@huawei.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-20power: reset: gpio-poweroff: add missing MODULE_DEVICE_TABLEBixuan Cui
[ Upstream commit ed3443fb4df4e140a22f65144546c8a8e1e27f4e ] This patch adds missing MODULE_DEVICE_TABLE definition which generates correct modalias for automatic loading of this driver when it is built as an external module. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Bixuan Cui <cuibixuan@huawei.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-20power: supply: ab8500: Avoid NULL pointersLinus Walleij
[ Upstream commit 5bcb5087c9dd3dca1ff0ebd8002c5313c9332b56 ] Sometimes the code will crash because we haven't enabled AC or USB charging and thus not created the corresponding psy device. Fix it by checking that it is there before notifying. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-05-22power: supply: s3c_adc_battery: fix possible use-after-free in ↵Yang Yingliang
s3c_adc_bat_remove() [ Upstream commit 68ae256945d2abe9036a7b68af4cc65aff79d5b7 ] This driver's remove path calls cancel_delayed_work(). However, that function does not wait until the work function finishes. This means that the callback function may still be running after the driver's remove function has finished, which would result in a use-after-free. Fix by calling cancel_delayed_work_sync(), which ensures that the work is properly cancelled, no longer running, and unable to re-schedule itself. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-05-22power: supply: generic-adc-battery: fix possible use-after-free in gab_remove()Yang Yingliang
[ Upstream commit b6cfa007b3b229771d9588970adb4ab3e0487f49 ] This driver's remove path calls cancel_delayed_work(). However, that function does not wait until the work function finishes. This means that the callback function may still be running after the driver's remove function has finished, which would result in a use-after-free. Fix by calling cancel_delayed_work_sync(), which ensures that the work is properly cancelled, no longer running, and unable to re-schedule itself. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-12-11qcom: fg-memif: Correct timeout condition for memory grantJishnu Prakash
Correct logic to handle timeout when trying for DMA access. Change-Id: I10e55e542a96b824db9f7b2abd3fef86286eac6b Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
2020-12-11power: qpnp-fg-gen3: Add a property to reset FG BCL deviceAshay Jaiswal
Add support to allow client to request FG to reset BCL device through a power supply property. Change-Id: I7c51adb1e9739c592c28943da8af8219661d38cc Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
2020-12-08power_supply: add FG_RESET_CLOCK propertyAshay Jaiswal
Add FG_RESET_CLOCK property which is used to reset FG clocks. Change-Id: I5c567842a3a59378937db5ddbae59767f2a4f640 Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
2020-11-10power: supply: test_power: add missing newlines when printing parameters by ↵Xiongfeng Wang
sysfs [ Upstream commit c07fa6c1631333f02750cf59f22b615d768b4d8f ] When I cat some module parameters by sysfs, it displays as follows. It's better to add a newline for easy reading. root@syzkaller:~# cd /sys/module/test_power/parameters/ root@syzkaller:/sys/module/test_power/parameters# cat ac_online onroot@syzkaller:/sys/module/test_power/parameters# cat battery_present trueroot@syzkaller:/sys/module/test_power/parameters# cat battery_health goodroot@syzkaller:/sys/module/test_power/parameters# cat battery_status dischargingroot@syzkaller:/sys/module/test_power/parameters# cat battery_technology LIONroot@syzkaller:/sys/module/test_power/parameters# cat usb_online onroot@syzkaller:/sys/module/test_power/parameters# Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-08-21power: supply: check if calc_soc succeeded in pm860x_init_batteryTom Rix
[ Upstream commit ccf193dee1f0fff55b556928591f7818bac1b3b1 ] clang static analysis flags this error 88pm860x_battery.c:522:19: warning: Assigned value is garbage or undefined [core.uninitialized.Assign] info->start_soc = soc; ^ ~~~ soc is set by calling calc_soc. But calc_soc can return without setting soc. So check the return status and bail similarly to other checks in pm860x_init_battery and initialize soc to silence the warning. Fixes: a830d28b48bf ("power_supply: Enable battery-charger for 88pm860x") Signed-off-by: Tom Rix <trix@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-07-23Revert "power: supply: qcom: Remove useless NULL checks against thresh array ↵Michael Bestas
in msm_bcl_enable" This reverts commit e888051ea71eea569dcfd0445bbd672585a39041.
2020-07-10power: qpnp-fg-gen3: Fix warning with llvmKishor Krishna Bhat
Fix Wsizeof-array-div, type cast error when llvm is enabled. Change-Id: Ia01af9b84161ae4cad978d4b652b9e21107d9bbb Signed-off-by: Kishor Krishna Bhat <kishkris@codeaurora.org>
2020-06-29power: supply: smb347-charger: IRQSTAT_D is volatileDmitry Osipenko
[ Upstream commit c32ea07a30630ace950e07ffe7a18bdcc25898e1 ] Fix failure when USB cable is connected: smb347 2-006a: reading IRQSTAT_D failed Fixes: 1502cfe19bac ("smb347-charger: Fix battery status reporting logic for charger faults") Tested-by: David Heidelberg <david@ixit.cz> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: David Heidelberg <david@ixit.cz> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-06-20power: vexpress: add suppress_bind_attrs to trueAnders Roxell
commit 73174acc9c75960af2daa7dcbdb9781fc0d135cb upstream. Make sure that the POWER_RESET_VEXPRESS driver won't have bind/unbind attributes available via the sysfs, so lets be explicit here and use ".suppress_bind_attrs = true" to prevent userspace from doing something silly. Link: https://lore.kernel.org/r/20200527112608.3886105-2-anders.roxell@linaro.org Cc: stable@vger.kernel.org Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-21kernel: Fix build errors with LLVMSwetha Chikkaboraiah
This patch intends to fix compilation errors while building kernel with LLVM toolchain. Change-Id: I76c4f97d8a0efb44434d54fb07cae23b050d2003 Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
2020-05-10power_supply: tps65217-charger: Fix NULL deref during property exportMarcin Niestroj
commit 362761299eea7dfc3a4870551de36e08758b9254 upstream. This bug leads to: [ 1.906411] Unable to handle kernel NULL pointer dereference at virtual address 0000000c [ 1.914878] pgd = c0004000 [ 1.917786] [0000000c] *pgd=00000000 [ 1.921536] Internal error: Oops: 5 [#1] SMP ARM [ 1.926357] Modules linked in: [ 1.929556] CPU: 0 PID: 14 Comm: kworker/0:1 Not tainted 4.4.5 #18 [ 1.936006] Hardware name: Generic AM33XX (Flattened Device Tree) [ 1.942383] Workqueue: events power_supply_changed_work [ 1.947842] task: de2c41c0 ti: de2c8000 task.ti: de2c8000 [ 1.953483] PC is at tps65217_ac_get_property+0x14/0x28 [ 1.958937] LR is at tps65217_ac_get_property+0x10/0x28 Driver was trying to use drv_data in property get handler. However drv_data was not set, so it caused NULL pointer dereference. This patch properly sets drv_data during probe by power_supply_config parameter, so the property get handler works as desired. Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Fixes: 3636859b280c ("power_supply: Add support for tps65217-charger") Signed-off-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-10power: bq27xxx_battery: Fix bq27541 AveragePower register addressLiu Xiang
commit 265b60497a57da56a4be7d5c72983ae89dc0765e upstream. Currently in bq27541 driver, the average power register address is incorrectly set to 0x76, which would result in an error: bq27xxx-battery 2-0055: error reading average power register 10: -11 According to the bq27541 datasheet, fix this problem by setting the average power register address to 0x24. Fixes: d74534c27775 ("power: bq27xxx_battery: Add support for additional bq27xxx family devices") Signed-off-by: Liu Xiang <liu.xiang6@zte.com.cn> Acked-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-10power: test_power: correctly handle empty writesSasha Levin
commit 6b9140f39c2aaf76791197fbab0839c0e4af56e8 upstream. Writing 0 length data into test_power makes it access an invalid array location and kill the system. Fixes: f17ef9b2d ("power: Make test_power driver more dynamic.") Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Signed-off-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-10power: bq27xxx: fix register numbers of bq27500H. Nikolaus Schaller
commit 099867a16a0fa9fd5aafc32e3b1a6f8a90f17834 upstream. bug: according to data sheet some register numbers are wrong. tested: no Fixes: d74534c27775 ("power: bq27xxx_battery: Add support for additional bq27xxx family devices") Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com> Acked-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-10power: bq27xxx: fix reading for bq27000 and bq27010H. Nikolaus Schaller
commit 549d7b317c761dbf4ed0c2945aec3acc9ca7ae14 upstream. bug: the driver reports funny capacity values: root@letux:/sys/class/power_supply/bq27000-battery# cat uevent POWER_SUPPLY_NAME=bq27000-battery POWER_SUPPLY_STATUS=Charging POWER_SUPPLY_PRESENT=1 POWER_SUPPLY_VOLTAGE_NOW=3702000 POWER_SUPPLY_CURRENT_NOW=-464635 POWER_SUPPLY_CAPACITY=1536 <- over 100% is magic POWER_SUPPLY_CAPACITY_LEVEL=Normal POWER_SUPPLY_TEMP=311 POWER_SUPPLY_TIME_TO_FULL_NOW=10440 POWER_SUPPLY_TECHNOLOGY=Li-ion POWER_SUPPLY_CHARGE_FULL=805450 POWER_SUPPLY_CHARGE_NOW=1068 POWER_SUPPLY_CHARGE_FULL_DESIGN=8844998 <- battery has just 1200 mAh POWER_SUPPLY_CYCLE_COUNT=21 POWER_SUPPLY_ENERGY_NOW=0 POWER_SUPPLY_POWER_AVG=0 POWER_SUPPLY_HEALTH=Good POWER_SUPPLY_MANUFACTURER=Texas Instruments reason: the state of charge and the design capacity register are single byte only. The design capacity returns the higer order byte. tested: GTA04 with Openmoko/FIC HF08x battery (using hdq) Fixes: d74534c27775 ("power: bq27xxx_battery: Add support for additional bq27xxx family devices") Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com> Acked-by: Andrew F. Davis <afd@ti.com> Reviewed-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-10power: ipaq-micro-battery: freeing the wrong variableDan Carpenter
commit b9223da41794030a5dfd5106c34ed1b98255e2ae upstream. We accidentally free "micro_ac_power" which is an error pointer and it leads to an oops. We intended to free "micro_batt_power". Fixes: a2c1d531854c ('power_supply: ipaq_micro_battery: Check return values in probe') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-18power: power_supply: Add property for capping parallel FCCGuru Das Srinagesh
Add a power supply property to expose the upper limit on the charging current that the parallel charger can supply. This is different from POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX in that the latter is meant for querying the hardware-defined value, while this new property is meant to be used to restrict the parallel's share of FCC to its specified limit much like in SMB1354, for instance. CRs-Fixed: 2170280 Change-Id: I3a6ed44fbafe0eff4ecc9462bdf9a35f34811d8c Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
2020-04-18power_supply: add POWER_SUPPLY_PROP_(BATFET_MODE/MIN_CIL) propertiesAshay Jaiswal
Add power_supply properties to expose parallel charger configuration. POWER_SUPPLY_PROP_BATFET_MODE property exposes BATFET configuration of parallel charger and POWER_SUPPLY_PROP_MIN_ICL property exposes minimum ICL configuration required by parallel charger. Change-Id: I477789b4ea9dd56ac34606b00566f46aa6f84aa5 Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
2020-04-13power: supply: axp288_charger: Fix unchecked return valueGustavo A. R. Silva
commit c3422ad5f84a66739ec6a37251ca27638c85b6be upstream. Currently there is no check on platform_get_irq() return value in case it fails, hence never actually reporting any errors and causing unexpected behavior when using such value as argument for function regmap_irq_get_virq(). Fix this by adding a proper check, a message reporting any errors and returning *pirq* Addresses-Coverity-ID: 1443940 ("Improper use of negative value") Fixes: 843735b788a4 ("power: axp288_charger: axp288 charger driver") Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Nobuhiro Iwamatsu (CIP) <nobuhiro1.iwamatsu@toshiba.co.jp>
2020-02-14power: supply: ltc2941-battery-gauge: fix use-after-freeSven Van Asbroeck
commit a60ec78d306c6548d4adbc7918b587a723c555cc upstream. This driver's remove path calls cancel_delayed_work(). However, that function does not wait until the work function finishes. This could mean that the work function is still running after the driver's remove function has finished, which would result in a use-after-free. Fix by calling cancel_delayed_work_sync(), which ensures that that the work is properly cancelled, no longer running, and unable to re-schedule itself. This issue was detected with the help of Coccinelle. Cc: stable <stable@vger.kernel.org> Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-02-02power: qpnp-fg-gen3: Silence an instance of -Wsizeof-array-div in ↵Nathan Chancellor
clear_cycle_counter Clang warns: ../drivers/power/supply/qcom/qpnp-fg-gen3.c:2611:32: warning: expression does not compute the number of elements in this array; element type is 'u16' (aka 'unsigned short'), not 'u8 *' (aka 'unsigned char *') [-Wsizeof-array-div] sizeof(chip->cyc_ctr.count) / sizeof(u8 *), ~~~~~~~~~~~~~~~~~~~ ^ ../drivers/power/supply/qcom/qpnp-fg-gen3.c:2611:32: note: place parentheses around the 'sizeof(u8 *)' expression to silence this warning 1 warning generated. Odds are this is intentional given the casting so silence the warning. Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2020-02-02power: supply: qcom: Remove useless NULL checks against thresh array in ↵Nathan Chancellor
msm_bcl_enable Clang warns: ../drivers/power/supply/qcom/msm_bcl.c:230:42: warning: address of array 'bcl[BCL_PARAM_VOLTAGE]->thresh' will always evaluate to 'true' [-Wpointer-bool-conversion] if (!bcl[i] || !bcl[BCL_PARAM_VOLTAGE]->thresh ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ ../drivers/power/supply/qcom/msm_bcl.c:231:31: warning: address of array 'bcl[BCL_PARAM_CURRENT]->thresh' will always evaluate to 'true' [-Wpointer-bool-conversion] || !bcl[BCL_PARAM_CURRENT]->thresh) { ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ 2 warnings generated. Fixes: 77dd35597191 ("qpnp: Add snapshot of some qpnp, regulator and charger drivers") Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2020-01-29power: supply: Init device wakeup after device_add()Stephen Boyd
[ Upstream commit 8288022284859acbcc3cf1a073a1e2692d6c2543 ] We may want to use the device pointer in device_init_wakeup() with functions that expect the device to already be added with device_add(). For example, if we were to link the device initializing wakeup to something in sysfs such as a class for wakeups we'll run into an error. It looks like this code was written with the assumption that the device would be added before initializing wakeup due to the order of operations in power_supply_unregister(). Let's change the order of operations so we don't run into problems here. Fixes: 948dcf966228 ("power_supply: Prevent suspend until power supply events are processed") Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Tri Vo <trong@android.com> Cc: Kalesh Singh <kaleshsingh@google.com> Cc: Ravi Chandra Sadineni <ravisadineni@chromium.org> Cc: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-12-23power: reset: Move in_panic handling out of dload modeMichael Bestas
* Some devices might want to use that logic without enabling download mode Change-Id: Idd4a2cc8a47041740f8d4e9f43bffd84fae5830d
2019-12-23power_supply: Fix unbalanced the power suppliesjonghyun26.kim
If a driver invokes multiple power_supply_register(), the each supply will not be saved in the supplied_from[] with the correct index. supplied_from[0] = "dc" num_supplies = 1; supplied_from[0] = "usb" num_supplies = 2; supplied_from[0] = "battery" num_supplies = 3; ... It results in NPE when iterating the supplied_from[] with num_supplies on __power_supply_is_supplied_by() Bug: 63785418 Change-Id: Ifd14ca7c6e2df247e1090e4fa8d8c66bd2912180 Signed-off-by; Devin Kim <dojip.kim@lge.com> Signed-off-by: Steve Pfetsch <spfetsch@google.com>
2019-12-23Fix bugs about step-chg-jeitaEssential kernel team
1. JEITA FV compensation cannot work 2. Cannot charge when battery capacity is 0% 3. Wrong debug message Change-Id: I32ecb77b4c1dd8073cbf5aec070c3e6fcadc1dd2