Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3238428rwd; Fri, 16 Jun 2023 14:29:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6EKdEb6+D8f6Maykm4zw3n1nZJMeltomDjhNnvALZyG5JAole+OyeR88fTr3VFSLMErEgF X-Received: by 2002:a17:902:db0d:b0:1ac:750e:33d5 with SMTP id m13-20020a170902db0d00b001ac750e33d5mr3309523plx.15.1686950954880; Fri, 16 Jun 2023 14:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686950954; cv=none; d=google.com; s=arc-20160816; b=Ng94X+LQj203L9MRRECRt8h7WXUnOVHjNTIjTIFOoiUEwpW+V6x0FRmfAmzXrwu6w+ A7E2vIOmfHEGGaHemTtWLy7KXRQy02jHSJxru1jHlaEM9cDhO2hveutyhalYqi2gJVzF KT2lyqFAKv0vj5de3m8CsZAprTS2hWgQp++wLKQupLqVR/TxO8LFcEitE4sew8wet/wJ 0hm+lmtr4XnDdZYMYeaiTZKvlRjt++fjEdYRqguYZE2/+xajwmyCmdVpofreMbbe4b/U AHdLyqC2jck7MgaVZ8t97AfPmDP2CIsVuvri87SMhOmWuukq79sQUmycL2Qoa/gr34wW XIgA== 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=YjKr9kfUpqIEiBIGHJQUMWUtyBPUuXHIW1WGIJcpt2o=; b=adVAxwjRdwmZQnwMAZYg3gAIBXpjKXGerBi4w+hjucDfdWSQj/4qokBNDZLUSLqT4k 9bdEElQfvLu4AP4PCn/97qBKfOkkCoQcUPN9k1jble6GzwejbXS2+lruC5F5UeYprBp3 36Afhf//btqVTJ8aGxVVb/J+9hk727gl3TDbXhVZdAcEV1gcbiUzE0JWGFlqLs9prTFK ffwQabb46iLCGKAsIlZj5yGae5U9sX/rY95mY3bzChZs33Mi6VLKGjNoKCXGkQA+Lz/w sPpxa71Ic2thhsffqH43FkWlI3u+KbKQN+IOdFl3Kufhn9q8nFIbcxC5xNd2dg0AA24w WeiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rocketmail.com header.s=s2048 header.b=qOK92UQB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020a17090322d100b001a92f0f46fbsi16383039plg.436.2023.06.16.14.29.00; Fri, 16 Jun 2023 14:29:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rocketmail.com header.s=s2048 header.b=qOK92UQB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rocketmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230022AbjFPVLX (ORCPT + 99 others); Fri, 16 Jun 2023 17:11:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbjFPVLV (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 C6D45359D 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+9QlhU5841UtFkxcLV5RplZ41TZfnakBQFpdeYamx/DB0atocO+grUlzsCwPfBnn8hyj9EUJ545q1xrwtQGuwaB+AwA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1686949878; bh=xV9Ew2IZtRvoMvZ3PbQTQkgjLFdHGDcn51oVjLpziI5=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Fh8DIma2QIDPYYVdHjhdudItXi16ZqEt0Zam4tLBHMSsIHineJLTD+/E/idoA+DhYhVgFn/S1jMBGJrwx47rgF7qMCTlmxCp7RJEeZ1TxP4EiwzGvBzyxSQlS6jI+zZ7s7fsRFxaeD3MWCNyOb9QOfb8HjTt1s82wKtEsin4GujbM5dJ0oOJBXEj1zJIn05cqn0fyyNRhPBwX5mf2ZJKBMgryU+gqCjpRdFCUPzwVLU6WDE+ztXlfNoDbdnTmV6bldlR+LzjOL0yM0PEFgY+Lh0vzFOmXJuJWeYUlOUAKEmjFvwfhmJxu2B4v4dAxB3vZdp/udhUmwUYNL6Qi9ds3A== X-YMail-OSG: tu6Ow8cVM1kFUR5B8_LSKVkmjInbn1l7C2dK1MaB2XCCxYKpXhtm8Jl9i_HULnn wNL5dPW3rdJ2Ag_NG1jf2VZ7H7la7yUfsABxO3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wV8jkwHWxxNXR0XkSve 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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) -- 2.39.2