Commit graph

3523 commits

Author SHA1 Message Date
Linus Torvalds
323bbfcf1e Convert 'alloc_flex' family to use the new default GFP_KERNEL argument
This is the exact same thing as the 'alloc_obj()' version, only much
smaller because there are a lot fewer users of the *alloc_flex()
interface.

As with alloc_obj() version, this was done entirely with mindless brute
force, using the same script, except using 'flex' in the pattern rather
than 'objs*'.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-02-21 17:09:51 -08:00
Linus Torvalds
bf4afc53b7 Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
This was done entirely with mindless brute force, using

    git grep -l '\<k[vmz]*alloc_objs*(.*, GFP_KERNEL)' |
        xargs sed -i 's/\(alloc_objs*(.*\), GFP_KERNEL)/\1)/'

to convert the new alloc_obj() users that had a simple GFP_KERNEL
argument to just drop that argument.

Note that due to the extreme simplicity of the scripting, any slightly
more complex cases spread over multiple lines would not be triggered:
they definitely exist, but this covers the vast bulk of the cases, and
the resulting diff is also then easier to check automatically.

For the same reason the 'flex' versions will be done as a separate
conversion.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-02-21 17:09:51 -08:00
Kees Cook
69050f8d6d treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from
scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to
avoid scalar types (which need careful case-by-case checking), and
instead replace kmalloc-family calls that allocate struct or union
object instances:

Single allocations:	kmalloc(sizeof(TYPE), ...)
are replaced with:	kmalloc_obj(TYPE, ...)

Array allocations:	kmalloc_array(COUNT, sizeof(TYPE), ...)
are replaced with:	kmalloc_objs(TYPE, COUNT, ...)

Flex array allocations:	kmalloc(struct_size(PTR, FAM, COUNT), ...)
are replaced with:	kmalloc_flex(*PTR, FAM, COUNT, ...)

(where TYPE may also be *VAR)

The resulting allocations no longer return "void *", instead returning
"TYPE *".

Signed-off-by: Kees Cook <kees@kernel.org>
2026-02-21 01:02:28 -08:00
Linus Torvalds
7563f7e0e9 power supply and reset changes for the 7.0 series
* power-supply core
   - sysfs: Constify pointer passed to dev_attr_psp
   - extend DT binding documentation for battery cells to allow
     describing voltage drop behaviour
  * power-supply drivers
   - multiple: Remove unused gpio include header
   - multiple: Fix potential IRQ use-after-free on driver unload
   - bd71828: Add support for ROHM BD72720
   - misc. small fixes
  * reset drivers
   - tdx-ec-poweroff: fix restart
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmmOWCwACgkQ2O7X88g7
 +ppKvRAAkOUnzB2XBNuFUo7lF5menrccueob0oDKFXqrOM4TEtByMQBcxYCU0Li7
 eYIWt1XlcjNJ2rvQfgbVAKWBp5aKAWlizH8f4Q1Z/1GTxKNrCAZdGF0ARsW+0l4Q
 mVOXZa/2FAD/zfV+xrHKZV0x0NWnMjaZPgsRFq1Gvc7Q+Fs11S8UvK266wjIzF5w
 3T9tAJapEcXgd9OpQSTJr898GI09tJLLbJLFNGeHY5+l+nzmCvL8gZWGDPxdDPEj
 c4EhTMfhQr4uJsFxwdPGdaLxWaYlGWMR+Ji/AA+56QuK1F3DekpTZWpPIh2loPgo
 A8cVNaOrusCA/8ZmaTTsSvTzgkj/sttXwV2CvSa0TyY7EaET3TZAwZVgvYEunmj6
 TJHIizRc/jPf+yoHMF9d9iEfgtaxUmbtzJ3KWF/Tt89vxZ0CxCvxeUYTELRiJkJz
 iXBmDlhfmoMBJlh76ULZr36tEytDc2UG6cLr812qjtMhkza9QZkWn8HF7lny9rZy
 df/uUzcfA4lLVu/XPEUo7KDYyx2Pd2T61nC0lsCgmExe46bjP9HLdLVUKHX8GCVA
 5/sqeLViUMqsKk32L3+zOeMGPPHd/qUlq0ItFDuqsaHEHxwFruFEU0Q2a3wAXvcI
 J2tQ4lhnxM5N5DNTL2QeAl2DxDzVUehxAxJQiXNJu9lDjh08wxw=
 =HkTZ
 -----END PGP SIGNATURE-----

Merge tag 'for-v7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply

Pull power supply and reset updates from Sebastian Reichel:
 "power-supply core:
   - sysfs: constify pointer passed to dev_attr_psp
   - extend DT binding documentation for battery cells to allow
     describing voltage drop behaviour

  power-supply drivers:
   - multiple: Remove unused gpio include header
   - multiple: Fix potential IRQ use-after-free on driver unload
   - bd71828: Add support for ROHM BD72720
   - misc small fixes

  reset drivers:
   - tdx-ec-poweroff: fix restart"

* tag 'for-v7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (30 commits)
  power: supply: bd71828: Use dev_err_probe()
  dt-bindings: power: supply: google,goldfish-battery: Convert to DT schema
  power: supply: qcom_battmgr: Recognize "LiP" as lithium-polymer
  power: supply: wm97xx: Use devm_power_supply_register()
  power: supply: wm97xx: Use devm_kcalloc()
  power: supply: pm8916_lbc: Fix use-after-free for extcon in IRQ handler
  power: reset: tdx-ec-poweroff: fix restart
  docs: power: update documentation about removed function
  power: supply: wm97xx: Fix NULL pointer dereference in power_supply_changed()
  MAINTAINERS: adjust file entry in ROHM BD71828 CHARGER
  power: supply: ab8500_chargalg: improve kernel-doc
  power: supply: sysfs: Constify pointer passed to dev_attr_psp()
  power: supply: bq27xxx: fix wrong errno when bus ops are unsupported
  power: reset: nvmem-reboot-mode: respect cell size for nvmem_cell_write
  power: supply: sbs-battery: Fix use-after-free in power_supply_changed()
  power: supply: rt9455: Fix use-after-free in power_supply_changed()
  power: supply: pm8916_lbc: Fix use-after-free in power_supply_changed()
  power: supply: pm8916_bms_vm: Fix use-after-free in power_supply_changed()
  power: supply: pf1550: Fix use-after-free in power_supply_changed()
  power: supply: goldfish: Fix use-after-free in power_supply_changed()
  ...
