From patchwork Mon Feb 6 08:20:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13129472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 338C7C05027 for ; Mon, 6 Feb 2023 08:20:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229489AbjBFIUw (ORCPT ); Mon, 6 Feb 2023 03:20:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229789AbjBFIUv (ORCPT ); Mon, 6 Feb 2023 03:20:51 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09EB5144BE for ; Mon, 6 Feb 2023 00:20:49 -0800 (PST) Received: from dggpemm100007.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4P9K0G5FVbznW2d; Mon, 6 Feb 2023 16:18:38 +0800 (CST) Received: from huawei.com (10.175.103.91) by dggpemm100007.china.huawei.com (7.185.36.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 6 Feb 2023 16:20:47 +0800 From: Yang Yingliang To: CC: , , , Subject: [PATCH -next] power: supply: rt9471: fix using wrong ce_gpio in rt9471_probe() Date: Mon, 6 Feb 2023 16:20:25 +0800 Message-ID: <20230206082025.1992331-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100007.china.huawei.com (7.185.36.116) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Pass the correct 'ce_gpio' to IS_ERR(), and assign it to the 'chip->ce_gpio', if devm_gpiod_get_optional() succeed. Fixes: 4a1a5f6781d8 ("power: supply: rt9471: Add Richtek RT9471 charger driver") Signed-off-by: Yang Yingliang Reviewed-by: ChiYuan Huang Reviewed-by: ChiYuan Huang --- drivers/power/supply/rt9471.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/rt9471.c b/drivers/power/supply/rt9471.c index 5d3cf375ad5c..de0bf484d313 100644 --- a/drivers/power/supply/rt9471.c +++ b/drivers/power/supply/rt9471.c @@ -851,10 +851,12 @@ static int rt9471_probe(struct i2c_client *i2c) /* Default pull charge enable gpio to make 'CHG_EN' by SW control only */ ce_gpio = devm_gpiod_get_optional(dev, "charge-enable", GPIOD_OUT_HIGH); - if (IS_ERR(chip->ce_gpio)) + if (IS_ERR(ce_gpio)) return dev_err_probe(dev, PTR_ERR(ce_gpio), "Failed to config charge enable gpio\n"); + chip->ce_gpio = ce_gpio; + regmap = devm_regmap_init_i2c(i2c, &rt9471_regmap_config); if (IS_ERR(regmap)) return dev_err_probe(dev, PTR_ERR(regmap), "Failed to init regmap\n");