aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/supply/axp288_charger.c
AgeCommit message (Collapse)Author
2019-05-21power: supply: axp288_charger: Fix unchecked return valueGustavo A. R. Silva
commit c3422ad5f84a66739ec6a37251ca27638c85b6be upstream. Currently there is no check on platform_get_irq() return value in case it fails, hence never actually reporting any errors and causing unexpected behavior when using such value as argument for function regmap_irq_get_virq(). Fix this by adding a proper check, a message reporting any errors and returning *pirq* Addresses-Coverity-ID: 1443940 ("Improper use of negative value") Fixes: 843735b788a4 ("power: axp288_charger: axp288 charger driver") Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-03power: supply: axp288_charger: Fix initial constant_charge_current valueHans de Goede
[ Upstream commit f2a42595f0865886a2d40524b0e9d15600848670 ] We should look at val which contains the value read from the register, not ret which is always 0 on a successful read. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Fixes: eac53b3664f59 ("power: supply: axp288_charger: Drop platform_data dependency") Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-12power: supply: axp288_charger: Properly stop work on probe-error / removeHans de Goede
[ Upstream commit 165c2357744e41391902a2a72dd170beb60c28d5 ] Properly stop any work we may have queued on probe-errors / remove. Rather then adding a remove driver callback for this, and goto style error handling to probe, use a devm_action for this. The devm_action gets registered before we register any of the extcon notifiers which may queue the work, devm does cleanup in reverse order, so this ensures that the notifiers are removed before we cancel the work. Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-19power: supply: axp288_charger: Only wait for INT3496 device if presentHans de Goede
On some devices with an axp288 pmic setting vbus path based on the id-pin is handled by an ACPI _AIE interrupt on the gpio and the INT3496 device is disabled. Instead of returning -EPROBE_DEFER on these devices waiting for the never to show up INT3496 device, check for its presence and only request and monitor the matching extcon if the device is there, otherwise let the firmware handle the vbus path control. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-01-04power: supply: axp288_charger: Use one notifier_block per extcon cableHans de Goede
Prior to this commit the code was using 1 notifier_block for all types of charger cable, this is incorrect as the notifier_block becomes part of a linked-list and now the same notifier_block is part of 3 linked lists. This commit fixes this by using a separate nb per extcon cable. Note this happened to work fine sofar because axp288_charger was the only listener, so when added to each of the 3 notifier chains, the next pointer in the nb would be set to 0, so we've 3 heads pointing to the same nb, with its next pointing to NULL. But as soon as we mix in a second extcon consumer things will go boom. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04power: supply: axp288_charger: Fix the module not auto-loadingHans de Goede
Add a MODULE_DEVICE_TABLE to fix the module not auto-loading. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04power: supply: axp288_charger: Remove unnecessary irq?_en register writesHans de Goede
Setting the irq_enable bits is taken care of by the irq chip when we request the irqs and the driver should not be meddling with the irq?_en registers itself. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04power: supply: axp288_charger: Fix wrong regmap_update_bitsHans de Goede
To set a bit to 1 one needs to pass the mask for the bit to set as second argument into regmap_update_bits, not "1". Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04power: supply: axp288_charger: Get and process initial hardware-stateHans de Goede
Do not wait for an extcon notification before processing the cable states, instead queue the otg / cable work on probe to make sure we immediately process the initial hardware state. Note this also requiree moving the getting of the USB_HOST cable state from the extcon notifier to the workqueue function. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04power: supply: axp288_charger: Some minor cleanupsHans de Goede
Remove info->health, info->present and info->online caching, as no code is reading the cached values. Remove if (changed) check before calling power_supply_changed(), we return early from axp288_charger_extcon_evt_worker if nothing has changed, so the check is not needed. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04power: supply: axp288_charger: Handle charger type changing without disconnectHans de Goede
Deal with the charger type changing without a vbus-disconnect being reported in between the 2 charger type states: -Do not return from axp288_charger_extcon_evt_worker early in this case (track old_chg_type) -Make calling axp288_charger_enable_charger with the same value as before a nop, to avoid the need for the caller to check this -Do no do a dev_err when axp288_charger_enable_charger returns an error, axp288_charger_enable_charger already returns an error itself -Disable the charger before changing the charge-current setting (nop if vbus was seen as disconnected before the change) Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04power: supply: axp288_charger: Actually get and use the USB_HOST extcon deviceHans de Goede
Nothing was setting info->otg.cable, so the extcon_get_cable_state_ calls on it would always return -EINVAL. This commit fixes this by actually setting info->otg.cable using the new extcon_get_extcon_dev_by_cable_id function. This commit also makes failing to register the extcon notifier for the USB_HOST cable an error rather then a warning, because we MUST have this notfier to properly disable the VBUS path when in host mode so that we're not drawing current from the 5V boost converter which is supplying power to the otg port when in host mode. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04power: supply: axp288_charger: Move init_hw_regs call before supply registrationHans de Goede
Move the charger_init_hw_regs() above the power_supply_register call, the axp288_charger_usb_set_property() uses axp288_chrg_info.max_cv and .max_cc which get set by charger_init_hw_regs(). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04power: supply: axp288_charger: Register extcon notifers after power_supplyHans de Goede
The extcon notifier work calls power_supply_changed on the power_supply we register, so the extcon notifiers should be registered after we register the power_supply. While touching this code anyways, refactor the code for the 3 cable types into a loop to avoid code repetition. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04power: supply: axp288_charger: Use devm_power_supply_registerHans de Goede
Use devm_power_supply_register instead of power_supply_register, this avoids the need to do manual cleanup and results in quite a nice code cleanup. Note it may seem excessive to add a "struct device *dev" helper local variable for the 1 time it is used in this patch, but future patches in this series also use it. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04Merge branch 'psy-mfd-axp288-immutable' into psy-nextSebastian Reichel
2017-01-04power: supply: axp288_charger: Replace the extcon APIChanwoo Choi
This patch uses the resource-managed extcon API for extcon_register_notifier() and replaces the deprecated extcon API as following: - extcon_get_cable_state_() -> extcon_get_state() Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04power: supply: axp288_charger: Drop platform_data dependencyHans de Goede
When the axp288_charger driver was originally merged, it was merged with a dependency on some other driver providing platform data for it. However the battery-data-framework which should provide that data never got merged, so the axp288_charger as merged upstream has never worked, its probe method simply always returns -ENODEV. This commit removes the dependency on the platform_data instead reading back the charging current and charging voltage that the firmware has set and using those values as the maximum values the user may set. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-04power: supply: axp288_charger: Make charger_init_hw_regs propagate i2c errorsHans de Goede
Make charger_init_hw_regs propagate i2c errors, instead of only warning about them and then ignoring them. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-08-16power: axp288_charger: remove duplicated include from axp288_charger.cWei Yongjun
Remove duplicated include. Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-08-11power: move power supply drivers to power/supplySebastian Reichel
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>