Commit Graph

6 Commits

Author SHA1 Message Date
Kunwu Chan
88f04bc3e7 power: supply: Fix null pointer dereference in smb2_probe
devm_kasprintf and devm_kzalloc return a pointer to dynamically
allocated memory which can be NULL upon failure.

Fixes: 8648aeb5d7 ("power: supply: add Qualcomm PMI8998 SMB2 Charger driver")
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Link: https://lore.kernel.org/r/20231124075021.1335289-1-chentao@kylinos.cn
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-12-24 23:43:28 +01:00
Ruan Jinjie
389405146c power: supply: Remove redundant dev_err_probe() for platform_get_irq_byname()
There is no need to call the dev_err_probe() function directly to print
a custom message when handling an error from platform_get_irq_byname()
function as it is going to display an appropriate error message
in case of a failure.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Link: https://lore.kernel.org/r/20230727113550.2599335-1-ruanjinjie@huawei.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-09-12 20:49:16 +02:00
Caleb Connolly
7e6311f04b power: supply: qcom_pmi8998_charger: fix charger status
The INHIBIT_CHARGE status bit means the battery has reached a
pre-programmed charge limit which is some voltage offset below the
target float voltage. This should be reported as a STATUS_FULL rather
than UNKNOWN, fix it.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Link: https://lore.kernel.org/r/20230802-pmi8998-charger-fixes-v1-2-a8f1e8b84c1e@linaro.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-08-03 02:23:42 +02:00
Caleb Connolly
f57f5838c0 power: supply: qcom_pmi8998_charger: remove CHARGE_CONTROL_LIMIT_* props
These property were intended to allow the power supply to be treated as a
cooling device, however the cooling device interface has been dropped
from the psy core code. They now just duplicate the CURRENT_NOW and
CURRENT_MAX properties and are generally confusing, drop them.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Link: https://lore.kernel.org/r/20230802-pmi8998-charger-fixes-v1-1-a8f1e8b84c1e@linaro.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-08-03 02:23:42 +02:00
Yu Liao
13a0d1088c power: supply: qcom_pmi8998_charger: fix uninitialized variable
smatch warnings:
  drivers/power/supply/qcom_pmi8998_charger.c:565 smb2_status_change_work() error: uninitialized symbol 'usb_online'.

usb_online is used uninitialized whenever smb2_get_prop_usb_online()
returns a negative value.

Thus, fix the issue by initializing usb_online to 0.

Fixes: 8648aeb5d7 ("power: supply: add Qualcomm PMI8998 SMB2 Charger driver")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202307280638.556PrzIS-lkp@intel.com/
Signed-off-by: Yu Liao <liaoyu15@huawei.com>
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org
Link: https://lore.kernel.org/r/20230802023130.2516232-1-liaoyu15@huawei.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-08-03 02:23:21 +02:00
Caleb Connolly
8648aeb5d7 power: supply: add Qualcomm PMI8998 SMB2 Charger driver
Add a driver for the SMB2 charger block found in the Qualcomm PMI8998
and PM660.

This driver is capable of utilising Qualcomm's Automatic Power Source
Detection (APSD) BC1.2 implementation, as well as Automatic Input
Current Limiting (AICL) to configure the maximum input current
limit of DCP (wall) chargers.

Quick Charge is not currently supported.

Most devices using the smb2 charger have a secondary dedicated charger
chip which is used in parallel to enable faster charger without
overheating. However, not all do, as a result to ensure safety until
these are supported, the maximum current is limited to ~1A via the
FAST_CHARGE_CURRENT_CFG register.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Tested-by: Joel Selvaraj <joelselvaraj.oss@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-06-09 01:20:14 +02:00