2026-02-12 18:24:37 -08:00
Linus Torvalds
d701782152 gpio updates for v7.0-rc1
GPIOLIB core:
 - shrink the GPIO bus driver stub code
 - rework software node support for "undefined" software nodes
 - provide and use devm_fwnode_gpiod_get_optional()
 - only compile the OF quirk for MT2701 when needed
 
 New drivers:
 - add the GPIO driver for ROHM bd72720
 - add the gpio-line-mux driver providing 1-to-many mapping for a single
   real GPIO
 
 Driver changes:
 - refactor gpio-pca9570: use lock guard, add missing headers, use devres
   consistently
 - add support for a new model (G7 Aspeed sgpiom) to the aspeed-sgpio driver
   along with some prerequisite refactoring
 - use device_get_match_data() where applicable and save some lines
 - add support for more models to gpio-cadence
 - add the compatible property to reset-gpio and use it in shared GPIO
   management
 - drop unnecessary use of irqd_get_trigger_type() in gpio-max77759
 - add support for a new variant to gpio-pca953x
 - extend build coverage with COMPILE_TEST for more drivers
 - constify configfs structures in gpio-sim and gpio-virtuser
 - add support for the K3 SoC to gpio-spacemit
 - implement the missing .get_direction() callback in gpio-max77620
 - add support for Tegra264 to gpio-tegra186
 - drop unneeded MODULE_ALIAS() from gpio-menz127
 
 DT bindings:
 - document support for the opencores GPIO controller in gpio-mmio
 - document new variants for gpio-pca953x
 
 Documentation:
 - extensively describe interrupt source detection for gpio-pca953x and
   add more models to the list of supported variants
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEkeUTLeW1Rh17omX8BZ0uy/82hMMFAmmK9bwACgkQBZ0uy/82
 hMM3rQ/7BTRmMgGiJXlDpqkUoA9fQusiEcokwgmpvlJFM3cb2ANzrjxqZDGnUVLS
 OFaVCPjgUTDrmWNgSSy5SBfyfVkvbXmT7X5+e38qotlNun6BKCPhF1H5HxBgJv9P
 ObHXZ6ACrg4Ia+jl0QkpIXUDC/vAzaBUml5LUATGHpwf/pa4ZcBDXXbLIEtEfSpb
 kNDDQVeWJlWxDYNuJudR8BL2saZFEoD9RaX8F4jLya8ogecoKXElK8Nj0G0Gua8D
 UkH9aKMlNTIrk/iE6MiohaLWWqBgRV6+wO6vd2IRek5iItTbPffk4iT2/dOiX8H4
 HcOxXBxACH/+wicXGwY360r5M5BCYaMcUvLQaCxLuac2T4302aFLcrWH7be+Ju6f
 F+rPBRK1LTYwn0LNlu1I7hYBbwNWHCXfWejXXTH4pMO4uyiwCPpkBHXWCyjWSTuV
 YhIbWVYuQjVgxvPCoJ0+67ju++I2ShlXtiT6NorQrxGt9CCBzMN4KU/uMPkN5j+Z
 RgurHuEEB1hZ8h5Tzs058L6Pxfyp4eY6Qy8BKLPcrGZaKvvX/EZeI/JkeQOOItKe
 VoVq4NIeeqYmqzFa5xrsRYnGUw6lKVj2M5SrjRfbGRz4xVX+rSgrBZMrz1gJyisP
 1M5LiGj+c91oo41tysJdPjkc8dkN47hFbNLzB27kXDfm77qlbUE=
 =Zhuy
 -----END PGP SIGNATURE-----

Merge tag 'gpio-updates-for-v7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio updates from Bartosz Golaszewski:
 "There are two new drivers and some changes to GPIO core but mostly
  just GPIO driver updates across a wide array of files, adding support
  for new models as well as various refactoring changes. Nothing
  controversial and everything has spent a good measure of time in
  linux-next.

  GPIOLIB core:
   - shrink the GPIO bus driver stub code
   - rework software node support for "undefined" software nodes
   - provide and use devm_fwnode_gpiod_get_optional()
   - only compile the OF quirk for MT2701 when needed

  New drivers:
   - add the GPIO driver for ROHM bd72720
   - add the gpio-line-mux driver providing 1-to-many mapping for a
     single real GPIO

  Driver changes:
   - refactor gpio-pca9570: use lock guard, add missing headers, use
     devres consistently
   - add support for a new model (G7 Aspeed sgpiom) to the aspeed-sgpio
     driver along with some prerequisite refactoring
   - use device_get_match_data() where applicable and save some lines
   - add support for more models to gpio-cadence
   - add the compatible property to reset-gpio and use it in shared GPIO
     management
   - drop unnecessary use of irqd_get_trigger_type() in gpio-max77759
   - add support for a new variant to gpio-pca953x
   - extend build coverage with COMPILE_TEST for more drivers
   - constify configfs structures in gpio-sim and gpio-virtuser
   - add support for the K3 SoC to gpio-spacemit
   - implement the missing .get_direction() callback in gpio-max77620
   - add support for Tegra264 to gpio-tegra186
   - drop unneeded MODULE_ALIAS() from gpio-menz127

  DT bindings:
   - document support for the opencores GPIO controller in gpio-mmio
   - document new variants for gpio-pca953x

  Documentation:
   - extensively describe interrupt source detection for gpio-pca953x
     and add more models to the list of supported variants"

* tag 'gpio-updates-for-v7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (59 commits)
  gpio: tegra186: Add support for Tegra264
  dt-bindings: gpio: Add Tegra264 support
  gpio: spacemit-k1: Use PDR for pin direction, not SDR/CDR
  gpio: max77620: Implement .get_direction() callback
  gpio: aspeed-sgpio: Support G7 Aspeed sgpiom controller
  dt-bindings: gpio: aspeed,sgpio: Support ast2700
  gpio: aspeed-sgpio: Convert IRQ functions to use llops callbacks
  gpio: aspeed-sgpio: Create llops to handle hardware access
  gpio: aspeed-sgpio: Remove unused bank name field
  gpio: aspeed-sgpio: Change the macro to support deferred probe
  regulator: bd71815: switch to devm_fwnode_gpiod_get_optional
  gpiolib: introduce devm_fwnode_gpiod_get_optional() wrapper
  gpio: mmio: Add compatible for opencores GPIO
  dt-bindings: gpio-mmio: Correct opencores GPIO
  gpio: pca9570: use lock guards
  gpio: pca9570: Don't use "proxy" headers
  gpio: pca9570: Use devm_mutex_init() for mutex initialization
  MAINTAINERS: Add ROHM BD72720 PMIC
  power: supply: bd71828-power: Support ROHM BD72720
  power: supply: bd71828: Support wider register addresses
  ...
2026-02-11 10:53:39 -08:00
Dmitry Baryshkov
ecfcae7885 power: sequencing: qcom-wcn: fix error path for VDDIO handling
In case getting VDDIO regulator returned an error, WCN power sequencing
driver passes ret to dev_err_probe() as the error code, however it is
known that ret is 0 at this point. Pass PTR_ERR(ctx->vddio) instead.

Fixes: 0eb85f468e ("power: sequencing: qcom-wcn: add support for WCN39xx")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/aYXvQxKqmjP_sdCd@stanley.mountain/
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://patch.msgid.link/20260207-fix-wcn39xx-v1-1-df0606108ce2@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-02-09 10:32:27 +01:00
Ziyi Guo
e1dccb485c power: sequencing: fix missing state_lock in pwrseq_power_on() error path
pwrseq_power_on() calls pwrseq_unit_disable() when the
post_enable callback fails. However, this call is outside the
scoped_guard(mutex, &pwrseq->state_lock) block that ends.

pwrseq_unit_disable() has lockdep_assert_held(&pwrseq->state_lock),
which will fail when called from this error path.

Add the scoped_guard block to cover the post_enable callback and its
error handling to ensure the lock is held when pwrseq_unit_disable() is
called.

Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
Link: https://patch.msgid.link/20260130182651.1576579-1-n7l8m4@u.northwestern.edu
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-02-04 11:26:14 +01:00
Matti Vaittinen
12bdf471e3 power: supply: bd71828: Use dev_err_probe()
The driver uses separate error printing and error returning at probe()
for locations where the error value is hard-coded and can't be
EPROBE_DEFER. This helps to omit the extra return value check which is
done in dev_err_probe().

Using the dev_err_probe() has some other benefits besides handling the
-EPROBE_DEFER though, like standardizing the print for error numbers.
Some believe thes outweigh the benefit of skipping the extra check.

Use dev_err_probe() consistently in the bd71828 power-supply probe.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/aWi_GG74sZRfajA_@mva-rohm
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-30 22:41:17 +01:00
Sebastian Reichel
cb3aa2b540 Immutable branch between MFD, Clk, GPIO, Power, Regulator and RTC due for the v6.20 merge window
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmlo7yoACgkQUa+KL4f8
 d2FKig//RoRbxD0C2OPFfZ7Gi8+lUXfky2sAxRo/lrwpZ9KKppzUB0Jh7YPRzhdD
 9vtCHcACrc7Q5qYI+u0+Xylr3T9VLvXS0ymE0sdXHZyOpqpKF14JT5AvZwGYiIyF
 T5KXJFwtyuZsg4SdoNV7obT4X4NOsGOmNlrhWkNDo7TGoIu+Hq3ia0LDRL9o0ims
 WJTpJuvkUJkZ1tu5vrBvfu/u8y4p+DZ1bgQDu33sQgvyA9yQ9/j1+TQ7YapCVlAI
 6KnkkrRxZ4N21UnF6BTlj896WJa9YI72jzAKgDvXoICoff12IJL0hainw8UeZs1g
 2AagW4umuT9zNNFrIHyxHIHXLnBZ2D8Dtnv3WvFoDgY4Yj2t+7C9nHc/qiXSbKOB
 uUBF9sHev5aI0KqyW0/RGJ0Z19zt71Mu5Nz2FWPCYpy8WuEti7hiY/rQgOIOHdYs
 Vw5zib9rwOQRwC99EA3SYyiPPuBd+lD0JRSClWoopcZdxO0d0TQ91mjvFPV7/kMI
 CtPQfN62f8wRCU7KnG+9pfChmxfnGz7d6bT98hFz/kTeB8EDJOz8Cu5KitB9iYHO
 SMuf408W6bdLiectcY2GGihELI1Rsa3pVHceeI1WLA8W+XE0mC6KEDMahOiE9rRT
 E0U41YYDsJFwReMTz2LKhs4rPkr3BQFMV1cTS2smBQ2tSGb46PY=
 =A82v
 -----END PGP SIGNATURE-----

Merge tag 'ib-mfd-clk-gpio-power-regulator-rtc-v6.20' into psy-next

Merge immutable branch between MFD, Clk, GPIO, Power, Regulator and RTC
due for the v6.20 merge window to apply further cleanups on top of the
BD72720 power-supply driver contained in this branch.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-30 22:38:57 +01:00
Val Packett
c655f45480 power: supply: qcom_battmgr: Recognize "LiP" as lithium-polymer
On the Dell Latitude 7455, the firmware uses "LiP" with a lowercase 'i'
for the battery chemistry type, but only all-uppercase "LIP" was being
recognized. Add the CamelCase variant to the check to fix the "Unknown
battery technology" warning.

Fixes: 202ac22b8e ("power: supply: qcom_battmgr: Add lithium-polymer entry")
Signed-off-by: Val Packett <val@packett.cool>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://patch.msgid.link/20260120235831.479038-1-val@packett.cool
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-30 20:58:57 +01:00
Waqar Hameed
3db37475d7 power: supply: wm97xx: Use devm_power_supply_register()
Instead of handling the registration manually, use the automatic
`devres` variant `devm_power_supply_register()`. This is less error
prone and cleaner.

Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/b0b366d302f0605c8555dd68ed32973959f133bb.1769158280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-30 20:57:32 +01:00
Waqar Hameed
72db889394 power: supply: wm97xx: Use devm_kcalloc()
Instead of handling the memory allocation manually, use the automatic
`devres` variant `devm_kcalloc()`. This is less error prone and
eliminates the `goto`-path.

Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/5ac93f5b0fa417bb5d9e93b9302a18f2c04d4077.1769158280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-30 20:57:32 +01:00
Waqar Hameed
2306725991 power: supply: pm8916_lbc: Fix use-after-free for extcon in IRQ handler
Using the `devm_` variant for requesting IRQ _before_ the `devm_`
variant for allocating/registering the `extcon` handle, means that the
`extcon` handle will be deallocated/unregistered _before_ the interrupt
handler (since `devm_` naturally deallocates in reverse allocation
order). This means that during removal, there is a race condition where
an interrupt can fire just _after_ the `extcon` handle has been
freed, *but* just _before_ the corresponding unregistration of the IRQ
handler has run.

This will lead to the IRQ handler calling `extcon_set_state_sync()` with
a freed `extcon` handle. Which usually crashes the system or otherwise
silently corrupts the memory...

Fix this racy use-after-free by making sure the IRQ is requested _after_
the registration of the `extcon` handle.

Fixes: f8d7a3d211 ("power: supply: Add driver for pm8916 lbc")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Reviewed-by: Nikita Travkin <nikita@trvn.ru>
Link: https://patch.msgid.link/e2a4cd2fcd42b6cd97d856c17c097289a2aed393.1769163273.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-30 20:55:19 +01:00
Emanuele Ghidoli
562357a631 power: reset: tdx-ec-poweroff: fix restart
During testing, restart occasionally failed on Toradex modules.

The issue was traced to an interaction between the EC-based reset/poweroff
handler and the PSCI restart handler. While the embedded controller is
resetting or powering off the module, the PSCI code may still be invoked,
triggering an I2C transaction to the PMIC. This can leave the PMIC I2C
in a frozen state.

Add a delay after issuing the EC reset or power-off command to give the
controller time to complete the operation and avoid falling back to another
restart/poweroff provider.

Also print an error message if sending the command to the embedded controller
fails.

Fixes: 18672fe123 ("power: reset: add Toradex Embedded Controller")
Cc: stable@vger.kernel.org
Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Link: https://patch.msgid.link/20260130071208.1184239-1-ghidoliemanuele@gmail.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-30 20:39:37 +01:00
Manivannan Sadhasivam
52e7b5bd62 power: sequencing: Add the Power Sequencing driver for the PCIe M.2 connectors
This driver is used to control the PCIe M.2 connectors of different
Mechanical Keys attached to the host machines and supporting different
interfaces like PCIe/SATA, USB/UART etc...

Currently, this driver supports only the Mechanical Key M connectors with
PCIe interface. The driver also only supports driving the mandatory 3.3v
and optional 1.8v power supplies. The optional signals of the Key M
connectors are not currently supported.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260122-pci-m2-v6-4-575da9f97239@oss.qualcomm.com
[Bartosz: rename pwrseq_pcie_m2_free_resources() to pwrseq_pcie_m2_free_regulators()]
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-01-23 10:05:38 +01:00
Matti Vaittinen
bcb5bb59b8 power: supply: bd71828-power: Support ROHM BD72720
The ROHM BD72720 is a power management IC with a charger and coulomb
counter block which is closely related to the charger / coulomb counter
found from the BD71815, BD71828, BD71879 which are all supported by the
bd71828-power driver. Due to the similarities it makes sense to support
also the BD72720 with the same driver.

Add basic support for the charger logic on ROHM BD72720.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/fb74c0cab3dfe534135d26dbbb9c66699678c2de.1765804226.git.mazziesaccount@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2026-01-13 12:50:31 +00:00
Matti Vaittinen
de8f20afb0 power: supply: bd71828: Support wider register addresses
The BD71828 power-supply driver assumes register addresses to be 8-bit.
The new BD72720 will use stacked register maps to hide paging which is
done using secondary I2C slave address. This requires use of 9-bit
register addresses in the power-supply driver (added offset 0x100 to
the 8-bit hardware register addresses).

The cost is slightly used memory consumption as the members in the
struct pwr_regs will be changed from u8 to unsigned int, which means 3
byte increase / member / instance.
This is currently 14 members (expected to possibly be increased when
adding new variants / new functionality which may introduce new
registers, but not expected to grow much) and 2 instances (will be 3
instances when BD72720 gets added).

