Skip to contentSkip to conversation

iio: adc: rzg2l_adc: Add fwnode_xlate() callback

PATCH Applied Biju Das 2 participants 4 messages Nov 26 – Nov 28

Subsystems (2)
lore
Share & tools
lore

Biju Das

author
#0 lore raw

PATCH 1/1 iio: adc: rzg2l_adc: Add fwnode_xlate() callback

From: Biju Das <[email protected]>

On RZ/G3L ADC1, IIO channel indices don't map 1:1 to hardware channel numbers. Add a fwnode_xlate() callback that finds the registered channel whose number matches the specifier argument and returns its index.

---
 drivers/iio/adc/rzg2l_adc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/iio/adc/rzg2l_adc.c +14 -0
index 340813f6f890..f00cfb897124 100644
@@ -286,9 +286,23 @@ static int rzg2l_adc_read_label(struct iio_dev *iio_dev,
 	return sysfs_emit(label, "%s\n", rzg2l_adc_channels[chan->channel].name);
 }
 
+static int rzg2l_adc_fwnode_xlate(struct iio_dev *indio_dev,
+				  const struct fwnode_reference_args *iiospec)
+{
+	if (iiospec->nargs != 1)
+		return -EINVAL;
+
+	for (unsigned int i = 0; i < indio_dev->num_channels; i++)
+		if (indio_dev->channels[i].channel == iiospec->args[0])
+			return i;
+
+	return -EINVAL;
+}
+
 static const struct iio_info rzg2l_adc_iio_info = {
 	.read_raw = rzg2l_adc_read_raw,
 	.read_label = rzg2l_adc_read_label,
+	.fwnode_xlate = rzg2l_adc_fwnode_xlate,
 };
 
 static irqreturn_t rzg2l_adc_isr(int irq, void *dev_id)
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 7 lines · On Thu, 26 Nov 2026 13:48:19 +0000 Biju Das <[email protected]> wrote:

From: Biju Das <[email protected]>

On RZ/G3L ADC1, IIO channel indices don't map 1:1 to hardware channel numbers. Add a fwnode_xlate() callback that finds the registered channel whose number matches the specifier argument and returns its index.

Sounds like a fix. So why no fixes tag? If it needs one then reply directly to this email with one and the tools will pick it up when I apply.

Thanks,

Jonathan

Quoted 32 lines
---
 drivers/iio/adc/rzg2l_adc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/iio/adc/rzg2l_adc.c +14 -0
index 340813f6f890..f00cfb897124 100644
@@ -286,9 +286,23 @@ static int rzg2l_adc_read_label(struct iio_dev *iio_dev,
 	return sysfs_emit(label, "%s\n", rzg2l_adc_channels[chan->channel].name);
 }
 
+static int rzg2l_adc_fwnode_xlate(struct iio_dev *indio_dev,
+				  const struct fwnode_reference_args *iiospec)
+{
+	if (iiospec->nargs != 1)
+		return -EINVAL;
+
+	for (unsigned int i = 0; i < indio_dev->num_channels; i++)
+		if (indio_dev->channels[i].channel == iiospec->args[0])
+			return i;
+
+	return -EINVAL;
+}
+
 static const struct iio_info rzg2l_adc_iio_info = {
 	.read_raw = rzg2l_adc_read_raw,
 	.read_label = rzg2l_adc_read_label,
+	.fwnode_xlate = rzg2l_adc_fwnode_xlate,
 };
 
 static irqreturn_t rzg2l_adc_isr(int irq, void *dev_id)
author
#2 lore raw

Hi Jonathan,

Quoted 6 lines · Jonathan Cameron
Quoted 2 lines · On Thu, 26 Nov 2026 13:48:19 +0000 Biju Das <[email protected]> wrote:

From: Biju Das <[email protected]>

Quoted 7 lines
Quoted 5 lines

