From patchwork Sat Jan 30 17:30:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timon Baetz X-Patchwork-Id: 373931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 502C0C433E9 for ; Sat, 30 Jan 2021 17:31:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24A5D64DE1 for ; Sat, 30 Jan 2021 17:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232002AbhA3RbI (ORCPT ); Sat, 30 Jan 2021 12:31:08 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:54199 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231519AbhA3RbE (ORCPT ); Sat, 30 Jan 2021 12:31:04 -0500 Date: Sat, 30 Jan 2021 17:30:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1612027817; bh=oQy4RevNDWFClH37MnwytBl8YcA2kgCeFHUG6CufrzE=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=RyCG1sqmI4l0wPx1P5Qgj3Zu5LJqGikvt9h7HNMPTiRdk0Zg91K07J8dwktAtCZMR yQtNtj+aBRVs1md5Kd28/+p11tIJym2pbHhA5BvG2NJyA3qWSpFLLJmJrxVUSZjlwr JVRahuP3RPLPKTs3fsLeIHG/D87jly/ZQbQzbYW0= To: Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Rob Herring , Sebastian Reichel From: Timon Baetz Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org, Timon Baetz Reply-To: Timon Baetz Subject: [PATCH 3/3] power: supply: max8997_charger: Switch to new binding Message-ID: <20210130172747.2022977-4-timon.baetz@protonmail.com> In-Reply-To: <20210130172747.2022977-1-timon.baetz@protonmail.com> References: <20210130172747.2022977-1-timon.baetz@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Get regulator from parent device's node and extcon by name. Signed-off-by: Timon Baetz Reviewed-by: Krzysztof Kozlowski --- drivers/power/supply/max8997_charger.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c index 321bd6b8ee41..625d8cc4312a 100644 --- a/drivers/power/supply/max8997_charger.c +++ b/drivers/power/supply/max8997_charger.c @@ -168,6 +168,7 @@ static int max8997_battery_probe(struct platform_device *pdev) int ret = 0; struct charger_data *charger; 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 max8997_platform_data *pdata = iodev->pdata; struct power_supply_config psy_cfg = {}; @@ -237,20 +238,23 @@ static int max8997_battery_probe(struct platform_device *pdev) 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"); + pdev->dev.of_node = np; if (IS_ERR(charger->reg)) { if (PTR_ERR(charger->reg) == -EPROBE_DEFER) return -EPROBE_DEFER; dev_info(&pdev->dev, "couldn't get charger regulator\n"); } - charger->edev = extcon_get_edev_by_phandle(&pdev->dev, 0); - if (IS_ERR(charger->edev)) { - if (PTR_ERR(charger->edev) == -EPROBE_DEFER) + charger->edev = extcon_get_extcon_dev("max8997-muic"); + if (IS_ERR_OR_NULL(charger->edev)) { + if (!charger->edev) return -EPROBE_DEFER; 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); ret = devm_add_action(&pdev->dev, max8997_battery_extcon_evt_stop_work, charger); if (ret) {