mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Lechner <dlechner@baylibre.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"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>,
	"Kurt Borja" <kuurtb@gmail.com>,
	"Nguyen Minh Tien" <zizuzacker@gmail.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] iio: adc: add ti-ads112c14 driver
Date: Tue, 16 Jun 2026 10:38:05 -0500	[thread overview]
Message-ID: <12831fd9-8a6f-442e-b1ca-f39248a5baf0@baylibre.com> (raw)
In-Reply-To: <ajD8Gxkp66kkDflE@ashevche-desk.local>

On 6/16/26 2:32 AM, Andy Shevchenko wrote:
> On Mon, Jun 15, 2026 at 05:00:00PM -0500, David Lechner (TI) wrote:
>> Add a new driver for the TI ADS112C14/ADS122C14 ADC chips.
>>
>> This first step is adding a very basic driver that only supports power
>> on/reset and reading the system monitor channels.
>>
>> ADS112C14_SYS_MON_CHANNEL_SHORT is the last channel rather than being in
>> logical order by address to keep the voltage channels together and in
>> case we find we need to add variants of this channel with different
>> voltage reference later.
> 
> ...


>> +static int ads112c14_read_label(struct iio_dev *indio_dev,
>> +				struct iio_chan_spec const *chan, char *label)
>> +{
>> +	const char *label_source;
> 
> I don't see the need of having this. Can't be returned directly?

Then this would have to be split into two functions. One to return
it directly and one to do the sysfs_emit(). I don't think it is
worth it.

> 
>> +	/* System monitor channels. */
>> +	switch (chan->channel) {
>> +	case ADS112C14_SYS_MON_CHANNEL_TEMP:
>> +		label_source = "Internal temperature sensor";
>> +		break;
>> +	case ADS112C14_SYS_MON_CHANNEL_EXT_REF:
>> +		label_source = "External reference";
>> +		break;
>> +	case ADS112C14_SYS_MON_CHANNEL_AVDD:
>> +		label_source = "AVDD";
>> +		break;
>> +	case ADS112C14_SYS_MON_CHANNEL_DVDD:
>> +		label_source = "DVDD";
>> +		break;
>> +	case ADS112C14_SYS_MON_CHANNEL_SHORT:
>> +		label_source = "Internal short";
>> +		break;
>> +	default:
>> +		return -EINVAL;
>> +	}
>> +
>> +	return sysfs_emit(label, "%s\n", label_source);
>> +}
> 


>> +	/*
>> +	 * The reset may cause an -EREMOTEIO error because of failing to get the
>> +	 * I2C ACK at the end of the message. The device still gets reset.
>> +	 */
>> +	if (ret != -EREMOTEIO)
>> +		return ret;
> 
> I would do it separately as
> 
> 	if (ret == -EREMOTEIO)
> 		/* ...big comment here... */
> 		return 0;

We should not return early here. We just continue with the rest
of the function as normal. So I think the way I had it was
simplest. Otherwise we would need a goto or something like that.


> 	if (ret) // which is regular pattern and doesn't need any comment.
> 		return ret;
> 
>> +	fsleep(ADS112C14_DELAY_RESET_us);
>> +
>> +	ret = regmap_read(data->regmap, ADS112C14_REG_STATUS_MSB, &reg_val);
>> +	if (ret)
>> +		return ret;
>> +
>> +	if (FIELD_GET(ADS112C14_STATUS_MSB_RESETN, reg_val))
>> +		return dev_err_probe(dev, -EIO, "reset failed\n");
>> +

  reply	other threads:[~2026-06-16 15:38 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15 21:59 [PATCH 0/4] iio: adc: new " David Lechner (TI)
2026-06-15 21:59 ` [PATCH 1/4] dt-bindings: iio: adc: add ti,ads122c14 David Lechner (TI)
2026-06-16  0:26   ` Kurt Borja
2026-06-16 15:22     ` David Lechner
2026-06-16 17:31       ` Kurt Borja
2026-06-16 16:07   ` Conor Dooley
2026-06-16 19:54     ` David Lechner
2026-06-16 20:50       ` Conor Dooley
2026-06-16 21:04         ` David Lechner
2026-06-17 15:34           ` Conor Dooley
2026-06-21 18:41   ` Jonathan Cameron
2026-06-21 21:14     ` David Lechner
2026-06-22  9:55       ` Jonathan Cameron
2026-06-22 16:59         ` David Lechner
2026-06-15 22:00 ` [PATCH 2/4] iio: adc: add ti-ads112c14 driver David Lechner (TI)
2026-06-16  7:32   ` Andy Shevchenko
2026-06-16 15:38     ` David Lechner [this message]
2026-06-17 10:07       ` Andy Shevchenko
2026-06-21 18:52   ` Jonathan Cameron
2026-06-15 22:00 ` [PATCH 3/4] iio: adc: ti-ads112c14: implement gain on internal short SYS_MON channel David Lechner (TI)
2026-06-16  7:58   ` Andy Shevchenko
2026-06-16 10:03     ` Nuno Sá
2026-06-15 22:00 ` [PATCH 4/4] iio: adc: ti-ads112c14: add measurement channel support David Lechner (TI)
2026-06-16  8:36   ` Andy Shevchenko
2026-06-16 15:55     ` David Lechner
2026-06-17 10:16       ` Andy Shevchenko
2026-06-16 15:30   ` David Lechner
2026-06-21 19:08   ` Jonathan Cameron
2026-06-16  0:18 ` [PATCH 0/4] iio: adc: new ti-ads112c14 driver Kurt Borja
2026-06-16 15:21   ` David Lechner
2026-06-16 17:26     ` Kurt Borja
2026-06-16 18:16       ` David Lechner
2026-06-21 19:14         ` Jonathan Cameron
2026-06-22  0:32           ` Kurt Borja
2026-06-22 10:02             ` Jonathan Cameron

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=12831fd9-8a6f-442e-b1ca-f39248a5baf0@baylibre.com \
    --to=dlechner@baylibre.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kuurtb@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    --cc=zizuzacker@gmail.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®