On RZ/G3L ADC1, IIO channel indices don't map 1:1 to hardware channel numbers. Add a fwnode_xlate() callback that finds the registered channel whose number matches the specifier argument and returns its index.

Sounds like a fix. So why no fixes tag? If it needs one then reply directly to this email with one and the tools will pick it up when I apply.

Yes, it is a fix. I missed that.

Fixes 39e16807997c ("iio: adc: rzg2l_adc: Add RZ/G3L ADC support for TSU")

Cheers,
Biju

Quoted 38 lines

Thanks,

Jonathan

Quoted 32 lines
---
 drivers/iio/adc/rzg2l_adc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/iio/adc/rzg2l_adc.c +14 -0
index 340813f6f890..f00cfb897124 100644
@@ -286,9 +286,23 @@ static int rzg2l_adc_read_label(struct iio_dev *iio_dev,
      return sysfs_emit(label, "%s\n", rzg2l_adc_channels[chan->channel].name);
 }
 
+static int rzg2l_adc_fwnode_xlate(struct iio_dev *indio_dev,
+                               const struct fwnode_reference_args *iiospec)
+{
+     if (iiospec->nargs != 1)
+             return -EINVAL;
+
+     for (unsigned int i = 0; i < indio_dev->num_channels; i++)
+             if (indio_dev->channels[i].channel == iiospec->args[0])
+                     return i;
+
+     return -EINVAL;
+}
+
 static const struct iio_info rzg2l_adc_iio_info = {
      .read_raw = rzg2l_adc_read_raw,
      .read_label = rzg2l_adc_read_label,
+     .fwnode_xlate = rzg2l_adc_fwnode_xlate,
 };
 
 static irqreturn_t rzg2l_adc_isr(int irq, void *dev_id)
maintainer Applied
#3 lore raw
Quoted 13 lines · On Sat, 28 Nov 2026 08:37:01 +0000 Biju Das <[email protected]> wrote:

Hi Jonathan,

Quoted 10 lines · Jonathan Cameron
Quoted 6 lines · On Thu, 26 Nov 2026 13:48:19 +0000 Biju Das <[email protected]> wrote:

From: Biju Das <[email protected]>

On RZ/G3L ADC1, IIO channel indices don't map 1:1 to hardware channel numbers. Add a fwnode_xlate() callback that finds the registered channel whose number matches the specifier argument and returns its index.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Sounds like a fix. So why no fixes tag? If it needs one then reply directly to this email with one and the tools will pick it up when I apply.

Yes, it is a fix. I missed that.

Fixes 39e16807997c ("iio: adc: rzg2l_adc: Add RZ/G3L ADC support for TSU")

Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

Quoted 43 lines

Cheers,
Biju

Quoted 38 lines

Thanks,

Jonathan

Quoted 32 lines
---
 drivers/iio/adc/rzg2l_adc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/iio/adc/rzg2l_adc.c +14 -0
index 340813f6f890..f00cfb897124 100644
@@ -286,9 +286,23 @@ static int rzg2l_adc_read_label(struct iio_dev *iio_dev,
      return sysfs_emit(label, "%s\n", rzg2l_adc_channels[chan->channel].name);
 }
 
+static int rzg2l_adc_fwnode_xlate(struct iio_dev *indio_dev,
+                               const struct fwnode_reference_args *iiospec)
+{
+     if (iiospec->nargs != 1)
+             return -EINVAL;
+
+     for (unsigned int i = 0; i < indio_dev->num_channels; i++)
+             if (indio_dev->channels[i].channel == iiospec->args[0])
+                     return i;
+
+     return -EINVAL;
+}
+
 static const struct iio_info rzg2l_adc_iio_info = {
      .read_raw = rzg2l_adc_read_raw,
      .read_label = rzg2l_adc_read_label,
+     .fwnode_xlate = rzg2l_adc_fwnode_xlate,
 };
 
 static irqreturn_t rzg2l_adc_isr(int irq, void *dev_id)