Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2839780rdh; Wed, 27 Sep 2023 14:36:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH45H1RzSGnmPqkfNPLELYsaddPycatqSweNW40A7N0PhGpw52RDMbllUaXiY6cfiztCRkW X-Received: by 2002:a05:6808:1294:b0:3ae:5372:3790 with SMTP id a20-20020a056808129400b003ae53723790mr4000072oiw.48.1695850566179; Wed, 27 Sep 2023 14:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695850566; cv=none; d=google.com; s=arc-20160816; b=Q2hwTEz0ZRnF0vhO/GUgAQASo0bDztWE1FRr9DZyr6hggtankIZ3gbWSQ5DP7gevkv e50PNplZQHdG2CSqPJsyVtYU10Oqka+nfc4qZXmRzsS2WTxrELuNNgo8dHqRG6kEYecJ gz9dFZqFx/gYX8m64wyyIiFsC8KV0UUptIBLp96fLrKnPsNknib0rcgX75KDMym6VBKF qGq5cnjDGlybvd7sgAZvzANJvplzVtH25GaVGTlQ3eWFvbaPJtuVf+cgAeI2n48G/P3p pYGC51bp60SJipjP4LQeAJ4cJ7rKDOlSIscATF9TeNgV3wfe9mYsdDRcF5X2n30G5k9b j9bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5xyF+KReJNWWxWCi7Ez3mVy/VMtqQScvdho4KTEIt0E=; fh=nz7VNHiZPehN5kI1Zu9EriA/WIR1rcAjRtHa5jFbAAo=; b=FQKSVnyLPQxA3RAlYfJD1JZRT1oX/BvEYTwkbbbMp6PmguwCzFYe6q+ShPT6GHmCTm cooNZE1PgG/wVMwINOGOx6h/Qagj0TfTki3i7IdQKDltmhd0Xs1d+aD/elJLAuzdhvEc oFNfciXBQr5jFrNWP2wVlbr1jvTftggZEon2/PNR5PUsJ+3BgD9f344XmNXF/eqy8Hs6 Eoq9bAeRJGV29eS1cHUufTB6Ag3sTK1UWckAKG4KWwa92GOcGjNfaCu1c+Tf89vI0riK GhWK8MkrIXolxUfi51VwijIReeYx5qUN1ia1KLUUb9baH7adDf3Yhqr7K2pWNz6yP8B+ adVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rocketmail.com header.s=s2048 header.b=A1ki3GZ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rocketmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id bv70-20020a632e49000000b0056f7f18bbfdsi16026203pgb.632.2023.09.27.14.36.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 14:36:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@rocketmail.com header.s=s2048 header.b=A1ki3GZ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rocketmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id A33FF8098B03; Wed, 27 Sep 2023 13:27:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbjI0U0g (ORCPT + 99 others); Wed, 27 Sep 2023 16:26:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbjI0U00 (ORCPT ); Wed, 27 Sep 2023 16:26:26 -0400 Received: from sonic307-54.consmr.mail.ir2.yahoo.com (sonic307-54.consmr.mail.ir2.yahoo.com [87.248.110.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6911121 for ; Wed, 27 Sep 2023 13:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1695846381; bh=5xyF+KReJNWWxWCi7Ez3mVy/VMtqQScvdho4KTEIt0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=A1ki3GZ2UgkUpg4cmRNHiLh8DOeQPyz4SQiEWjFd42AzVz7UGlWLG/yIncW8Ml/7TeSKl/o/SrqQam9a6gWkt0rdtP1dfbZUJ+etWzfHxmiu8PfAVrrzK0QXwEqqbeUBb0qUP7q23Y1p2RXyNBS8ANnloAjN0zKcr5GYGqpOjf+TnhYv7uULaibD+hHqdfCr5Ad1ZJ5K9E3FPvXOBf7PlSfaW4OGU1STkte+i8afkVvy5zU4IC59ObIo8JcRbf4PGevDIKR7/Ot8WOBOUWF1kxQ4qcFmEjAi1zqmUmtccptG2wGJCzD6xNzM66y9/ftW/y4s65h91WGsbGESy/gt3g== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1695846381; bh=Wb28mO+t+8IOr2hAdJHoSdh7nqXlI4Bo3bWZKM9csLN=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=CNDM5w0hsc/zHlvtktGuWlk1R60RfOnMaDJE7aSLes9xYLHH1jGhPcNN0eA4Oisyhr43jyIeljg1+Nd2lWBQOUZeKeyl0ldktUvPDFIi4p6cHhfqImRh9Mwsi9ZAX2t1U8ZCsi4y1EIhkHb+RyOo2DNk6LkjgfbByPLZX12kOWQISe6GPIuep928A1QoCBhqTS4Ae9+MjwbM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CkVKJWGizvu9TxZYbdDqDzTQvTLSVL5e.FcO4 cyhVFndB4NcLCURsN_y_izOUOx8jwgOdS7qCnQ9foteqWBgrzLI6funIdTYVeaIJ1bGyTJDyWe4o BMzbid7h.vZHPJTndQ9WTXKaHpdedi_ScAJ_i5rOGel62gjWjRGm.yO4fcYOL9HJ9lOyljFNDdUe SNeC1TxBEU8fUTpjX5PiM4Ugd.qgV08wIwRnuV9PeWqXSD5b_UGF7__GnJn7aWllLmHa5BJlwy87 JpFx6UOb.WoNskA.OomzjKd6m3L.80aiggwzXmH5ehQl4N2mnbjL3mXpM1tKBEF6jk4UaCbq_XSM EjmfYn9JDKIg8g18flKokyHXMmJ2Lbnns.OiT X-Sonic-MF: X-Sonic-ID: dc664729-052d-4421-9fec-a3471547cf86 Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.ir2.yahoo.com with HTTP; Wed, 27 Sep 2023 20:26:21 +0000 Received: by hermes--production-ir2-55db9d9d5-5hvhf (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 1d998f486e26fd309cd8d11c694d3a2b; Wed, 27 Sep 2023 20:26:18 +0000 (UTC) From: Jakob Hauser To: Sebastian Reichel Cc: Lee Jones , Stephen Rothwell , Yang Yingliang , Christophe Jaillet , Stephan Gerhold , Raymond Hackley , Henrik Grimler , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Jakob Hauser Subject: [PATCH 4/5] power: supply: rt5033_charger: Simplify initialization of rt5033_charger_data Date: Wed, 27 Sep 2023 22:26:01 +0200 Message-Id: <95e236e16e25978d1a0280302cecd3bf59687e98.1695844349.git.jahau@rocketmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 27 Sep 2023 13:27:15 -0700 (PDT) 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 091ca4a21f29..b34ef0ea6f8a 100644 --- a/drivers/power/supply/rt5033_charger.c +++ b/drivers/power/supply/rt5033_charger.c @@ -29,7 +29,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; @@ -131,7 +131,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; @@ -205,7 +205,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; @@ -250,7 +250,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; @@ -550,21 +550,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; @@ -573,7 +568,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) @@ -690,9 +685,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) -- 2.39.2