summaryrefslogtreecommitdiff
path: root/drivers/power/supply/max8997_charger.c
AgeCommit message (Collapse)AuthorFilesLines
2022-05-13extcon: Fix extcon_get_extcon_dev() error handlingDan Carpenter1-4/+4
The extcon_get_extcon_dev() function returns error pointers on error, NULL when it's a -EPROBE_DEFER defer situation, and ERR_PTR(-ENODEV) when the CONFIG_EXTCON option is disabled. This is very complicated for the callers to handle and a number of them had bugs that would lead to an Oops. In real life, there are two things which prevented crashes. First, error pointers would only be returned if there was bug in the caller where they passed a NULL "extcon_name" and none of them do that. Second, only two out of the eight drivers will build when CONFIG_EXTCON is disabled. The normal way to write this would be to return -EPROBE_DEFER directly when appropriate and return NULL when CONFIG_EXTCON is disabled. Then the error handling is simple and just looks like: dev->edev = extcon_get_extcon_dev(acpi_dev_name(adev)); if (IS_ERR(dev->edev)) return PTR_ERR(dev->edev); For the two drivers which can build with CONFIG_EXTCON disabled, then extcon_get_extcon_dev() will now return NULL which is not treated as an error and the probe will continue successfully. Those two drivers are "typec_fusb302" and "max8997-battery". In the original code, the typec_fusb302 driver had an 800ms hang in tcpm_get_current_limit() but now that function is a no-op. For the max8997-battery driver everything should continue working as is. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2022-02-24power: supply: max8997_charger: Use devm_work_autocancel()Christophe JAILLET1-9/+3
Use devm_work_autocancel() instead of hand writing it. It saves a few lines of code. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02power: supply: max8997_charger: Switch to new bindingTimon Baetz1-4/+8
Get regulator from parent device's node and extcon by name. Signed-off-by: Timon Baetz <timon.baetz@protonmail.com> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-03-06power: supply: max8997-charger: remove unneeded semicolonJiapeng Chong1-1/+1
Fix the following coccicheck warnings: ./drivers/power/supply/max8997_charger.c:266:3-4: Unneeded semicolon. Reported-by: Abaci Robot <abaci@linux.alibaba.com> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-06power: supply: max8997_charger: fix spelling mistake "diconnected" -> ↵Colin Ian King1-1/+1
"disconnected" There is a spelling mistake in a dev_dbg message. Fix it. Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-01-05power: supply: max8997_charger: Set CHARGER current limitTimon Baetz1-0/+96
Register for extcon notification and set charging current depending on the detected cable type. Current values are taken from vendor kernel, where most charger types end up setting 650mA [0]. Also enable and disable the CHARGER regulator based on extcon events. [0] https://github.com/krzk/linux-vendor-backup/blob/samsung/galaxy-s2-epic-4g-touch-sph-d710-exynos4210-dump/drivers/misc/max8997-muic.c#L1675-L1678 Signed-off-by: Timon Baetz <timon.baetz@protonmail.com> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-11-30power: supply: max8997-charger: Improve getting charger statusTimon Baetz1-17/+35
Detect charging and discharging state. Ported from downstream Samsung Galaxy S2 (i9100) kernel fork. Signed-off-by: Timon Baetz <timon.baetz@protonmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-11-30power: supply: max8997-charger: Fix platform data retrievalTimon Baetz1-1/+1
Use pdata field of max8998_dev struct to obtain platform data. Signed-off-by: Timon Baetz <timon.baetz@protonmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-11-30power: supply: max8997-charger: Use module_platform_driver()Timon Baetz1-12/+1
Replace register and unregister function calls with module_platform_driver(). Signed-off-by: Timon Baetz <timon.baetz@protonmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-08-30power: supply: maxim: Add SPDX license identifiersKrzysztof Kozlowski1-20/+6
Replace GPL v2.0 and v2.0+ license statements with SPDX license identifiers. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2017-11-06power: supply: max8997: Improve a size determination in probeMarkus Elfring1-2/+1
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-01-04power: supply: max8997_charger: Using device managed API and remove OOM printSrikant Ritolia1-13/+2
Use managed resource function devm_power_supply_register instead of power_supply_register to simplify the error path by allowing unregistering to happen automatically on error and remove. Removing max8997_battery_remove function also as it is now redundant. Also removing out of memory printk message after kzalloc as there is already enough information on failure. Signed-off-by: Srikant Ritolia <s.ritolia@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-19power: supply: max8997_charger: Fix module autoloadJavier Martinez Canillas1-0/+1
If the driver is built as a module, autoload won't work because the module alias information is not filled. So user-space can't match the registered device with the corresponding module. Export the module alias information using the MODULE_DEVICE_TABLE() macro. Before this patch: $ modinfo drivers/power/supply/max8997_charger.ko | grep alias $ After this patch: $ modinfo drivers/power/supply/max8997_charger.ko | grep alias alias: platform:max8997-battery Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-08-11power: move power supply drivers to power/supplySebastian Reichel1-0/+211
This moves all power supply drivers from drivers/power/ to drivers/power/supply/. The intention is a cleaner source tree, since drivers/power/ also contains frameworks unrelated to power supply, like adaptive voltage scaling. Signed-off-by: Sebastian Reichel <sre@kernel.org>