From patchwork Fri Jun 16 21:10:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Hauser X-Patchwork-Id: 693544 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 55BD2EB64D7 for ; Fri, 16 Jun 2023 21:11:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344628AbjFPVLW (ORCPT ); Fri, 16 Jun 2023 17:11:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbjFPVLV (ORCPT ); Fri, 16 Jun 2023 17:11:21 -0400 Received: from sonic311-31.consmr.mail.ir2.yahoo.com (sonic311-31.consmr.mail.ir2.yahoo.com [77.238.176.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2D8CD8 for ; Fri, 16 Jun 2023 14:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1686949878; bh=YjKr9kfUpqIEiBIGHJQUMWUtyBPUuXHIW1WGIJcpt2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=qOK92UQBcz4YTCNRW/ckInwSTYODoQGpaIcDCWIvecXWa5I8Vb9SAyq7k4que5nszxSJsmdqHWSPyXoAqDcHN2YKYgqeWd5DTDk3zGJ6c+j3zqYYpijPqz10s4e7ffeZl0IH1XGiAtTxGwSOmBBp1k+EgglnVUxgRVd+ccetxUuk/brW2ahvGnbKJyDa9sqvyzZ8vCyDCQCuJLTuQWKSNlKDF4uNRinq3NJTfhsfka5XVVT0WDlSqwjgLou+9QlhU5841UtFkxcLV5RplZ41T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JjxjeSOXlNcaSrMzoN1t qNK8Q4wxY6Guj8QT4wEs9I.Cf3ijOvfqXg_SjeUmjpxCkSXA2DmCiZ4YBAkmD5KkWk54FfZj3___ txy8GQLXRuXo7Pmo.FOO.S4y1nbExiSfNdF.IU.MScI5yv7eveaNBy1LwkRqEfeexcLVDuJsdg85 9Wz4M_hHJMmmRR4mOy50wPn6W2Ssz4EAnUPFEvfrM4yMJ9onu_OTHYK8PHYwskxL24Hlf1AY.YrI sAb7le599nRuOxOCGfaoNktC4LgH641RVpblADHXx5hOBMFm6TOfGV0Slqvlobyr8zUmoRQOVz_f FG6eHMgb83V_QYhjgYoRKEXpPjScSNy7IqjVlGqEAMJ2sYFpGAAenYcxWxGOwpcmbWcG6pkpBZto SVE6s4VlLLyCvYoxjFerEh81H2lyhzUblm98u08_X4rRKWnVOjOqK4U0Uvb9yVzz5qwipVyOhZOO AViwEts6h.F3VZowoSoy_oaJ5MT7RlJihYhfG6yC9wi9V09x4ZyBnKs.NdKQYizRBN7rfmCIRqX2 I143kwMeO4kr7NQSbUSf9tIF3a_ww.061IeMThKf5kv.AQoOWCUoVYLCYO_.OZ.qtUEoAIOear.n 9S8zROeEKdgyenXF_p2_6glhtDtLZS1LJtGJZpP33bYMSNvvMVqDJz05cwV8jkwHWxxNXR0XkSve H6cnQMf1te6pqA8uqYinJLOg9wd689fM3kiJzLP6zpAhK2MBkfGDWZs5cMWKYdVc2ovRjIGhiVNe mCtvw2i6hhf5HuZzBEq5p92E_vrFev995yg-- X-Sonic-MF: X-Sonic-ID: 03f28b74-5c07-42cd-8eba-1a8f59d9f5b9 Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.ir2.yahoo.com with HTTP; Fri, 16 Jun 2023 21:11:18 +0000 Received: by hermes--production-ir2-7867f454fc-gg9x8 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID c618d34c94eed5ad1e4505ee686233db; Fri, 16 Jun 2023 21:11:17 +0000 (UTC) From: Jakob Hauser To: Sebastian Reichel Cc: Lee Jones , Christophe Jaillet , Stephan Gerhold , Raymond Hackley , Henrik Grimler , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Jakob Hauser Subject: [PATCH 1/2] power: supply: rt5033_charger: Simplify initialization of rt5033_charger_data Date: Fri, 16 Jun 2023 23:10:47 +0200 Message-Id: <3936e777efe1e9d11462ce81bb177690b982a807.1686948074.git.jahau@rocketmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently the struct "rt5033_charger_data" is initialized rather complicated. The cause lies inside of the struct "rt5033_charger", where struct "rt5033_charger_data" is implemented as a pointer *chg. Therefore, inside of struct "rt5033_charger" change the struct "rt5033_charger_data" to non-pointer "chg". It is then initialized right away and can be accessed more easily. Signed-off-by: Jakob Hauser --- drivers/power/supply/rt5033_charger.c | 29 +++++++++++---------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/power/supply/rt5033_charger.c b/drivers/power/supply/rt5033_charger.c index e0303ca5a8db..361a36c2a195 100644 --- a/drivers/power/supply/rt5033_charger.c +++ b/drivers/power/supply/rt5033_charger.c @@ -28,7 +28,7 @@ struct rt5033_charger { struct device *dev; struct regmap *regmap; struct power_supply *psy; - struct rt5033_charger_data *chg; + struct rt5033_charger_data chg; struct extcon_dev *edev; struct notifier_block extcon_nb; struct work_struct extcon_work; @@ -130,7 +130,7 @@ static int rt5033_get_charger_const_voltage(struct rt5033_charger *charger) static inline int rt5033_init_const_charge(struct rt5033_charger *charger) { - struct rt5033_charger_data *chg = charger->chg; + struct rt5033_charger_data *chg = &charger->chg; int ret; unsigned int val; u8 reg_data; @@ -204,7 +204,7 @@ static inline int rt5033_init_const_charge(struct rt5033_charger *charger) static inline int rt5033_init_fast_charge(struct rt5033_charger *charger) { - struct rt5033_charger_data *chg = charger->chg; + struct rt5033_charger_data *chg = &charger->chg; int ret; unsigned int val; u8 reg_data; @@ -249,7 +249,7 @@ static inline int rt5033_init_fast_charge(struct rt5033_charger *charger) static inline int rt5033_init_pre_charge(struct rt5033_charger *charger) { - struct rt5033_charger_data *chg = charger->chg; + struct rt5033_charger_data *chg = &charger->chg; int ret; unsigned int val; u8 reg_data; @@ -539,21 +539,16 @@ static int rt5033_charger_get_property(struct power_supply *psy, return 0; } -static struct rt5033_charger_data *rt5033_charger_dt_init( - struct rt5033_charger *charger) +static int rt5033_charger_dt_init(struct rt5033_charger *charger) { - struct rt5033_charger_data *chg; + struct rt5033_charger_data *chg = &charger->chg; struct power_supply_battery_info *info; int ret; - chg = devm_kzalloc(charger->dev, sizeof(*chg), GFP_KERNEL); - if (!chg) - return ERR_PTR(-ENOMEM); - ret = power_supply_get_battery_info(charger->psy, &info); if (ret) - return ERR_PTR(dev_err_probe(charger->dev, -EINVAL, - "missing battery info\n")); + return dev_err_probe(charger->dev, -EINVAL, + "missing battery info\n"); /* Assign data. Validity will be checked in the init functions. */ chg->pre_uamp = info->precharge_current_ua; @@ -562,7 +557,7 @@ static struct rt5033_charger_data *rt5033_charger_dt_init( chg->pre_uvolt = info->precharge_voltage_max_uv; chg->const_uvolt = info->constant_charge_voltage_max_uv; - return chg; + return 0; } static void rt5033_charger_extcon_work(struct work_struct *work) @@ -679,9 +674,9 @@ static int rt5033_charger_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(charger->psy), "Failed to register power supply\n"); - charger->chg = rt5033_charger_dt_init(charger); - if (IS_ERR_OR_NULL(charger->chg)) - return PTR_ERR(charger->chg); + ret = rt5033_charger_dt_init(charger); + if (ret) + return ret; ret = rt5033_charger_reg_init(charger); if (ret)