Linux IIO development
 help / color / mirror / Atom feed
* AD7192 driver mess
@ 2023-03-29 10:46 Paul Cercueil
  2023-03-30  8:44 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Cercueil @ 2023-03-29 10:46 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio

Hi Jonathan,

I noticed that the upstream AD7192 driver (drivers/iio/adc/ad7192.c) we
have two IIO channels with the same identifier:

AD719x_SHORTED_CHANNEL(3, 2, AD7192_CH_AIN2P_AIN2M)

and:
AD719x_CHANNEL(5, 2, AD7192_CH_AIN2)

Both macros create a iio_chan_spec with .channel = 2.

This results in having this mess in sysfs:
in_voltage2_en
in_voltage2_index
in_voltage2_shorted_en
in_voltage2_shorted_index

In turn, this causes Libiio to detect it as a single IIO channel whose
identifier is "in_voltage2", with attributes "en", "index",
"shorted_en" and "shorted_index".

My question is, is it okay for the driver to do this? I would expect
the .channel field to contain an identifier, and it would be invalid
for two channels to have the same identifier.

Cheers,
-Paul

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: AD7192 driver mess
  2023-03-29 10:46 AD7192 driver mess Paul Cercueil
@ 2023-03-30  8:44 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2023-03-30  8:44 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: Jonathan Cameron, linux-iio

On Wed, 29 Mar 2023 12:46:00 +0200
Paul Cercueil <paul@crapouillou.net> wrote:

> Hi Jonathan,
> 
> I noticed that the upstream AD7192 driver (drivers/iio/adc/ad7192.c) we
> have two IIO channels with the same identifier:
> 
> AD719x_SHORTED_CHANNEL(3, 2, AD7192_CH_AIN2P_AIN2M)
> 
> and:
> AD719x_CHANNEL(5, 2, AD7192_CH_AIN2)
> 
> Both macros create a iio_chan_spec with .channel = 2.
> 
> This results in having this mess in sysfs:
> in_voltage2_en
> in_voltage2_index
> in_voltage2_shorted_en
> in_voltage2_shorted_index
> 
> In turn, this causes Libiio to detect it as a single IIO channel whose
> identifier is "in_voltage2", with attributes "en", "index",
> "shorted_en" and "shorted_index".
> 
> My question is, is it okay for the driver to do this? I would expect
> the .channel field to contain an identifier, and it would be invalid
> for two channels to have the same identifier.

Unique naming (ignoring the extend name part) would be my expectation
as well.

So I'd be very happy to see this moved to a different index.  I'd consider
it a bug so fine to backport even if it breaks ABI, but open to comments
on this from others.

If this was done originally with the idea of 'grouping' channels, then
that should be changed to being done with labels (though that extend name
trick with the label is then not available).

Jonathan

> Cheers,
> -Paul


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-30  8:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-29 10:46 AD7192 driver mess Paul Cercueil
2023-03-30  8:44 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox