Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp867407rdb; Sun, 1 Oct 2023 08:45:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFW2QJEQ0NM4+BCAmI8PEN4qP1eVKJPuH29i1sd5eLPE6y7sNuONhWrWCsiUo6cH1AKWBOQ X-Received: by 2002:a05:6a20:8f26:b0:15a:7d2:a418 with SMTP id b38-20020a056a208f2600b0015a07d2a418mr13979633pzk.19.1696175151096; Sun, 01 Oct 2023 08:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696175151; cv=none; d=google.com; s=arc-20160816; b=Q+wi1bzxK4j/ulpQGSp5R3lPtGFcviaX7XUyfhbv8Wxx8h8rZfds7MXQorGxUzAlXQ DwoHFjCgjqDsXzklZMQYCFQYpvJjLZggFMIWTi5w/loibKyMBsIJUK/sqesPhXDPuJPj 5xsVCYU/RlvCCUr2RWDKkQNNBJZQmaHI4sP+du+9elBiRj9Dk/Z8DN2V0VDCjhWDboRy vzSQdNvleZ+F6dBgNxU53rSSvp6TMO0dc8ZPHIT1xXz9ibx2nGfmKGRGUs6Tuv+nN1jH XNm6KEgG/7In9FFWzYKHRRjZ4s6xabHroBvRl35nivAvTTwttG7Kct7ELIeijrYDSmx2 jM7g== 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=I397u19ShYOwXa+3mT/VH8DS1ZieGKsk5opSRxRnjNrapvQP1fWvvV9RuGhtyosaps k7xXEMwCFdejrY+50GlvIvdv0zq406QfDPGW23ZmIExxlnP5MBodyQBzISeWp5MHgmjC V0CcuY+My166r2EebzRh/dJ8R0/tOQpfFk+L1fJsG6TxzBNbCO7YvLCrw4AlmVPlyOIp BR/zPbjoD4UM0bRgEkMmQbCElrDmMQCAA8GnqaFDwkY45cIZu6kkdwnTRQU/oGeydRur YTcCvXuWEoU22kijER/sE7uozCzHdNb4/0+rV8yGUk155UK7fgBZteccUfBT6IyAsu42 TTug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rocketmail.com header.s=s2048 header.b=J0JYfMjy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id ck7-20020a056a00328700b0068fb8fa1e71si18360747pfb.207.2023.10.01.08.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 08:45:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@rocketmail.com header.s=s2048 header.b=J0JYfMjy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 21C7A8022EAA; Sun, 1 Oct 2023 06:18:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235012AbjJANSH (ORCPT + 99 others); Sun, 1 Oct 2023 09:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234993AbjJANSE (ORCPT ); Sun, 1 Oct 2023 09:18:04 -0400 Received: from sonic301-21.consmr.mail.ir2.yahoo.com (sonic301-21.consmr.mail.ir2.yahoo.com [77.238.176.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37A91BC for ; Sun, 1 Oct 2023 06:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1696166280; bh=5xyF+KReJNWWxWCi7Ez3mVy/VMtqQScvdho4KTEIt0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=J0JYfMjyRncz4s9KNUJfV1mhF3dkeK0MlhNqvV81fixw+6OTC1G246mJ2pDtTYWAkGLDHHqwihRzKduGmePVFtgrTLT6D+wYafLqVkgKbNFONQ3yyPZJR99ankkItaFoq6NZwOxcAn1DDHuPwbnM0qrxYqIEibvKcZ8P1Je6DcPjJu70GQOmf/ulr5qNE66NCOcW6vtjH2rPrgokKs33rrP7RZTUXXh73kBejbIXebelrAYnhwP4I92GD4/H7vw/+jlcxDfmom0DITBWmT6TvcN52KxOROxXfvr8Lb21kj/u+6mqmEr/cFdlVMQQczxcU4BuW+/M7IO/Sh104des7Q== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1696166280; bh=qfPIYl9u1Ofy1BNQjRpSAaml4adrrYUU4HmpkXR4ONL=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Gkk7WsSmnLHjhE2+cXGH9Bkz+RtqxnpnDxdb6UrmcKRL8xFbQLkRj2/Gr9WWo3qxsRYZpGE1rRFTbxTavywc133pztW2gMsIMbjYrgJcArelf6Eg+JCWYoqgN2uPu5WGsUY4CvDkD45KAmp6KZ+QFdFTTo/BNYCae2SQk5W1+mEUswldNj6Uh3YoyMqrofYM0/yioiq8AmNOuK4BSMcSizADvm+P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7h3u2PrU_bnN8Qsz2gVb2GS1rK3bxof9es5FYqt_TWGq1b05JrdQtTIyLOMzsv5bTfubTFI 2PdS4PZP5MfHTLccioSFT6cHmT4cRqCrqJNpt80.vy6JA5XYRze_BbgLq73i35Xm3wRscci8np_V kMaXu7ttjz3p3IgrhzEYjUzoGLhRFkidhNcRx2VSJBkkrBMpM38GIebWSt.2lJbuMnVIFyD3IGjI AvnJVEgCQPm4HrcdeR..UGkgsYUsxK4pEoLtJvcTwCKjv9ocu2LQruWnYmXf2KlcGvLF46Cn65O7 UpqrZlepnZrR31ob3SeGbBH_vnisiTA-- X-Sonic-MF: X-Sonic-ID: af00d58e-3114-4afa-9a0e-10712531b56f Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ir2.yahoo.com with HTTP; Sun, 1 Oct 2023 13:18:00 +0000 Received: by hermes--production-ir2-55db9d9d5-gk4f2 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID f1c2828dd5bee1de58f8566f5b57afb9; Sun, 01 Oct 2023 13:17:58 +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 v2 2/3] power: supply: rt5033_charger: Simplify initialization of rt5033_charger_data Date: Sun, 1 Oct 2023 15:17:43 +0200 Message-Id: <0aff8c2a18cf4b88ec3333f6679a8419dd76ca29.1696165240.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 pete.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 (pete.vger.email [0.0.0.0]); Sun, 01 Oct 2023 06:18:33 -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