summaryrefslogtreecommitdiffstats
path: root/drivers/power/supply
AgeCommit message (Collapse)AuthorFilesLines
2021-07-13power: supply: Fix fall-through warnings for ClangGustavo A. R. Silva2-0/+3
Fix the following fallthrough warnings: drivers/power/supply/ab8500_fg.c:1730:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] drivers/power/supply/abx500_chargalg.c:1155:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] Reported-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2021-06-30power: supply: ab8500: Fix an old bugLinus Walleij1-1/+1
Trying to get the AB8500 charging driver working I ran into a bit of bitrot: we haven't used the driver for a while so errors in refactorings won't be noticed. This one is pretty self evident: use argument to the macro or we end up with a random pointer to something else. Cc: stable@vger.kernel.org Cc: Krzysztof Kozlowski <krzk@kernel.org> Cc: Marcus Cooper <codekipper@gmail.com> Fixes: 297d716f6260 ("power_supply: Change ownership from driver to core") Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-30power: supply: axp288_fuel_gauge: remove redundant continue statementColin Ian King1-3/+1
The continue statement at the end of a for-loop has no effect, invert the if expression and remove the continue. Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-30power: supply: axp288_fuel_gauge: Make "T3 MRD" no_battery_list DMI entry ↵Hans de Goede1-9/+9
more generic It turns out that the "T3 MRD" DMI_BOARD_NAME value is used in a lot of different Cherry Trail x5-z8300 / x5-z8350 based Mini-PC / HDMI-stick models from Ace PC / Meegopad / MinisForum / Wintel (and likely also other vendors). Most of the other DMI strings on these boxes unfortunately contain various generic values like "Default string" or "$(DEFAULT_STRING)", so we cannot match on them. These devices do have their chassis-type correctly set to a value of "3" (desktop) which is a pleasant surprise, so also match on that. This should avoid the quirk accidentally also getting applied to laptops / tablets (which do actually have a battery). Although in my quite large database of Bay and Cherry Trail based devices DMIdecode dumps I don't have any laptops / tables with a board-name of "T3 MRD", so this should not be an issue. BugLink: https://askubuntu.com/questions/1206714/how-can-a-mini-pc-be-stopped-from-being-detected-as-a-laptop-with-a-battery/ Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-30power: supply: axp288_fuel_gauge: Rename fuel_gauge_blacklist to no_battery_listHans de Goede1-2/+2
As documented in the updated "Naming" chapter of Documentation/process/coding-style.rst, usage of the work blacklist should be avoided where possible. Rename the list of devices which have no battery to the axp288_no_battery_list, which also more accurately describes the contents of the list. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-30power: supply: bq24190_charger: drop of_match_ptr() from device ID tableAndy Shevchenko1-9/+2
The driver can match only via the DT table so the table should be always used and the of_match_ptr() does not have any sense (this also allows ACPI matching via PRP0001, even though it might be not relevant here). This fixes compile warning (!CONFIG_OF): drivers/power/supply/bq24190_charger.c:1972:34: warning: ‘bq24190_of_match’ defined but not used [-Wunused-const-variable=] Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-30power: supply: ab8500: add missing MODULE_DEVICE_TABLEZou Wei3-0/+3
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>
2021-06-29power: supply: charger-manager: add missing MODULE_DEVICE_TABLEZou Wei1-0/+1
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>
2021-06-29Merge branch 'psy-fixes' into psy-nextSebastian Reichel2-3/+13
2021-06-04power: supply: cpcap-charger: get the battery inserted infomation from ↵Carl Philipp Klemm1-19/+20
cpcap-battery This avoids reimplementing the detection logic twice and removes the possibility of activating charging with 500mA even if a battery is not detected. Signed-off-by: Carl Philipp Klemm <philipp@uvos.xyz> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-04power: supply: cpcap-battery: invalidate config when incompatible ↵Carl Philipp Klemm1-3/+16
measurements are read This invalidates empty->counter_uah and charge_full when charge_now indicates that they are grossly wrong and adds some tolerance to POWER_SUPPLY_PROP_CHARGE_FULL to allow for inaccuracies in the charge counter and manufacturing tolerances in the battery. Signed-off-by: Carl Philipp Klemm <philipp@uvos.xyz> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-04power: supply: axp20x_battery: allow disabling battery chargingHermann Lauer1-2/+15
Allow disabling and re-enabling battery charging of an axp209 PMIC through a writable status property. With the current driver code charging is always on. This works on the axp209 of Banana {Pi M1+,Pro} and should work on all AXP chips. Signed-off-by: Hermann.Lauer@uni-heidelberg.de Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-04power: supply: max17040: drop unused platform data supportKrzysztof Kozlowski1-3/+0
There are no platforms using the driver with platform data (no board files with the driver), so the dead code can be dropped. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-04power: supply: max17040: simplify POWER_SUPPLY_PROP_ONLINEKrzysztof Kozlowski1-2/+1
The driver was reporting POWER_SUPPLY_PROP_ONLINE via platform data functions or '1' if no platform data was provided. Since there are no platforms using the driver with platform data (no board files with the driver), the online property can be simplified to always return '1'. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-04power: supply: max17040: remove non-working POWER_SUPPLY_PROP_STATUSKrzysztof Kozlowski1-29/+3
The driver was reporting POWER_SUPPLY_PROP_STATUS via platform data functions. Without platform data, the max17040_get_status() functions returns early with POWER_SUPPLY_STATUS_UNKNOWN. Since there are no platforms using the driver with platform data (no board files with the driver), the status property was always unknown. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-04power: supply: rt5033_battery: Fix device tree enumerationStephan Gerhold2-1/+9
The fuel gauge in the RT5033 PMIC has its own I2C bus and interrupt line. Therefore, it is not actually part of the RT5033 MFD and needs its own of_match_table to probe properly. Also, given that it's independent of the MFD, there is actually no need to make the Kconfig depend on MFD_RT5033. Although the driver uses the shared <linux/mfd/rt5033.h> header, there is no compile or runtime dependency on the RT5033 MFD driver. Cc: Beomho Seo <beomho.seo@samsung.com> Cc: Chanwoo Choi <cw00.choi@samsung.com> Fixes: b847dd96e659 ("power: rt5033_battery: Add RT5033 Fuel gauge device driver") Signed-off-by: Stephan Gerhold <stephan@gerhold.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-04power: supply: Drop BD70528 supportMatti Vaittinen3-720/+0
The only known BD70528 use-cases are such that the PMIC is controlled from separate MCU which is not running Linux. I am not aware of any Linux driver users. Furthermore, it seems there is no demand for this IC. Let's ease the maintenance burden and drop the driver. We can always add it back if there is sudden need for it. Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-04power: supply: max17040: Do not enforce (incorrect) interrupt trigger typeKrzysztof Kozlowski1-3/+1
Interrupt line can be configured on different hardware in different way, even inverted. Therefore driver should not enforce specific trigger type - edge falling - but instead rely on Devicetree to configure it. The Maxim 14577/77836 datasheets describe the interrupt line as active low with a requirement of acknowledge from the CPU therefore the edge falling is not correct. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Acked-by: Iskren Chernev <iskren.chernev@gmail.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-04power: supply: max17042: Do not enforce (incorrect) interrupt trigger typeKrzysztof Kozlowski1-1/+1
Interrupt line can be configured on different hardware in different way, even inverted. Therefore driver should not enforce specific trigger type - edge falling - but instead rely on Devicetree to configure it. The Maxim 17047/77693 datasheets describe the interrupt line as active low with a requirement of acknowledge from the CPU therefore the edge falling is not correct. The interrupt line is shared between PMIC and RTC driver, so using level sensitive interrupt is here especially important to avoid races. With an edge configuration in case if first PMIC signals interrupt followed shortly after by the RTC, the interrupt might not be yet cleared/acked thus the second one would not be noticed. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-03power: supply: surface-charger: Fix type of integer variableMaximilian Luz1-1/+1
The ac->state field is __le32, not u32. So change the variable we're temporarily storing it in to __le32 as well. Reported-by: kernel test robot <lkp@intel.com> Fixes: e61ffb344591 ("power: supply: Add AC driver for Surface Aggregator Module") Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-03power: supply: sbs-battery: cache constant string propertiesIkjoon Jang1-58/+95
Currently sbs-battery supports three string properties - manufacturer, model_name, and chemistry. Buffers for those properties are currently defined as global variables. This patch moves those global variables into struct sbs_info and cache/reuse them as they are all constant values. Signed-off-by: Ikjoon Jang <ikjn@chromium.org> Tested-by: Hsin-Yi Wang <hsinyi@chromium.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-03power: supply: rn5t618: Add input current limitAndreas Kemnade1-0/+188
Adds properties for setting the maximum current to USB, ADP and Battery supplies. USB and ADP limits are reset to OTP values upon replugging. Signed-off-by: Andreas Kemnade <andreas@kemnade.info> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-03power: supply: rn5t618: Add charger type detectionAndreas Kemnade1-0/+47
The RC5T619 can detect SDP, CDP and DCP chargers, so let's add support for it. Signed-off-by: Andreas Kemnade <andreas@kemnade.info> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-03power: supply: smb347-charger: Drop unused includeLinus Walleij1-1/+0
This driver is including the legacy GPIO header <linux/gpio.h> but not using any symbols from it. Delete the include. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: David Heidelberg <david@ixit.cz> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-03power: supply: pm2301_charger: Delete driverLinus Walleij2-1250/+1
The PM2301 was only used in tandem with AB9540, part of U9540, a platform that was cancelled and never deployed in products. Delete it. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-03power: supply: ab8500: Drop unnecessary NULL check after container_ofGuenter Roeck1-3/+0
The result of container_of() operations is never NULL unless the element is the first element of the embedded structure, which is not the case here. The NULL check is therefore unnecessary and misleading. Remove it. This change was made automatically with the following Coccinelle script. @@ type t; identifier v; statement s; @@ <+... ( t v = container_of(...); | v = container_of(...); ) ... when != v - if (\( !v \| v == NULL \) ) s ...+> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-03power: supply: ab8500: Drop unused memberLinus Walleij1-1/+0
This setting is read directly from the device tree in the ab8500_charger.c code. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-03power: supply: ab8500: Enable USB and ACLinus Walleij2-12/+14
The vendor code tree supplies platform data to enable he USB charging for AB8500 and AB8500 and disable the AC charging on the AB8505. This was missed when the driver was submitted to the mainline kernel. Fix this by doing what the vendor kernel does: always register the USB charger, do not register the AC charger on the AB8505. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-03power: supply: ab8500: Avoid NULL pointersLinus Walleij1-1/+17
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>
2021-06-03power: supply: ab8500: Call battery population onceLinus Walleij3-20/+0
The code was calling ab8500_bm_of_probe() in four different spots effectively overwriting the same configuration three times. This was done because probe order was uncertain. Since we now used componentized probe, call it only once while probing the main charging component. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-03power: supply: ab8500: Move to componentized bindingLinus Walleij5-334/+379
The driver has problems with the different components of the charging code racing with each other to probe(). This results in all four subdrivers populating battery information to ascertain that it is populated for their own needs for example. Fix this by using component probing and thus expressing to the kernel that these are dependent components. The probes can happen in any order and will only acquire resources such as state container, regulators and interrupts and initialize the data structures, but no execution happens until the .bind() callback is called. The charging driver is the main component and binds first, then bind in order the three subcomponents: ab8500-fg, ab8500-btemp and ab8500-chargalg. Do some housekeeping while we are moving the code around. Like use devm_* for IRQs so as to cut down on some boilerplate. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-06-03power: supply: ab8500: Fix typoJian Xin1-1/+1
fix misspelled 'interrupts' Signed-off-by: Jian Xin <xinjian@yulong.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-05-13power: supply: surface_battery: Fix battery event handlingMaximilian Luz1-2/+12
The battery subsystem of the Surface Aggregator Module EC requires us to register the battery notifier with instance ID 0. However, battery events are actually sent with the instance ID corresponding to the device, which is nonzero. Thus, the strict-matching approach doesn't work here and will discard events that the driver is expected to handle. To fix this we have to fall back on notifier matching by target-category only and have to manually check the instance ID in the notifier callback. Fixes: 167f77f7d0b3 ("power: supply: Add battery driver for Surface Aggregator Module") Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-05-13power: supply: sc2731_charger: Add missing MODULE_DEVICE_TABLEZou Wei1-0/+1
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>
2021-05-13power: supply: sc27xx: Add missing MODULE_DEVICE_TABLEZou Wei1-0/+1
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>
2021-04-28Merge tag 'for-v5.13' of ↵Linus Torvalds40-350/+2275
git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply Pull power supply and reset updates from Sebastian Reichel: "battery/charger driver changes: - core: - provide function stubs if CONFIG_POWER_SUPPLY=n - reduce loglevel for probe defer info - surface: - new battery and charger drivers for Surface - bq27xxx: - add bq78z100 support - fix current_now/power_avg for newer chips - cw2015: - add CHARGE_NOW support - ab8500: - drop pdata support - convert most DT bindings to YAML - lots of minor fixes and cleanups reset drivers: - ltc2952-poweroff: - make trigger delay configurable from DT - minor fixes and cleanups" * tag 'for-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (97 commits) power: supply: cpcap-battery: fix invalid usage of list cursor power: supply: bq256xx: add kerneldoc for structure members power: supply: act8945a: correct kerneldoc power: supply: max17040: remove unneeded double cast power: supply: max17040: handle device_property_read_u8_array() failure power: supply: max14577: remove unneeded variable initialization power: supply: surface-charger: Make symbol 'surface_ac_pm_ops' static power: supply: surface-battery: Make some symbols static power: reset: restart-poweroff: Add missing MODULE_DEVICE_TABLE power: reset: hisi-reboot: add missing MODULE_DEVICE_TABLE power: supply: s3c_adc_battery: fix possible use-after-free in s3c_adc_bat_remove() power: supply: generic-adc-battery: fix possible use-after-free in gab_remove() power: supply: Add AC driver for Surface Aggregator Module power: supply: Add battery driver for Surface Aggregator Module power: supply: bq25980: Move props from battery node power: supply: core: Use true and false for bool variable power: supply: goldfish: Remove the GOLDFISH dependency power: reset: ltc2952: make trigger delay configurable power: supply: cpcap-charger: Simplify bool conversion power: supply: cpcap-charger: Add usleep to cpcap charger to avoid usb plug bounce ...
2021-04-21power: supply: cpcap-battery: fix invalid usage of list cursorGuangqing Zhu1-1/+1
Fix invalid usage of a list_for_each_entry in cpcap_battery_irq_thread(). Empty list or fully traversed list points to list head, which is not NULL (and before the first element containing real data). Signed-off-by: Guangqing Zhu <zhuguangqing83@gmail.com> Reviewed-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Carl Philipp Klemm <philipp@uvos.xyz> Tested-by: Carl Philipp Klemm <philipp@uvos.xyz> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-20power: supply: bq256xx: add kerneldoc for structure membersKrzysztof Kozlowski1-0/+2
Document members of structure to fix W=1 warnings like: drivers/power/supply/bq256xx_charger.c:240: warning: Function parameter or member 'charger' not described in 'bq256xx_device' Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-20power: supply: act8945a: correct kerneldocKrzysztof Kozlowski1-1/+1
Remove incorrect kerneldoc marker to fix W=1 warning: drivers/power/supply/act8945a_charger.c:22: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-20power: supply: max17040: remove unneeded double castKrzysztof Kozlowski1-2/+1
There is no need for double explicit cast from of_device_get_match_data() (uintptr_t and then to target enum) because implicit conversion from uintptr_t to enum is straightforward (uintptr_t is a integer type). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-20power: supply: max17040: handle device_property_read_u8_array() failureKrzysztof Kozlowski1-5/+4
The device_property_read_u8_array() call should not fail because it is preceded with device_property_count_u8() and check for number of readable u8 values. However the code is more obvious and easier to read if the return value of device_property_read_u8_array() is checked. Otherwise reader needs to investigate whether really there is no risk of using random stack values of 'rcomp' variable. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-20power: supply: max14577: remove unneeded variable initializationKrzysztof Kozlowski1-1/+1
The local 'current_bits' variable does not have to be initialized because all cases in following switch() either return or initialize it. Addresses-Coverity: Unused value Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-12power: supply: surface-charger: Make symbol 'surface_ac_pm_ops' staticQiheng Lin1-1/+1
The sparse tool complains as follows: drivers/power/supply/surface_charger.c:229:1: warning: symbol 'surface_ac_pm_ops' was not declared. Should it be static? This symbol is not used outside of surface_charger.c, so this commit marks it static. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Qiheng Lin <linqiheng@huawei.com> Acked-by: Maximilian Luz <luzmaximilian@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-12power: supply: surface-battery: Make some symbols staticQiheng Lin1-2/+2
The sparse tool complains as follows: drivers/power/supply/surface_battery.c:700:1: warning: symbol 'dev_attr_alarm' was not declared. Should it be static? drivers/power/supply/surface_battery.c:805:1: warning: symbol 'surface_battery_pm_ops' was not declared. Should it be static? This symbol is not used outside of surface_battery.c, so this commit marks it static. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Qiheng Lin <linqiheng@huawei.com> Acked-by: Maximilian Luz <luzmaximilian@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-08power: supply: s3c_adc_battery: fix possible use-after-free in ↵Yang Yingliang1-1/+1
s3c_adc_bat_remove() 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>
2021-04-08power: supply: generic-adc-battery: fix possible use-after-free in gab_remove()Yang Yingliang1-1/+1
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>
2021-04-08power: supply: Add AC driver for Surface Aggregator ModuleMaximilian Luz3-0/+299
On newer Microsoft Surface models (specifically 7th-generation, i.e. Surface Pro 7, Surface Book 3, Surface Laptop 3, and Surface Laptop Go), battery and AC status/information is no longer handled via standard ACPI devices, but instead directly via the Surface System Aggregator Module (SSAM), i.e. the embedded controller on those devices. While on previous generation models, AC status is also handled via SSAM, an ACPI shim was present to translate the standard ACPI AC interface to SSAM requests. The SSAM interface itself, which is modeled closely after the ACPI interface, has not changed. This commit introduces a new SSAM client device driver to support AC status/information via the aforementioned interface on said Surface models. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-08power: supply: Add battery driver for Surface Aggregator ModuleMaximilian Luz3-0/+882
On newer Microsoft Surface models (specifically 7th-generation, i.e. Surface Pro 7, Surface Book 3, Surface Laptop 3, and Surface Laptop Go), battery and AC status/information is no longer handled via standard ACPI devices, but instead directly via the Surface System Aggregator Module (SSAM), i.e. the embedded controller on those devices. While on previous generation models, battery status is also handled via SSAM, an ACPI shim was present to translate the standard ACPI battery interface to SSAM requests. The SSAM interface itself, which is modeled closely after the ACPI interface, has not changed. This commit introduces a new SSAM client device driver to support battery status/information via the aforementioned interface on said Surface models. It is in parts based on the standard ACPI battery driver. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-05power: supply: bq25980: Move props from battery nodeRicardo Rivera-Matos1-28/+12
Currently POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT and POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE are exposed on the battery node and this is incorrect. This patch exposes both of them on the charger node rather than the battery node. Fixes: 5069185fc18e ("power: supply: bq25980: Add support for the BQ259xx family") Signed-off-by: Ricardo Rivera-Matos <r-rivera-matos@ti.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-05Merge tag 'ib-mfd-power-v5.13' into psy-nextSebastian Reichel9-85/+822
Immutable branch between MFD and Power due for the v5.13 merge window. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>