Skip to content

Commit

Permalink
iio: adc: cf_axi_adc_core: relax check in register access
Browse files Browse the repository at this point in the history
With commit
c5a5970 ("iio: adc: cf_axi_adc_core: use devm_jesd204_fsm_start()"),

we started to use devm_platform_ioremap_resource() which means 'regs_size'
will stay unchanged during probe and will be 0. Thus, checking the
register to fit the mapped area will fail in the debugfs interface. Hence,
relax that check and only check for proper alignment. While checking if the
register fits the mapped area would be a nice thing, this is a debug
interface and users are expected to know what they are doing. Hence I
prefer to have simplicity during probe and not to keep 'regs_size' only to
be used in the debugfs interface.

Fixes: c5a5970 ("iio: adc: cf_axi_adc_core: use devm_jesd204_fsm_start()")
Signed-off-by: Nuno Sa <[email protected]>
  • Loading branch information
nunojsa committed Dec 23, 2024
1 parent c7fe871 commit 1db9b37
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/iio/adc/cf_axi_adc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ struct axiadc_state {
struct clk *clk;
struct gpio_desc *gpio_decimation;
struct jesd204_dev *jdev;
size_t regs_size;
void __iomem *regs;
void __iomem *slave_regs;
unsigned int max_usr_channel;
Expand Down Expand Up @@ -234,9 +233,8 @@ static int axiadc_reg_access(struct iio_dev *indio_dev,
struct axiadc_converter *conv = to_converter(st->dev_spi);
int ret;

/* Check that the register is in range and aligned */
if ((reg & DEBUGFS_DRA_PCORE_REG_MAGIC) &&
((reg & 0xffff) >= st->regs_size || (reg & 0x3)))
/* Check that the register is aligned */
if ((reg & DEBUGFS_DRA_PCORE_REG_MAGIC) && (reg & 0x3))
return -EINVAL;

mutex_lock(&conv->lock);
Expand Down

0 comments on commit 1db9b37

Please sign in to comment.