mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Maxime Chevallier" <maxime.chevallier@bootlin.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Matti Vaittinen" <mazziesaccount@gmail.com>,
	"Rodolfo Giometti" <giometti@enneenne.com>,
	"Marcelo Schmitt" <marcelo.schmitt@analog.com>,
	"Antoniu Miclaus" <antoniu.miclaus@analog.com>,
	"Angelo Dureghello" <adureghello@baylibre.com>,
	"Tobias Sperling" <tobias.sperling@softing.com>,
	"Eason Yang" <j2anfernee@gmail.com>,
	"Marilene Andrade Garcia" <marilene.agarcia@gmail.com>,
	"Cosmin Tanislav" <cosmin-gabriel.tanislav.xa@renesas.com>,
	duje@dujemihanovic.xyz, "Joshua Crofts" <crofts@kernel.org>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Victor Chernyakin" <chernyakin.victor.j@outlook.com>,
	herve.codina@bootlin.com, thomas.petazzoni@bootlin.com,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] iio: adc: add driver for Texas Instruments TLA2528 adc
Date: Sat, 14 Nov 2026 01:10:15 +0000	[thread overview]
Message-ID: <20261114011015.44831cf1@jic23-hlaptop> (raw)
In-Reply-To: <avcvfUcFwdJWjvs8@ashevche-desk.local>

On Fri, 13 Nov 2026 17:40:45 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Fri, Nov 13, 2026 at 04:15:42PM +0100, Maxime Chevallier wrote:
> > Add a new driver for the TI TLA2528 ADC chip. It has 8 12-bit
> > channels, that can also be configured as 16-bit averaging channels.  
> 
> I forgot to check if there is a justification of the brand new driver,
> I assume there is.
> 
> > This is a very simple driver, allowing reading raw values for each
> > channel. GPIO mode isn't supported for now, as well as buffered mode and
> > the 16-bit averaging mode.  
> 
> Some nit-picks below, but they do not prevent from this patch being accepted,
> so
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> 
Applied, I did the second of these suggestions as a tweak.

Thanks,

Jonathan

> ...
> 
> > +static int tla2528_read(struct tla2528 *tla2528, u8 channel, int *val)
> > +{
> > +	__be16 data;
> > +	int ret;
> > +
> > +	guard(mutex)(&tla2528->lock);
> > +
> > +	ret = regmap_update_bits(tla2528->regmap, TLA2528_CHANNEL_SEL_ADR,
> > +				 TLA2528_CHANNEL_SEL_MANUAL_CHID, channel);
> > +	if (ret)
> > +		return ret;  
> 
> Ideally this needs a comment explaining in short why regmap IO accessors may
> not be used.
I left this alone because there is a comment in probe. I'm not sure repeating
a comment that basically says 'because weird' is worth it.

> 
> > +	ret = i2c_master_recv(tla2528->client, (char *)&data, sizeof(data));
> > +	if (ret < 0)
> > +		return ret;
> > +	if (ret != sizeof(data))
> > +		return -EIO;
> > +
> > +	*val = be16_to_cpu(data) >> 4;
> > +
> > +	return 0;
> > +}  
> 
> ...
> 
> > +	ret = regmap_write(tla2528->regmap, TLA2528_GENERAL_CFG_ADR,
> > +			   TLA2528_GENERAL_CFG_RST);  
> 
> With locally defined
> 
> 	struct regmap *map;
> 	...
> 	map = devm_regmap_*init*(...);
> 	...
> 	tla2528->regmap = map;
> 	...
> 	ret = regmap_write(map, TLA2528_GENERAL_CFG_ADR, TLA2528_GENERAL_CFG_RST);
> 
> this can kill two birds with one stone:
> - make this one line (yes, 82 characters is okay)
> - keeping data structure free from error pointers
> 
diff --git a/drivers/iio/adc/ti-tla2528.c b/drivers/iio/adc/ti-tla2528.c
index c02b04e19785..754b31d6725f 100644
--- a/drivers/iio/adc/ti-tla2528.c
+++ b/drivers/iio/adc/ti-tla2528.c
@@ -128,6 +128,7 @@ static int tla2528_probe(struct i2c_client *client)
 	struct iio_chan_spec *channels;
 	struct iio_dev *indio_dev;
 	struct tla2528 *tla2528;
+	struct regmap *map;
 	int ret;
 
 	/*
@@ -148,9 +149,11 @@ static int tla2528_probe(struct i2c_client *client)
 	tla2528 = iio_priv(indio_dev);
 	tla2528->client = client;
 
-	tla2528->regmap = devm_regmap_init_i2c(client, &tla2528_regmap_config);
-	if (IS_ERR(tla2528->regmap))
-		return PTR_ERR(tla2528->regmap);
+	map = devm_regmap_init_i2c(client, &tla2528_regmap_config);
+	if (IS_ERR(map))
+		return PTR_ERR(map);
+
+	tla2528->regmap = map;
 
 	ret = devm_mutex_init(dev, &tla2528->lock);
 	if (ret)
@@ -179,8 +182,7 @@ static int tla2528_probe(struct i2c_client *client)
 	indio_dev->info = &tla2528_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	ret = regmap_write(tla2528->regmap, TLA2528_GENERAL_CFG_ADR,
-			   TLA2528_GENERAL_CFG_RST);
+	ret = regmap_write(map, TLA2528_GENERAL_CFG_ADR, TLA2528_GENERAL_CFG_RST);
 	if (ret)
 		return ret;
 
                                                   
                                 
> > +	if (ret)
> > +		return ret;  
> 


      reply	other threads:[~2026-11-14  1:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 15:15 [PATCH v4 0/2] " Maxime Chevallier
2026-11-13 15:15 ` [PATCH v4 1/2] dt-bindings: iio: adc: add Texas Instruments TLA2528 Maxime Chevallier
2026-11-13 15:15 ` [PATCH v4 2/2] iio: adc: add driver for Texas Instruments TLA2528 adc Maxime Chevallier
2026-11-13 15:26   ` Joshua Crofts
2026-11-13 15:36   ` Matti Vaittinen
2026-11-13 16:25     ` Maxime Chevallier
2026-11-13 15:40   ` Andy Shevchenko
2026-11-14  1:10     ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261114011015.44831cf1@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=adureghello@baylibre.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=chernyakin.victor.j@outlook.com \
    --cc=conor+dt@kernel.org \
    --cc=cosmin-gabriel.tanislav.xa@renesas.com \
    --cc=crofts@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=duje@dujemihanovic.xyz \
    --cc=giometti@enneenne.com \
    --cc=herve.codina@bootlin.com \
    --cc=j2anfernee@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=marilene.agarcia@gmail.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mazziesaccount@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tobias.sperling@softing.com \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®