Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2190296pxb; Sat, 2 Oct 2021 09:10:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0r93rkCa30ZusxPXMLGrAatUMRMtzm+HYrWfq90Hr+0XhDcpd5iXajq+OK1KG+1j7wF7f X-Received: by 2002:a17:906:3283:: with SMTP id 3mr5003215ejw.4.1633191031319; Sat, 02 Oct 2021 09:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633191031; cv=none; d=google.com; s=arc-20160816; b=1CGJRJVuu38NI40bbYHb5JrX0ggaZ3az8dLaZE1FWU7kApMHyl+9vsIqhepMkqagMn VH4Rx4KKiwLZWC0vI0LV8vj4vIhaaHr0T23qME5Y9uFy10uX1YNiiIr2pqsNgP6a+h+6 uCuylessXua49mPBsixIdIXGabc6/3DhMJmfdVU8FjuswHCZDRlxYu8hk9ZBLxBoFxcP 9yJ/EvhI7x+bgybv2v8+10itCwQqTw6qtwFslTKkR6pT/G+fwVmzn6DwwU+L4lq8CN+N AMA/FE+0i2VfmQJsL/vEb8lxEmECluU5jafSEt5Zhg7Ohk7kXiBQRf1kyyRgN6nmFOP7 W73w== 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; bh=kiwpBGodFWFfHCpkj8VrnKS/SEiyxKSPJUcKdT4cnn8=; b=W1F13DVZsgvWyFLDZjECqUj6orkHafqL4a7fBXcDT0LbPCPbRJHkUn4Pvr1jEkcbYB qXlcK5BssZQp5/KhKw1FfOxWJu2OCW+PzE8q/i62Prwx1ztWNf9F15sfih67DxZAkeXV AhQnWfxlr1Yvzp9IWPd/uruuUnm2wff3E2LQ+D9Io4Yhiz/23uXwtXO2mf0Te77lSuO8 Q2Fk75J6kc5qro7g6GLZ9Off0jmv17D06++RLv+TYF7UMunElAxEWMjVKHFBfnsiPuZ8 AL0HIhMLLukCArz4BuMf+LiqBXBqyHowZLrkxo2aTgys+TqpMtVsLtN6kywrJDP4BZI3 AmbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb8si8725189edb.579.2021.10.02.09.10.07; Sat, 02 Oct 2021 09:10:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233554AbhJBQFL (ORCPT + 99 others); Sat, 2 Oct 2021 12:05:11 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:57036 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232575AbhJBQFK (ORCPT ); Sat, 2 Oct 2021 12:05:10 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id BB6DF1F4418A Received: by earth.universe (Postfix, from userid 1000) id 7764F3C0CA8; Sat, 2 Oct 2021 18:03:20 +0200 (CEST) Date: Sat, 2 Oct 2021 18:03:20 +0200 From: Sebastian Reichel To: Tang Bin Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] power: supply: cpcap-battery: use device_get_match_data() to simplify code Message-ID: <20211002160320.24clt5v2nevynuco@earth.universe> References: <20210928020623.21192-1-tangbin@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="p5fpuwijhyki46dm" Content-Disposition: inline In-Reply-To: <20210928020623.21192-1-tangbin@cmss.chinamobile.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --p5fpuwijhyki46dm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue, Sep 28, 2021 at 10:06:23AM +0800, Tang Bin wrote: > In the function cpcap_battery_probe(), the driver only needs the > data object, so use device_get_match_data() instead, to make the > code cleaner. >=20 > Signed-off-by: Tang Bin > --- Thanks, queued. -- Sebastian > Changes from v1 > - change the title and commit message. > - change the code to use other api to make code simple. > --- > drivers/power/supply/cpcap-battery.c | 15 ++++----------- > 1 file changed, 4 insertions(+), 11 deletions(-) >=20 > diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/= cpcap-battery.c > index 8d62d4241..18e3ff0e1 100644 > --- a/drivers/power/supply/cpcap-battery.c > +++ b/drivers/power/supply/cpcap-battery.c > @@ -1026,20 +1026,13 @@ static const struct power_supply_desc cpcap_charg= er_battery_desc =3D { > static int cpcap_battery_probe(struct platform_device *pdev) > { > struct cpcap_battery_ddata *ddata; > - const struct of_device_id *match; > struct power_supply_config psy_cfg =3D {}; > int error; > + const struct cpcap_battery_config *cfg; > =20 > - match =3D of_match_device(of_match_ptr(cpcap_battery_id_table), > - &pdev->dev); > - if (!match) > - return -EINVAL; > - > - if (!match->data) { > - dev_err(&pdev->dev, "no configuration data found\n"); > - > + cfg =3D device_get_match_data(&pdev->dev); > + if (!cfg) > return -ENODEV; > - } > =20 > ddata =3D devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); > if (!ddata) > @@ -1047,7 +1040,7 @@ static int cpcap_battery_probe(struct platform_devi= ce *pdev) > =20 > INIT_LIST_HEAD(&ddata->irq_list); > ddata->dev =3D &pdev->dev; > - memcpy(&ddata->config, match->data, sizeof(ddata->config)); > + memcpy(&ddata->config, cfg, sizeof(ddata->config)); > =20 > ddata->reg =3D dev_get_regmap(ddata->dev->parent, NULL); > if (!ddata->reg) > --=20 > 2.20.1.windows.1 >=20 >=20 >=20 --p5fpuwijhyki46dm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmFYgsgACgkQ2O7X88g7 +pqV+A/+IWRbLr8ueUYq5cmxH1A/cnfQhibQuHCWDfQ7mZDld82vBzvi7xQ4MciH x5goyvXWZLX3ZB336fEoqZAwi7ve1PxB5s4NCFG08+adh4hxi+//yd+DslImSsbt oE3srIc3AiFArJ853omaUZp3hh4C0FmuXJP867LlMz+I4TUoDumF4wdBaVm+bwtQ tHPA7TrRl4wcgLI+p6BklVhIBDnZAnBMV2ypUiaJZLMLGLrnJ7XJ2jTWbPTrIqLf KEeHpJ1Rx4q3CR7FtgdpS7Haj01+9GoLd7IFCT5yQQsM83vCMxTpOxK0icCiK/e+ dI9l/hHfvJoTqoB1WLUG37oSS6A+suta0+ebkL0Xne0IaZSrAJgKtt6jgFtmiGWX i1tdNgpAQ1hsB8nwvkFGseL8tE9JGJFZEBFrUQIihBAynuOnqg1bGMcBJeWK7ppF UWWdko6Y7yDWQeCTQQfKqbY+oDxFJOJ4C3+L7o9T8SDRchAvh/fN3UpaGTrytkQx 7FmtuQ0u/FSu5x3vvab9zjtEJO9gyNxDBEZl7C2wTkE/erS9GaTJ33+4OR0dT674 Wnle0DZWfTGLwF3wiLCJOJYrFr3438b7RpmhseIoHIB/h+cgI69kYoede4w+Jjo6 bTn7dyFgHYrGDaCajGQbttOEF5nxcBp76fAsVF/JaVv9vrOi4L4= =lVLE -----END PGP SIGNATURE----- --p5fpuwijhyki46dm--