So, even if the number of registers grew to 50 it'd be 150 bytes /
instance. Assuming we eventually supported 5 variants, it'd be
5 * 150 bytes, which stays very reasonable considering systems we are
dealing with.

As a side note, we can reduce the "wasted space / member / instance" from
3 bytes to 1 byte, by using u16 instead of the unsigned int if needed. I
rather use unsigned int to be initially prepared for devices with 32 bit
registers if there is no need to count bytes.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://patch.msgid.link/57c87f7e2082a666f0adeafcd11f673c0af7d326.1765804226.git.mazziesaccount@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
2026-01-13 12:50:27 +00:00
Waqar Hameed
39fe0eac6d power: supply: wm97xx: Fix NULL pointer dereference in power_supply_changed()
In `probe()`, `request_irq()` is called before allocating/registering a
`power_supply` handle. If an interrupt is fired between the call to
`request_irq()` and `power_supply_register()`, the `power_supply` handle
will be used uninitialized in `power_supply_changed()` in
`wm97xx_bat_update()` (triggered from the interrupt handler). This will
lead to a `NULL` pointer dereference since

Fix this racy `NULL` pointer dereference by making sure the IRQ is
requested _after_ the registration of the `power_supply` handle. Since
the IRQ is the last thing requests in the `probe()` now, remove the
error path for freeing it. Instead add one for unregistering the
`power_supply` handle when IRQ request fails.

Fixes: 7c87942aef ("wm97xx_battery: Use irq to detect charger state")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/97b55f0479a932eea7213844bf66f28a974e27a2.1766270196.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:32 +01:00
Randy Dunlap
81963d1c56 power: supply: ab8500_chargalg: improve kernel-doc
Correct "bad line" warnings and add descriptions for missing entries
to avoid these warnings:

ab8500_chargalg.c:173: warning: bad line:  is set
ab8500_chargalg.c:179: warning: bad line:  increased
ab8500_chargalg.c:247: warning: Function parameter or struct member
 't_hyst_norm' not described in 'ab8500_chargalg'
ab8500_chargalg.c:247: warning: Function parameter or struct member
 't_hyst_lowhigh' not described in 'ab8500_chargalg'
ab8500_chargalg.c:247: warning: Function parameter or struct member
 'ccm' not described in 'ab8500_chargalg'
ab8500_chargalg.c:247: warning: Function parameter or struct member
 'ac_chg' not described in 'ab8500_chargalg'
ab8500_chargalg.c:247: warning: Function parameter or struct member
 'usb_chg' not described in 'ab8500_chargalg'
ab8500_chargalg.c:308: warning: Function parameter or struct member
 'state' not described in 'ab8500_chargalg_state_to'
ab8500_chargalg.c:773: warning: Function parameter or struct member
 'di' not described in 'ab8500_chargalg_chg_curr_maxim'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://patch.msgid.link/20251111060009.1959425-1-rdunlap@infradead.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:32 +01:00
Krzysztof Kozlowski
2c7e46e131 power: supply: sysfs: Constify pointer passed to dev_attr_psp()
Memory pointer by pointer passed to dev_attr_psp() is not modified, so
with help of container_of_const() (preferred than container_of()) can be
made pointer to const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20251126171859.72465-2-krzysztof.kozlowski@oss.qualcomm.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:31 +01:00
Haotian Zhang
688364a116 power: supply: bq27xxx: fix wrong errno when bus ops are unsupported
bq27xxx_write(), bq27xxx_read_block(), and bq27xxx_write_block()
return -EPERM when the bus callback pointer is NULL. A NULL callback
indicates the operation is not supported by the bus/driver,
not that permission is denied.

Return -EOPNOTSUPP instead of -EPERM when di->bus.write/
read_bulk/write_bulk is NULL.

Fixes: 14073f6614 ("power: supply: bq27xxx: Add bulk transfer bus methods")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Reviewed-by: Matt Ranostay <matt@ranostay.sg>
Link: https://patch.msgid.link/20251204083436.1367-1-vulab@iscas.ac.cn
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:31 +01:00
Alexander Koskovich
36b0562922 power: reset: nvmem-reboot-mode: respect cell size for nvmem_cell_write
Some platforms expose reboot mode cells that are smaller than an
unsigned int, in which cases lead to write failures. Read the cell
first to determine actual size and only write the number of bytes the
cell can hold.

Fixes: 7a78a7f769 ("power: reset: nvmem-reboot-mode: use NVMEM as reboot mode write interface")
Signed-off-by: Alexander Koskovich <akoskovich@pm.me>
Link: https://patch.msgid.link/20251214191529.2470580-1-akoskovich@pm.me
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:31 +01:00
Waqar Hameed
8d59cf3887 power: supply: sbs-battery: Fix use-after-free in power_supply_changed()
Using the `devm_` variant for requesting IRQ _before_ the `devm_`
variant for allocating/registering the `power_supply` handle, means that
the `power_supply` handle will be deallocated/unregistered _before_ the
interrupt handler (since `devm_` naturally deallocates in reverse
allocation order). This means that during removal, there is a race
condition where an interrupt can fire just _after_ the `power_supply`
handle has been freed, *but* just _before_ the corresponding
unregistration of the IRQ handler has run.

This will lead to the IRQ handler calling `power_supply_changed()` with
a freed `power_supply` handle. Which usually crashes the system or
otherwise silently corrupts the memory...

Note that there is a similar situation which can also happen during
`probe()`; the possibility of an interrupt firing _before_ registering
the `power_supply` handle. This would then lead to the nasty situation
of using the `power_supply` handle *uninitialized* in
`power_supply_changed()`.

Fix this racy use-after-free by making sure the IRQ is requested _after_
the registration of the `power_supply` handle. Keep the old behavior of
just printing a warning in case of any failures during the IRQ request
and finishing the probe successfully.

Fixes: d2cec82c28 ("power: sbs-battery: Request threaded irq and fix dev callback cookie")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Reviewed-by: Phil Reid <preid@electromag.com.au>
Link: https://patch.msgid.link/0ef896e002495e615157b482d18a437af19ddcd0.1766268280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:31 +01:00
Waqar Hameed
e2febe375e power: supply: rt9455: Fix use-after-free in power_supply_changed()
Using the `devm_` variant for requesting IRQ _before_ the `devm_`
variant for allocating/registering the `power_supply` handle, means that
the `power_supply` handle will be deallocated/unregistered _before_ the
interrupt handler (since `devm_` naturally deallocates in reverse
allocation order). This means that during removal, there is a race
condition where an interrupt can fire just _after_ the `power_supply`
handle has been freed, *but* just _before_ the corresponding
unregistration of the IRQ handler has run.

This will lead to the IRQ handler calling `power_supply_changed()` with
a freed `power_supply` handle. Which usually crashes the system or
otherwise silently corrupts the memory...

Note that there is a similar situation which can also happen during
`probe()`; the possibility of an interrupt firing _before_ registering
the `power_supply` handle. This would then lead to the nasty situation
of using the `power_supply` handle *uninitialized* in
`power_supply_changed()`.

Fix this racy use-after-free by making sure the IRQ is requested _after_
the registration of the `power_supply` handle.

Fixes: e86d69dd78 ("power_supply: Add support for Richtek RT9455 battery charger")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/1567d831e04c3e2fcb9e18dd36b7bcba4634581a.1766268280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:31 +01:00
Waqar Hameed
b750812997 power: supply: pm8916_lbc: Fix use-after-free in power_supply_changed()
Using the `devm_` variant for requesting IRQ _before_ the `devm_`
variant for allocating/registering the `power_supply` handle, means that
the `power_supply` handle will be deallocated/unregistered _before_ the
interrupt handler (since `devm_` naturally deallocates in reverse
allocation order). This means that during removal, there is a race
condition where an interrupt can fire just _after_ the `power_supply`
handle has been freed, *but* just _before_ the corresponding
unregistration of the IRQ handler has run.

