Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1347205rwd; Sun, 14 May 2023 18:12:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5MKfNB71/piLVd6GFtwpnBiD19qVB2eYhNK/+FikpBierge2NDhsNn9D+6pHT16gBhwJFw X-Received: by 2002:a17:90b:b15:b0:246:bb61:4a56 with SMTP id bf21-20020a17090b0b1500b00246bb614a56mr31466939pjb.27.1684113164700; Sun, 14 May 2023 18:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684113164; cv=none; d=google.com; s=arc-20160816; b=JD0MVJ05UuNGytWEIhpMSPjrPhzm4FAGwa3JAxv3wKEdQ3g5kIS2XVLPpWbAIe8Vwt pnPBWHYd8XLb67O9ZxkyWcAtS2Ma/Z8rGFDYXCd6ECkcHzHUJd5DKIMtLSWiOFjMcjQf rgEeg3V3/N3hOksx2AolLMUjwSM7DrKhIPwStqB2DJStJXWHO4pr/2R9b62gyeiELtua IP3HQIzB4UA6HlsEpeSlf8pCS77GSEpJHJAquTTQqsM8khMavO6njNMc2nsl0PaJ6GhU tZOzLnFrdU4Z6JoszI7tpE6X+ITtSiCEEOygS/7GHIe658IyUuY8nEtm1r+8ERPyCLNR MWfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HBaIPtRy2JvJvERUL98xKYSMYmji4sKGQW2XFVBgjTs=; b=ApJKB/0nRK66sKRoqeXSIjUxdZKCz+8DLw+lHExrCYoLR2jvmmP+F/8MR9h85ypvD4 TIuQt5SMFe6iLoDDDXk466EWzNuapHeWGu2a4bo8YBL0oKyIqb6jrCsM/c3RModtxalG R40eDo0zVGV67bXsRc7+PwnRF9h2e1p0jLNT94/rU1w/bZ07pMBKZ/c5+q+fQYPO6bVK Rrg179A1o2/T9QTf83F78DXry2K5n5vNKvrXeZj3POz5f6csgW2TyXYWtifMAbgHei4w oyiO6ORN0Wzmi+W5JbrZijkNZn+ZZ0vM1RiieDNCUJNSanDWD9LcgDb7qzMVcMxxmoZW F1zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="UZ/Mi+tp"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f15-20020a17090ac28f00b002477fad79d5si27684051pjt.63.2023.05.14.18.12.32; Sun, 14 May 2023 18:12:44 -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=@collabora.com header.s=mail header.b="UZ/Mi+tp"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232859AbjENWvO (ORCPT + 99 others); Sun, 14 May 2023 18:51:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbjENWvN (ORCPT ); Sun, 14 May 2023 18:51:13 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B04110EA; Sun, 14 May 2023 15:51:12 -0700 (PDT) Received: from mercury (unknown [185.209.196.239]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id B4ABD660574D; Sun, 14 May 2023 23:51:10 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1684104670; bh=5X6s/35EjIL/j/tIEBwv4UCLHvPjHhXLzzfqo9HA6O4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UZ/Mi+tp3zrvSBufhtKmx4NGodOrfTryMzjxzIu3IwVG8CdHf0NxcW4FRKr9ztofe b+XVurqqf301WnIrYSbxpyeMIwbpmyr2w4DAdpL2+xb+tbAN110T4oGKbXDZ7tQ5Qb cfpgHyYJnQe8wphN/HLZokqiwq0QYH7QyU3JvcATMGpN5G0vvoDbeORwxFbb0ky4lx 3MYiOC5y76DWeplSwFGNBHDowYyIyxMdmiwr9QOdm4rRpVUH5nACHnkRsjUYSwyEhD blul3AlIbAlAV1m4FjG4IxglGUWQh6jLTO7JhhTOB4PnT1lMzvSNV1oCvLqfP3U6FC LI+SukIZZJEBA== Received: by mercury (Postfix, from userid 1000) id 4949B1061381; Mon, 15 May 2023 00:51:08 +0200 (CEST) Date: Mon, 15 May 2023 00:51:08 +0200 From: Sebastian Reichel To: Jakob Hauser Cc: Christophe JAILLET , Lee Jones , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Beomho Seo , Chanwoo Choi , Stephan Gerhold , Raymond Hackley , Pavel Machek , Axel Lin , ChiYuan Huang , Linus Walleij , Henrik Grimler , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht Subject: Re: [PATCH v5 05/10] power: supply: rt5033_charger: Add RT5033 charger device driver Message-ID: <20230514225108.pkn2zufrfgic7r4c@mercury.elektranox.org> References: <20230514123130.41172-1-jahau@rocketmail.com> <20230514123130.41172-6-jahau@rocketmail.com> <2e0f37ef-b80c-1a4d-2159-29598ac11156@wanadoo.fr> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="32wuacfcnymnc56n" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 --32wuacfcnymnc56n Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Sun, May 14, 2023 at 07:03:03PM +0200, Jakob Hauser wrote: > Hi Christophe, Hi all, >=20 > On 14.05.23 16:31, Christophe JAILLET wrote: > > Le 14/05/2023 =E0 14:31, Jakob Hauser a =E9crit=A0: >=20 > ... >=20 > > > +static int rt5033_charger_probe(struct platform_device *pdev) > > > +{ > > > +=A0=A0=A0 struct rt5033_charger *charger; > > > +=A0=A0=A0 struct power_supply_config psy_cfg =3D {}; > > > +=A0=A0=A0 int ret; > > > + > > > +=A0=A0=A0 charger =3D devm_kzalloc(&pdev->dev, sizeof(*charger), GFP= _KERNEL); > > > +=A0=A0=A0 if (!charger) > > > +=A0=A0=A0=A0=A0=A0=A0 return -ENOMEM; > > > + > > > +=A0=A0=A0 platform_set_drvdata(pdev, charger); > > > +=A0=A0=A0 charger->dev =3D &pdev->dev; > > > +=A0=A0=A0 charger->regmap =3D dev_get_regmap(pdev->dev.parent, NULL); > > > + > > > +=A0=A0=A0 psy_cfg.of_node =3D pdev->dev.of_node; > > > +=A0=A0=A0 psy_cfg.drv_data =3D charger; > > > + > > > +=A0=A0=A0 charger->psy =3D devm_power_supply_register(&pdev->dev, > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 &rt5033_charger_desc, > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 &psy_cfg); > > > +=A0=A0=A0 if (IS_ERR(charger->psy)) > > > +=A0=A0=A0=A0=A0=A0=A0 return dev_err_probe(&pdev->dev, PTR_ERR(charg= er->psy), > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "Failed= to register power supply\n"); > > > + > > > +=A0=A0=A0 charger->chg =3D rt5033_charger_dt_init(charger); > > > +=A0=A0=A0 if (IS_ERR_OR_NULL(charger->chg)) > >=20 > > Hi, > >=20 > > Nit: charger->chg can't be NULL. > >=20 > > > +=A0=A0=A0=A0=A0=A0=A0 return -ENODEV; > >=20 > > Why bother returning specific error code in rt5033_charger_dt_init() if > > they are eaten here. > >=20 > > return PTR_ERR(charger->chg)? > >=20 >=20 > Thanks for the heads-up. >=20 > ... >=20 > Writing towards the list: >=20 > The way it is done in the current patchset is taken from the original > patchset of March 2015 [2]. I kept the original as far as possible. >=20 > By now I'm not happy with the way of initializing "struct > rt5033_charger_data". I realized this in the course of the review. As I > didn't want to disturb the review with this, I had planned a small clean-= up > patch after this review is finished. >=20 > The cause of the complicated handling of "struct rt5033_charger_data" lies > inside of the "struct rt5033_charger". There the "struct > rt5033_charger_data" is initialized as pointer *chg. >=20 > The clean-up would be: >=20 > - Inside of "struct rt5033_charger" change the > "struct rt5033_charger_data" to non-pointer "chg". It is then > initialized right away. >=20 > struct rt5033_charger_data chg; >=20 > - Change function rt5033_charger_dt_init() from type > "struct rt5033_charger_data" to type "int". >=20 > static int rt5033_charger_dt_init(struct rt5033_charger *charger) >=20 > - In the probe function, call the function rt5033_charger_dt_init() in > the same way like e.g. the following rt5033_charger_reg_init(): >=20 > ret =3D rt5033_charger_dt_init(charger); > if (ret) > return ret; >=20 > - Within function rt5033_charger_dt_init() and all other functions > using the charger data, get the address of the already-initialized > struct &charger->chg. >=20 > struct rt5033_charger_data *chg =3D &charger->chg; >=20 > This would also solve the issue reported by Christophe because the errors > inside function rt5033_charger_dt_init() would be passed to the probe > function by the "ret =3D" and being returned there with "return ret". >=20 > I'm not sure how to handle this now. I would prefer to get the review of > this patchset finished and send a clean-up patch afterwards. >=20 > [2] https://lore.kernel.org/lkml/1425864191-4121-1-git-send-email-beomho.= seo@samsung.com/T/#u Sounds sensible, until then please use 'return PTR_ERR(charger->chg)' as suggested by Christophe. With this fixed: Acked-by: Sebastian Reichel -- Sebastian --32wuacfcnymnc56n Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmRhZdsACgkQ2O7X88g7 +pqqGA/5Afn0kyYuYYCNeFMbpA31bUx5pcgtxQm3ln66uNZTQK5BOgyxagGQnTFY 6lDDlMrWSNTe5gd/OehNmA9YPqKgREqZA4uVrC7LFrb2bghL5GCReDx3onB0rsKP 7qb2wfG0vQs0eAFC7BMwHiLfxpdc6X5y9KWP55rW2bI8PFGDoDNNNw3SvyyvMbXi GY7+fWE75LluZmRNXOko1SK6OsuOLlHE6jsmilqgNVKadLZx3Q+wjLvttS1m4WnY 1RNs7YWgnXdjEaoEXm6NtfMnbJMilCSfBDn2brlhfNTjNWxaHvdLEUH0ZOgscM0C UMl8BALb66LFFDHnO5Ok5YOqkZKo4S/ckTelc6LTeh/Y55Tl5lBR3LJwUKz92XjD SXIAWWpnqGls4zHyMNknqdLMTj39dB3Sp10x+Eg+R16ceOL/YGotn+9p0v9JHcy4 njIf0y2kyeQa6xjRBQ6/j0RACvQKTkEazB4nDBJ92suehdUX8xXSji8FgWEQpiSy h9fhWh90KKHdy47kXP8oSb4xjmlX6tlXrjNv5ms2ayUL6hdlSB4C5B+Z4BnLjsaL UVrY1WaezXoxpdV64Ft7+UqynRNsYb++zGLdzNV1wd9qa16i/XFwAD073pGoNjoo AnPtnUc61zdidPSNPrRBRw5J+HwPyelqxUo6DID+tdeCVkqWZvA= =Zev5 -----END PGP SIGNATURE----- --32wuacfcnymnc56n--