Commit 416682f2 authored by Timon Baetz's avatar Timon Baetz Committed by Sebastian Reichel

power: supply: max8997_charger: Switch to new binding

Get regulator from parent device's node and extcon by name.
Signed-off-by: default avatarTimon Baetz <timon.baetz@protonmail.com>
Reviewed-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 9f45275a
...@@ -168,6 +168,7 @@ static int max8997_battery_probe(struct platform_device *pdev) ...@@ -168,6 +168,7 @@ static int max8997_battery_probe(struct platform_device *pdev)
int ret = 0; int ret = 0;
struct charger_data *charger; struct charger_data *charger;
struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
struct device_node *np = pdev->dev.of_node;
struct i2c_client *i2c = iodev->i2c; struct i2c_client *i2c = iodev->i2c;
struct max8997_platform_data *pdata = iodev->pdata; struct max8997_platform_data *pdata = iodev->pdata;
struct power_supply_config psy_cfg = {}; struct power_supply_config psy_cfg = {};
...@@ -237,20 +238,23 @@ static int max8997_battery_probe(struct platform_device *pdev) ...@@ -237,20 +238,23 @@ static int max8997_battery_probe(struct platform_device *pdev)
return PTR_ERR(charger->battery); return PTR_ERR(charger->battery);
} }
// grab regulator from parent device's node
pdev->dev.of_node = iodev->dev->of_node;
charger->reg = devm_regulator_get_optional(&pdev->dev, "charger"); charger->reg = devm_regulator_get_optional(&pdev->dev, "charger");
pdev->dev.of_node = np;
if (IS_ERR(charger->reg)) { if (IS_ERR(charger->reg)) {
if (PTR_ERR(charger->reg) == -EPROBE_DEFER) if (PTR_ERR(charger->reg) == -EPROBE_DEFER)
return -EPROBE_DEFER; return -EPROBE_DEFER;
dev_info(&pdev->dev, "couldn't get charger regulator\n"); dev_info(&pdev->dev, "couldn't get charger regulator\n");
} }
charger->edev = extcon_get_edev_by_phandle(&pdev->dev, 0); charger->edev = extcon_get_extcon_dev("max8997-muic");
if (IS_ERR(charger->edev)) { if (IS_ERR_OR_NULL(charger->edev)) {
if (PTR_ERR(charger->edev) == -EPROBE_DEFER) if (!charger->edev)
return -EPROBE_DEFER; return -EPROBE_DEFER;
dev_info(charger->dev, "couldn't get extcon device\n"); dev_info(charger->dev, "couldn't get extcon device\n");
} }
if (!IS_ERR(charger->reg) && !IS_ERR(charger->edev)) { if (!IS_ERR(charger->reg) && !IS_ERR_OR_NULL(charger->edev)) {
INIT_WORK(&charger->extcon_work, max8997_battery_extcon_evt_worker); INIT_WORK(&charger->extcon_work, max8997_battery_extcon_evt_worker);
ret = devm_add_action(&pdev->dev, max8997_battery_extcon_evt_stop_work, charger); ret = devm_add_action(&pdev->dev, max8997_battery_extcon_evt_stop_work, charger);
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment