Skip to content

Commit e2648f8

Browse files
committed
iio: adf4030: Add adf4030_fwnode_xlate() for non-1:1 map
Adds method to map the fwnode_reference_args->args[0] value to the iio_channel index, instead of relying on __fwnode_iio_simple_xlate() that supports only 1:1 mapped channels. Allows to not describe and skip channels in the devicetree. Signed-off-by: Jorge Marques <jorge.marques@analog.com>
1 parent 75f5e19 commit e2648f8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

drivers/iio/frequency/adf4030.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,10 +887,24 @@ static int adf4030_read_avail(struct iio_dev *indio_dev,
887887
}
888888
}
889889

890+
static int adf4030_fwnode_xlate(struct iio_dev *indio_dev,
891+
const struct fwnode_reference_args *iiospec)
892+
{
893+
struct adf4030_state *st = iio_priv(indio_dev);
894+
895+
for (int i = 0; i < st->num_channels; i++) {
896+
if (st->channels[i].num == iiospec->args[0])
897+
return i;
898+
}
899+
900+
return -EINVAL;
901+
}
902+
890903
static const struct iio_info adf4030_iio_info = {
891904
.read_raw = &adf4030_read_raw,
892905
.write_raw = &adf4030_write_raw,
893906
.read_avail = &adf4030_read_avail,
907+
.fwnode_xlate = &adf4030_fwnode_xlate,
894908
.debugfs_reg_access = &adf4030_reg_access,
895909
};
896910

0 commit comments

Comments
 (0)