This will lead to the IRQ handler calling `power_supply_changed()` with
a freed `power_supply` handle. Which usually crashes the system or
otherwise silently corrupts the memory...

Note that there is a similar situation which can also happen during
`probe()`; the possibility of an interrupt firing _before_ registering
the `power_supply` handle. This would then lead to the nasty situation
of using the `power_supply` handle *uninitialized* in
`power_supply_changed()`.

Fix this racy use-after-free by making sure the IRQ is requested _after_
the registration of the `power_supply` handle.

Fixes: f8d7a3d211 ("power: supply: Add driver for pm8916 lbc")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Reviewed-by: Nikita Travkin <nikita@trvn.ru>
Link: https://patch.msgid.link/64d8dd3675a4e59fa32c3e0ef451f12d1f7ed18f.1766268280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:30 +01:00
Waqar Hameed
62914959b3 power: supply: pm8916_bms_vm: Fix use-after-free in power_supply_changed()
Using the `devm_` variant for requesting IRQ _before_ the `devm_`
variant for allocating/registering the `power_supply` handle, means that
the `power_supply` handle will be deallocated/unregistered _before_ the
interrupt handler (since `devm_` naturally deallocates in reverse
allocation order). This means that during removal, there is a race
condition where an interrupt can fire just _after_ the `power_supply`
handle has been freed, *but* just _before_ the corresponding
unregistration of the IRQ handler has run.

This will lead to the IRQ handler calling `power_supply_changed()` with
a freed `power_supply` handle. Which usually crashes the system or
otherwise silently corrupts the memory...

Note that there is a similar situation which can also happen during
`probe()`; the possibility of an interrupt firing _before_ registering
the `power_supply` handle. This would then lead to the nasty situation
of using the `power_supply` handle *uninitialized* in
`power_supply_changed()`.

Fix this racy use-after-free by making sure the IRQ is requested _after_
the registration of the `power_supply` handle.

Fixes: 098bce1838 ("power: supply: Add pm8916 VM-BMS support")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Reviewed-by: Nikita Travkin <nikita@trvn.ru>
Link: https://patch.msgid.link/2749c09ff81fcac87ae48147e216135450d8c067.1766268280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:30 +01:00
Waqar Hameed
838767f507 power: supply: pf1550: Fix use-after-free in power_supply_changed()
Using the `devm_` variant for requesting IRQ _before_ the `devm_`
variant for allocating/registering the `power_supply` handle, means that
the `power_supply` handle will be deallocated/unregistered _before_ the
interrupt handler (since `devm_` naturally deallocates in reverse
allocation order). This means that during removal, there is a race
condition where an interrupt can fire just _after_ the `power_supply`
handle has been freed, *but* just _before_ the corresponding
unregistration of the IRQ handler has run.

This will lead to the IRQ handler calling `power_supply_changed()` with
a freed `power_supply` handle. Which usually crashes the system or
otherwise silently corrupts the memory...

Note that there is a similar situation which can also happen during
`probe()`; the possibility of an interrupt firing _before_ registering
the `power_supply` handle. This would then lead to the nasty situation
of using the `power_supply` handle *uninitialized* in
`power_supply_changed()`.

Fix this racy use-after-free by making sure the IRQ is requested _after_
the registration of the `power_supply` handle.

Fixes: 4b6b6433a9 ("power: supply: pf1550: add battery charger support")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Reviewed-by: Samuel Kayode <samkay014@gmail.com>
Link: https://patch.msgid.link/ae5a71b7e4dd2967d8fdcc531065cc71b17c86f5.1766268280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:30 +01:00
Waqar Hameed
b2ce982e2e power: supply: goldfish: Fix use-after-free in power_supply_changed()
Using the `devm_` variant for requesting IRQ _before_ the `devm_`
variant for allocating/registering the `power_supply` handle, means that
the `power_supply` handle will be deallocated/unregistered _before_ the
interrupt handler (since `devm_` naturally deallocates in reverse
allocation order). This means that during removal, there is a race
condition where an interrupt can fire just _after_ the `power_supply`
handle has been freed, *but* just _before_ the corresponding
unregistration of the IRQ handler has run.

This will lead to the IRQ handler calling `power_supply_changed()` with
a freed `power_supply` handle. Which usually crashes the system or
otherwise silently corrupts the memory...

Note that there is a similar situation which can also happen during
`probe()`; the possibility of an interrupt firing _before_ registering
the `power_supply` handle. This would then lead to the nasty situation
of using the `power_supply` handle *uninitialized* in
`power_supply_changed()`.

Fix this racy use-after-free by making sure the IRQ is requested _after_
the registration of the `power_supply` handle.

Fixes: 84d7b76874 ("power: Add battery driver for goldfish emulator")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/500a606bb6fb6f2bb8d797e19a00cea9dd7b03c1.1766268280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:30 +01:00
Waqar Hameed
642f33e34b power: supply: cpcap-battery: Fix use-after-free in power_supply_changed()
Using the `devm_` variant for requesting IRQ _before_ the `devm_`
variant for allocating/registering the `power_supply` handle, means that
the `power_supply` handle will be deallocated/unregistered _before_ the
interrupt handler (since `devm_` naturally deallocates in reverse
allocation order). This means that during removal, there is a race
condition where an interrupt can fire just _after_ the `power_supply`
handle has been freed, *but* just _before_ the corresponding
unregistration of the IRQ handler has run.

This will lead to the IRQ handler calling `power_supply_changed()` with
a freed `power_supply` handle. Which usually crashes the system or
otherwise silently corrupts the memory...

Note that there is a similar situation which can also happen during
`probe()`; the possibility of an interrupt firing _before_ registering
the `power_supply` handle. This would then lead to the nasty situation
of using the `power_supply` handle *uninitialized* in
`power_supply_changed()`.

Fix this racy use-after-free by making sure the IRQ is requested _after_
the registration of the `power_supply` handle.

Fixes: 874b2adbed ("power: supply: cpcap-battery: Add a battery driver")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/81db58d610c9a51a68184f856cd431a934cccee2.1766268280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:30 +01:00
Waqar Hameed
5f0b1cb419 power: supply: bq25980: Fix use-after-free in power_supply_changed()
Using the `devm_` variant for requesting IRQ _before_ the `devm_`
variant for allocating/registering the `power_supply` handle, means that
the `power_supply` handle will be deallocated/unregistered _before_ the
interrupt handler (since `devm_` naturally deallocates in reverse
allocation order). This means that during removal, there is a race
condition where an interrupt can fire just _after_ the `power_supply`
handle has been freed, *but* just _before_ the corresponding
unregistration of the IRQ handler has run.

This will lead to the IRQ handler calling `power_supply_changed()` with
a freed `power_supply` handle. Which usually crashes the system or
otherwise silently corrupts the memory...

Note that there is a similar situation which can also happen during
`probe()`; the possibility of an interrupt firing _before_ registering
the `power_supply` handle. This would then lead to the nasty situation
of using the `power_supply` handle *uninitialized* in
`power_supply_changed()`.

Fix this racy use-after-free by making sure the IRQ is requested _after_
the registration of the `power_supply` handle.

Fixes: 5069185fc1 ("power: supply: bq25980: Add support for the BQ259xx family")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/8763035cadb959e14787b3837f2d3db61f6e1c34.1766268280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:29 +01:00
Waqar Hameed
8005843369 power: supply: bq256xx: Fix use-after-free in power_supply_changed()
Using the `devm_` variant for requesting IRQ _before_ the `devm_`
variant for allocating/registering the `power_supply` handle, means that
the `power_supply` handle will be deallocated/unregistered _before_ the
interrupt handler (since `devm_` naturally deallocates in reverse
allocation order). This means that during removal, there is a race
condition where an interrupt can fire just _after_ the `power_supply`
handle has been freed, *but* just _before_ the corresponding
unregistration of the IRQ handler has run.

