From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24B431C2D for ; Sat, 6 Aug 2022 17:53:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94870C433C1; Sat, 6 Aug 2022 17:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659808407; bh=N4R6bAIgXf+qR39Qf/icSXDtbAcXLXJGvEsDtUbR9K8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RDKmkPqLK9JBNONow6WuECuYOe71VLiYyxMRujjqpc3fiZ5H1YG8ki07yccB2m/uU BR/EVwIyFTQALbGMMItSqlLF72BZt951zzF2yhRcB9bvcUqFyys61w77nn0J3NyXvu 9QEP9BBw1lG78sCp+DHTGYA+bIExSwKvRzhV+ng62G3KIvUr5W9NXn/vKoMvzHDz6J TdxnKGhhJphslZ+ozkKxIibsIbj0KhW1OCrhnEgYwFoUw7+V44ScBM0ANOX8xtEh2e LJHDYSa5Iy4AevyL9LNtrdBM1TtuoDK+Jgh0S6tmo5FZMyrw7rO0IBr7eVNT2lkOmX EHsYtlpSnMYDA== Date: Sat, 6 Aug 2022 19:03:37 +0100 From: Jonathan Cameron To: Nuno =?UTF-8?B?U8Oh?= Cc: , , , , , , , , , Lad Prabhakar , , Gwendal Grignou , Saravanan Sekar , Tomer Maimon , Maxime Coquelin , "Alexandre Torgue" , Lorenzo Bianconi , Fabio Estevam , Shawn Guo , "Olivier Moysan" , Tali Perry , Thara Gopinath , Bjorn Andersson , Arnd Bergmann , Benjamin Fair , Nicolas Ferre , "Rafael J. Wysocki" , Patrick Venture , Pengutronix Kernel Team , Fabrice Gasnier , Daniel Lezcano , Benson Leung , Nancy Yuen , Miquel Raynal , "Alexandre Belloni" , Zhang Rui , Linus Walleij , Christophe Branchereau , Cai Huoqing , Avi Fishman , Eugen Hristev , Matthias Brugger , Sascha Hauer , Lars-Peter Clausen , "Andy Shevchenko" , Guenter Roeck , Paul Cercueil , Claudiu Beznea , Andy Gross , Amit Kucheria , Michael Hennerich , "Haibo Chen" , Jishnu Prakash Subject: Re: [PATCH v3 08/15] iio: adc: ab8500-gpadc: convert to device properties Message-ID: <20220806190337.5f3086c9@jic23-huawei> In-Reply-To: <20220715122903.332535-9-nuno.sa@analog.com> References: <20220715122903.332535-1-nuno.sa@analog.com> <20220715122903.332535-9-nuno.sa@analog.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, 15 Jul 2022 14:28:56 +0200 Nuno S=C3=A1 wrote: > Make the conversion to firmware agnostic device properties. As part of > the conversion the IIO inkern interface 'of_xlate()' is also converted to > 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF > dependencies from IIO. >=20 > Signed-off-by: Nuno S=C3=A1 > Acked-by: Linus Walleij > Reviewed-by: Andy Shevchenko Nitpick, but ideally this would have been two patches.=20 1) Drop parameter to *_parse_channels()=20 2) the rest. As that little corner was hardert o check than the rest :) meh. It's trivial as I said, otherwise looks good to me. Jonathan > --- > drivers/iio/adc/ab8500-gpadc.c | 27 ++++++++++++--------------- > 1 file changed, 12 insertions(+), 15 deletions(-) >=20 > diff --git a/drivers/iio/adc/ab8500-gpadc.c b/drivers/iio/adc/ab8500-gpad= c.c > index 930ce96e6ff5..4fa2126a354b 100644 > --- a/drivers/iio/adc/ab8500-gpadc.c > +++ b/drivers/iio/adc/ab8500-gpadc.c > @@ -925,8 +925,8 @@ static int ab8500_gpadc_read_raw(struct iio_dev *indi= o_dev, > return -EINVAL; > } > =20 > -static int ab8500_gpadc_of_xlate(struct iio_dev *indio_dev, > - const struct of_phandle_args *iiospec) > +static int ab8500_gpadc_fwnode_xlate(struct iio_dev *indio_dev, > + const struct fwnode_reference_args *iiospec) > { > int i; > =20 > @@ -938,7 +938,7 @@ static int ab8500_gpadc_of_xlate(struct iio_dev *indi= o_dev, > } > =20 > static const struct iio_info ab8500_gpadc_info =3D { > - .of_xlate =3D ab8500_gpadc_of_xlate, > + .fwnode_xlate =3D ab8500_gpadc_fwnode_xlate, > .read_raw =3D ab8500_gpadc_read_raw, > }; > =20 > @@ -968,7 +968,7 @@ static int ab8500_gpadc_runtime_resume(struct device = *dev) > /** > * ab8500_gpadc_parse_channel() - process devicetree channel configurati= on > * @dev: pointer to containing device > - * @np: device tree node for the channel to configure > + * @fwnode: fw node for the channel to configure > * @ch: channel info to fill in > * @iio_chan: IIO channel specification to fill in > * > @@ -976,15 +976,15 @@ static int ab8500_gpadc_runtime_resume(struct devic= e *dev) > * and define usage for things like AUX GPADC inputs more precisely. > */ > static int ab8500_gpadc_parse_channel(struct device *dev, > - struct device_node *np, > + struct fwnode_handle *fwnode, > struct ab8500_gpadc_chan_info *ch, > struct iio_chan_spec *iio_chan) > { > - const char *name =3D np->name; > + const char *name =3D fwnode_get_name(fwnode); > u32 chan; > int ret; > =20 > - ret =3D of_property_read_u32(np, "reg", &chan); > + ret =3D fwnode_property_read_u32(fwnode, "reg", &chan); > if (ret) { > dev_err(dev, "invalid channel number %s\n", name); > return ret; > @@ -1021,22 +1021,20 @@ static int ab8500_gpadc_parse_channel(struct devi= ce *dev, > /** > * ab8500_gpadc_parse_channels() - Parse the GPADC channels from DT > * @gpadc: the GPADC to configure the channels for > - * @np: device tree node containing the channel configurations > * @chans: the IIO channels we parsed > * @nchans: the number of IIO channels we parsed > */ > static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc, > - struct device_node *np, > struct iio_chan_spec **chans_parsed, > unsigned int *nchans_parsed) > { > - struct device_node *child; > + struct fwnode_handle *child; > struct ab8500_gpadc_chan_info *ch; > struct iio_chan_spec *iio_chans; > unsigned int nchans; > int i; > =20 > - nchans =3D of_get_available_child_count(np); > + nchans =3D device_get_child_node_count(gpadc->dev); > if (!nchans) { > dev_err(gpadc->dev, "no channel children\n"); > return -ENODEV; > @@ -1054,7 +1052,7 @@ static int ab8500_gpadc_parse_channels(struct ab850= 0_gpadc *gpadc, > return -ENOMEM; > =20 > i =3D 0; > - for_each_available_child_of_node(np, child) { > + device_for_each_child_node(gpadc->dev, child) { > struct iio_chan_spec *iio_chan; > int ret; > =20 > @@ -1064,7 +1062,7 @@ static int ab8500_gpadc_parse_channels(struct ab850= 0_gpadc *gpadc, > ret =3D ab8500_gpadc_parse_channel(gpadc->dev, child, ch, > iio_chan); > if (ret) { > - of_node_put(child); > + fwnode_handle_put(child); > return ret; > } > i++; > @@ -1081,7 +1079,6 @@ static int ab8500_gpadc_probe(struct platform_devic= e *pdev) > struct ab8500_gpadc *gpadc; > struct iio_dev *indio_dev; > struct device *dev =3D &pdev->dev; > - struct device_node *np =3D pdev->dev.of_node; > struct iio_chan_spec *iio_chans; > unsigned int n_iio_chans; > int ret; > @@ -1096,7 +1093,7 @@ static int ab8500_gpadc_probe(struct platform_devic= e *pdev) > gpadc->dev =3D dev; > gpadc->ab8500 =3D dev_get_drvdata(dev->parent); > =20 > - ret =3D ab8500_gpadc_parse_channels(gpadc, np, &iio_chans, &n_iio_chans= ); > + ret =3D ab8500_gpadc_parse_channels(gpadc, &iio_chans, &n_iio_chans); > if (ret) > return ret; > =20