This will lead to the IRQ handler calling `power_supply_changed()` with
a freed `power_supply` handle. Which usually crashes the system or
otherwise silently corrupts the memory...

Note that there is a similar situation which can also happen during
`probe()`; the possibility of an interrupt firing _before_ registering
the `power_supply` handle. This would then lead to the nasty situation
of using the `power_supply` handle *uninitialized* in
`power_supply_changed()`.

Fix this racy use-after-free by making sure the IRQ is requested _after_
the registration of the `power_supply` handle.

Fixes: 32e4978bb9 ("power: supply: bq256xx: Introduce the BQ256XX charger driver")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/39da6da8cc060fa0382ca859f65071e791cb6119.1766268280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:29 +01:00
Waqar Hameed
3291c51d46 power: supply: act8945a: Fix use-after-free in power_supply_changed()
Using the `devm_` variant for requesting IRQ _before_ the `devm_`
variant for allocating/registering the `power_supply` handle, means that
the `power_supply` handle will be deallocated/unregistered _before_ the
interrupt handler (since `devm_` naturally deallocates in reverse
allocation order). This means that during removal, there is a race
condition where an interrupt can fire just _after_ the `power_supply`
handle has been freed, *but* just _before_ the corresponding
unregistration of the IRQ handler has run.

This will lead to the IRQ handler calling `power_supply_changed()` with
a freed `power_supply` handle. Which usually crashes the system or
otherwise silently corrupts the memory...

Note that there is a similar situation which can also happen during
`probe()`; the possibility of an interrupt firing _before_ registering
the `power_supply` handle. This would then lead to the nasty situation
of using the `power_supply` handle *uninitialized* in
`power_supply_changed()`.

Fix this racy use-after-free by making sure the IRQ is requested _after_
the registration of the `power_supply` handle.

Fixes: a09209acd6 ("power: supply: act8945a_charger: Add status change update support")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/bcf3a23b5187df0bba54a8c8fe09f8b8a0031dee.1766268280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:29 +01:00
Waqar Hameed
c4af8a98bb power: supply: ab8500: Fix use-after-free in power_supply_changed()
Using the `devm_` variant for requesting IRQ _before_ the `devm_`
variant for allocating/registering the `power_supply` handle, means that
the `power_supply` handle will be deallocated/unregistered _before_ the
interrupt handler (since `devm_` naturally deallocates in reverse
allocation order). This means that during removal, there is a race
condition where an interrupt can fire just _after_ the `power_supply`
handle has been freed, *but* just _before_ the corresponding
unregistration of the IRQ handler has run.

This will lead to the IRQ handler calling `power_supply_changed()` with
a freed `power_supply` handle. Which usually crashes the system or
otherwise silently corrupts the memory...

Note that there is a similar situation which can also happen during
`probe()`; the possibility of an interrupt firing _before_ registering
the `power_supply` handle. This would then lead to the nasty situation
of using the `power_supply` handle *uninitialized* in
`power_supply_changed()`.

Commit 1c1f13a006 ("power: supply: ab8500: Move to componentized
binding") introduced this issue during a refactorization. Fix this racy
use-after-free by making sure the IRQ is requested _after_ the
registration of the `power_supply` handle.

Fixes: 1c1f13a006 ("power: supply: ab8500: Move to componentized binding")
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/ccf83a09942cb8dda3dff70b2682f2c2e9cb97f2.1766268280.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:29 +01:00
Waqar Hameed
ce3bc8469e power: supply: ucs1002: Remove unused gpio include header
This header file is not used anywhere in the driver. Remove it.

Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/dcff57bfbf0510c8b5bfd9d39de021607567a6e8.1766266985.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:28 +01:00
Waqar Hameed
91a4f92de8 power: supply: cw2015: Remove unused gpio include header
This header file is not used anywhere in the driver. Remove it.

Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/6c6ea228f39f3c01c0a89d8ba545be6f3ec13c2a.1766266985.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:28 +01:00
Waqar Hameed
3d74b6dfd7 power: supply: bq25980: Remove unused gpio include header
This header file is not used anywhere in the driver. Remove it.

Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/94cf6d7dc464e20abea543983b24828e51c64f93.1766266985.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:28 +01:00
Waqar Hameed
38673fd9d6 power: supply: bq256xx: Remove unused gpio include header
This header file is not used anywhere in the driver. Remove it.

Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://patch.msgid.link/730eb504f7ae9d3fcdfeebb544bfe115c32e1064.1766266985.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:28 +01:00
Waqar Hameed
e312b7e318 power: supply: bd99954: Remove unused gpio include header
This header file is not used anywhere in the driver. Remove it.

Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Acked-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/ee74b461a8b8f02093e0beb519a1f0b8de7b64bc.1766266985.git.waqar.hameed@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2026-01-12 02:52:28 +01:00
Dmitry Baryshkov
0eb85f468e power: sequencing: qcom-wcn: add support for WCN39xx
The WCN39xx family of WiFi/BT chips incorporates a simple PMU, spreading
voltages over internal rails. Implement power sequencing support for
this generation of WCN chips. Unlike later devices, they don't have
separate enable GPIO lines, letting the chip figure out the necessary
parts on its own.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260106-wcn3990-pwrctl-v2-5-0386204328be@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-01-07 09:24:10 +01:00
Bartosz Golaszewski
b1857911d8 power: sequencing: qcom-wcn: use device_get_match_data()
Use the generic fwnode interface for retrieving device match data
instead of the OF-specific one.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20251125134700.29135-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-01-07 09:23:15 +01:00
Linus Torvalds
208eed95fc soc: driver updates for 6.19
This is the first half of the driver changes:
 
  - A treewide interface change to the "syscore" operations for
    power management, as a preparation for future Tegra specific
    changes.
 
  - Reset controller updates with added drivers for LAN969x, eic770
    and RZ/G3S SoCs.
 
  - Protection of system controller registers on Renesas and Google SoCs,
    to prevent trivially triggering a system crash from e.g. debugfs
    access.
 
  - soc_device identification updates on Nvidia, Exynos and Mediatek
 
  - debugfs support in the ST STM32 firewall driver
 
  - Minor updates for SoC drivers on AMD/Xilinx, Renesas,  Allwinner, TI
 
  - Cleanups for memory controller support on Nvidia and Renesas
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmky/8gACgkQmmx57+YA
 GNlqohAApPTLM6Q4gf1cIcsTVaP0uxx9CBgupCGuT5ORrOMKBghVWjTOTSxeEAab
 UQF465QwYUUu602GH34UmRaY9CKW2bMIsfmkgmxNB4Y4Qd7yCgQNJ/h/TnN0rBH+
 qTeEsRH/hax4miSNsh0oOZfVkZkg+23VF02d1VL0CcaX7y4oT45RPBQugrNx/gNS
 fHfVwgIq8vJ8WyrmM1h2nv1i1vgSzEy50B3kY674BBw83FcJTafNLvD7N5DSgD1H
 /I/2xeyEpb+oL1VfeHcXZaX/jf04O+cmvSzBi+MOH1tI3MpdxJib1vEYBdggoOWN
 K/FFGgsOY+DNmJPpSnPTTu8UpzksS8SxGBP7M9Q8roKZwA2c9wLotxySvjki5yv8
 2zvabRdzbrSaoYwsH9QnZdQ2hVkJ9W8MESu8PevD3yMNuFUzledPDWW0N1SbGm78
 0ZdB6NPdaBZYHMNMRdFhN8P275/Mx5e0XWN9oYMQqjPooH7YkyT7hJWz6ao2PCJP
 8mDmnW1RzL+LWf7mJ25ZEtS+YjmKA/PVmogRrGurKCadvdxXqCF09KNljICHhmmu
 t0KB4dqw02OXLPvBk21qCi0zL56w1JDgqtS8suFvDYo9sCceeAbAcmpyoUOFj2N+
 Upn976tb4iqFrr9mFswpmCJWPpqJkU+A+KnKsIRPU7N4kSrP35I=
 =HvlN
 -----END PGP SIGNATURE-----

Merge tag 'soc-drivers-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull SoC driver updates from Arnd Bergmann:
 "This is the first half of the driver changes:

   - A treewide interface change to the "syscore" operations for power
     management, as a preparation for future Tegra specific changes

   - Reset controller updates with added drivers for LAN969x, eic770 and
     RZ/G3S SoCs

   - Protection of system controller registers on Renesas and Google
     SoCs, to prevent trivially triggering a system crash from e.g.
     debugfs access

   - soc_device identification updates on Nvidia, Exynos and Mediatek

   - debugfs support in the ST STM32 firewall driver

   - Minor updates for SoC drivers on AMD/Xilinx, Renesas, Allwinner, TI

   - Cleanups for memory controller support on Nvidia and Renesas"

* tag 'soc-drivers-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (114 commits)
  memory: tegra186-emc: Fix missing put_bpmp
  Documentation: reset: Remove reset_controller_add_lookup()
  reset: fix BIT macro reference
  reset: rzg2l-usbphy-ctrl: Fix a NULL vs IS_ERR() bug in probe
  reset: th1520: Support reset controllers in more subsystems
  reset: th1520: Prepare for supporting multiple controllers
  dt-bindings: reset: thead,th1520-reset: Add controllers for more subsys
  dt-bindings: reset: thead,th1520-reset: Remove non-VO-subsystem resets
  reset: remove legacy reset lookup code
  clk: davinci: psc: drop unused reset lookup
  reset: rzg2l-usbphy-ctrl: Add support for RZ/G3S SoC
  reset: rzg2l-usbphy-ctrl: Add support for USB PWRRDY
  dt-bindings: reset: renesas,rzg2l-usbphy-ctrl: Document RZ/G3S support
  reset: eswin: Add eic7700 reset driver
  dt-bindings: reset: eswin: Documentation for eic7700 SoC
  reset: sparx5: add LAN969x support
  dt-bindings: reset: microchip: Add LAN969x support
  soc: rockchip: grf: Add select correct PWM implementation on RK3368
  soc/tegra: pmc: Add USB wake events for Tegra234
  amba: tegra-ahb: Fix device leak on SMMU enable
  ...
2025-12-05 17:29:04 -08:00
Linus Torvalds
b0206c4eb6 power supply and reset changes for the 6.19 series
* power-supply core
   - documentation fixes
  * power-supply drivers
   - add BD71828 charger driver
   - add Richtek RT9756 driver
   - max77705: add adaptive input current support
   - max77705: add support for multiple devices
   - misc. small fixes
  * reset drivers
   - add spacemit-p1 poweroff/reboot driver
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmkyAjAACgkQ2O7X88g7
 +pqPZQ//UeQc/wx+5Vg/YtvV948PNA7j8YhqHS5pvV0i5dm7zv1fB/gVfZBT82UD
 2Ac6HlrqRfcZRosE4wSH64MpAmKo3pwjf1MPOYpLcUdfRZnxAwwYcuZqZtiVOVSp
 d9GnmpWugFdDNfLnuLwAvYUGUB4t8E8EdznH+5JotRwhEuUP7h8JIgOM5s6P+gIX
 azuug5fh48MCDsCAfEbpwFNJ404eGcMgiJNeIVm0qvUqe+vr8ln9LsDv/fLEQUtR
 xZsQLakDHDSoYn4lq90wq4YajZuLvU/UO4qTREN1MdHAasfVGsDEgfVaIrbTr6Ez
 rWuX/TD/+aj9Rxp2rUUM09QcANoEFFyzqABRVtLYmfFaCLY2lC9TJ4G756nSmODc
 ScvAzH45Qq4v+s3W5LOu/xk/XlQqpHys709HVNU3u5+njcNlWi4mQyRipqUdOpYJ
 Dr+3JzfNJY2/XvaQJqasra2U2bxNl4+EILdAkkr82dUx4F4W0hH52bB1wKiOV7VG
 btSgFx8OnHPtXRRGMrNqfUlavvM+G8i8+gozrX/6l7lO0Gdv4PWNT8ud7+eXgNoD
 G0yu8XYN6FcdJAYO7jOfXcwaQh/UXSUPsRT2sOn7F3SpyJLv5dUoBtFzJDpBCiRl
 pPG6DythmaRouXGJL+NIRZ2itKeDfwzu284vAa2N1NxsfZWmwpc=
 =vTVH
 -----END PGP SIGNATURE-----

Merge tag 'for-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply

Pull power supply and reset updates from Sebastian Reichel:
  "Power-supply core:
   - documentation fixes

  power-supply drivers:
   - add BD71828 charger driver
   - add Richtek RT9756 driver
   - max77705: add adaptive input current support
   - max77705: add support for multiple devices
   - misc small fixes

  reset drivers:
   - add spacemit-p1 poweroff/reboot driver"

* tag 'for-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
  Revert "power: supply: qcom_battmgr: support disabling charge control"
  Documentation: power: rt9756: Document exported sysfs entries
  power: supply: rt9756: Add Richtek RT9756 smart cap divider charger
  dt-bindings: power: supply: Add Richtek RT9756 smart cap divider charger
  driver: reset: spacemit-p1: add driver for poweroff/reboot
  power: supply: apm_power: only unset own apm_get_power_status
  power: supply: use ktime_divns() to avoid 64-bit division
  docs: power: clean up power_supply_class.rst
  power: supply: qcom_battmgr: support disabling charge control
  power: supply: qcom_battmgr: clamp charge control thresholds
  power: supply: wm831x: Check wm831x_set_bits() return value
  power: supply: rt9467: Prevent using uninitialized local variable in rt9467_set_value_from_ranges()
  power: supply: rt9467: Return error on failure in rt9467_set_value_from_ranges()
  power: supply: max17040: Check iio_read_channel_processed() return code
  power: supply: cw2015: Check devm_delayed_work_autocancel() return code
  power: supply: rt5033_charger: Fix device node reference leaks
  power: supply: max77705: Fix potential IRQ chip conflict when probing two devices
  power: supply: max77705_charger: implement aicl feature
  MAINTAINERS: Add entry for BD71828 charger
  power: supply: Add bd718(15/28/78) charger driver
2025-12-04 16:12:03 -08:00
Linus Torvalds
0a9431fa74 regulator: Updates for v6.19
This is a relatively busy release for the regulator API, as well as a
 good collection of new drivers we've got a little bit of core work and a
 bunch of cleanup throughout the subsystem:
 
  - Support for propagating undervoltage events to child regulators.
  - Undo enables done on supplies when setting enabling regulators via
    constraints fails.
  - Pull in some gpiolib changes adding support for shared GPIOs to
    the gpiolib core, using them to replace the open coded variant of this
    that we've had in the regulator API for a long time.
  - Support for Fitipower FP9931 and JD9330, Mediatek MT6316, MT6363 and
    MT6373, NXP PF1550 and Qualcomm PMH01XX and PMCX0102
 
 The PF1550 support was originally going to go via the MFD tree but
 Krzysztof's cleanup work overlapped with it so I pulled in Lee's signed
 tag with support for the device.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmkt72UACgkQJNaLcl1U
 h9Dm2wf+JhjBLxviOozOhSv17wKnCYpApL12vPIHhv3lGu4J9wPiqqe3eB6PrTPo
 xkuIb8u68wOveh7uLgr/kprH/YUxofrkCEwZjy57geSanuqIEzVoqU//4NKca9ND
 UeoDiTYLx5JQVzlo12tSFhLCvDsFgdnemWFfubRPQGTJA/RElMxrNySf3yUQbYBE
 ODpTGbXqt4LnYQTJRvVM8/0KzREpxD0X8fSISKpA3KYBFntMexZcgrs5pqijwfMS
 Euxff2UpFzjodmYEusWfKOFeZXmd/cClF26Tol7oaeaurr1pNu1i0nBUprbd/rzL
 YTV8QeiftLqER/h2iDX4f8iTmvVhzA==
 =9IkF
 -----END PGP SIGNATURE-----

Merge tag 'regulator-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator

Pull regulator updates from Mark Brown:
 "This is a relatively busy release for the regulator API, as well as a
  good collection of new drivers we've got a little bit of core work and
  a bunch of cleanup throughout the subsystem:

   - Support for propagating undervoltage events to child regulators

   - Undo enables done on supplies when setting enabling regulators via
     constraints fails

   - Pull in some gpiolib changes adding support for shared GPIOs to the
     gpiolib core, using them to replace the open coded variant of this
     that we've had in the regulator API for a long time

   - Support for Fitipower FP9931 and JD9330, Mediatek MT6316, MT6363
     and MT6373, NXP PF1550 and Qualcomm PMH01XX and PMCX0102

  The PF1550 support was originally going to go via the MFD tree but
  Krzysztof's cleanup work overlapped with it so I pulled in Lee's
  signed tag with support for the device"

* tag 'regulator-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (50 commits)
  regulator: fp9931: Fix spelling mistake "failid" -> "failed"
  regulator: core: Protect regulator_supply_alias_list with regulator_list_mutex
  regulator: pf9453: Constify pointers to 'regulator_desc' wrap struct
  regulator: pca9450: Constify pointers to 'regulator_desc' wrap struct
  regulator: mt6358: Constify pointers to 'regulator_desc' wrap struct
  regulator: bd96801: Constify pointers to 'regulator_desc' wrap struct
  regulator: bd718x7: Constify pointers to 'regulator_desc' wrap struct
  regulator: bd71828: Constify pointers to 'regulator_desc' wrap struct
  regulator: bd71815: Constify pointers to 'regulator_desc' wrap struct
  regulator: Use container_of_const() when all types are const
  regulator: pca9450: Fix error code in probe()
  regulator: qcomm-labibb: replace use of system_wq with system_dfl_wq
  regulator: Add FP9931/JD9930 driver
  dt-bindings: regulator: Add Fitipower FP9931/JD9930
  dt-bindings: vendor-prefixes: Add Fitipower
  regulator: make the subsystem aware of shared GPIOs
  regulator: renesas-usb-vbus-regulator: Remove unused headers
  regulator: pca9450: Add support for setting debounce settings
  regulator: dt-bindings: pca9540: add debounce timer configuration
  regulator: core: disable supply if enabling main regulator fails
  ...
2025-12-04 11:20:29 -08:00
Linus Torvalds
ad8cccc248 Fix Intel Dollar Cove TI battery driver 32-bit build error
The driver is doing a 64-bit divide, rather than using the proper
helpers, causing link errors on i386 allyesconfig builds:

  x86_64-linux-ld: drivers/power/supply/intel_dc_ti_battery.o: in function `dc_ti_battery_get_voltage_and_current_now':
  intel_dc_ti_battery.c:(.text+0x5c): undefined reference to `__udivdi3'
  x86_64-linux-ld: intel_dc_ti_battery.c:(.text+0x96): undefined reference to `__udivdi3'

and while fixing that, fix the double rounding: keep the timing
difference in nanoseconds ('ktime'), and then just convert to usecs at
the end.

Not because the timing precision is likely to matter, but because doing
it right also makes the code simpler.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Cc: Hans de Goede <hansg@kernel.org>
Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2025-11-26 12:31:48 -08:00
Thierry Reding
a97fbc3ee3 syscore: Pass context data to callbacks
Several drivers can benefit from registering per-instance data along
with the syscore operations. To achieve this, move the modifiable fields
out of the syscore_ops structure and into a separate struct syscore that
can be registered with the framework. Add a void * driver data field for
drivers to store contextual data that will be passed to the syscore ops.

Acked-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2025-11-14 10:01:52 +01:00
Sebastian Reichel
8e8856396b Revert "power: supply: qcom_battmgr: support disabling charge control"
The charge control disabling does not work as expected and needs
more time to be figured out correctly. Drop this feature for now.

Reported-by: Val Packett <val@packett.cool>
Closes: https://lore.kernel.org/all/8f003bfb-8279-4c65-a271-c1e4a029043d@packett.cool/
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2025-11-03 15:32:47 +01:00
ChiYuan Huang
b6f0796d43 power: supply: rt9756: Add Richtek RT9756 smart cap divider charger
Add support for RT9756 smart cap divider charger.

The RT9759 is a high efficiency and high charge current charger. The
maximum charge current is up to 8A. It integrates a dual-phase charge
pump core with ADC monitoring.

Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
Link: https://patch.msgid.link/f682812069b6be2138bfdae2ff9a9c84994d5b64.1761894605.git.cy_huang@richtek.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2025-11-03 01:44:20 +01:00
Aurelien Jarno
28124cc0fb driver: reset: spacemit-p1: add driver for poweroff/reboot
This driver implements poweroff/reboot support for the SpacemiT P1 PMIC
chip, which is commonly paired with the SpacemiT K1 SoC.

The SpacemiT P1 support is implemented as a MFD driver, so the access is
done directly through the regmap interface. Reboot or poweroff is
triggered by setting a specific bit in a control register, which is
automatically cleared by the hardware afterwards.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Link: https://patch.msgid.link/20251102230352.914421-2-aurelien@aurel32.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2025-11-03 01:02:10 +01:00
Ahelenia Ziemiańska
bd44ea1291 power: supply: apm_power: only unset own apm_get_power_status
Mirroring drivers/macintosh/apm_emu.c, this means that
  modprobe apm_power && modprobe $anotherdriver && modprobe -r apm_power
leaves $anotherdriver's apm_get_power_status instead of deleting it.

Fixes: 3788ec932b ("[BATTERY] APM emulation driver for class batteries")
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Link: https://patch.msgid.link/xczpgox57hxbunkcbdl5fxhc4gnsajsipldfidi7355afezk64@tarta.nabijaczleweli.xyz
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2025-11-03 01:01:57 +01:00
Michal Kubecek
3fd1695f5d power: supply: use ktime_divns() to avoid 64-bit division
The build of intel_dc_ti_battery module on i386 (32-bit) fails with

ERROR: modpost: "__udivdi3" [drivers/power/supply/intel_dc_ti_battery.ko]

This is caused by 64-bit division of ktime values by NSEC_PER_USEC. Use
ktime_divns() helper which handles the division correctly on 32-bit
architectures.

Fixes: 8c5795fe55 ("power: supply: Add new Intel Dollar Cove TI battery driver")
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Reviewed-by: Hans de Goede <hansg@kernel.org>
Link: https://patch.msgid.link/20251015075957.8F40620057@lion.mk-sys.cz
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2025-11-03 01:01:57 +01:00