Skip to content

Commit

Permalink
iio: adc: ad9467: cleanup ad9467_spi_write() function
Browse files Browse the repository at this point in the history
Remove 'spi' NULL check. It's redundant.
Format function header (similar to upstream version).

Signed-off-by: Alexandru Ardelean <[email protected]>
  • Loading branch information
commodo committed Aug 25, 2020
1 parent 611893f commit c7690d2
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions drivers/iio/adc/ad9467.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,30 +181,27 @@ static int ad9467_spi_read(struct spi_device *spi, unsigned reg)
return -ENODEV;
}

static int ad9467_spi_write(struct spi_device *spi, unsigned reg, unsigned val)
static int ad9467_spi_write(struct spi_device *spi, unsigned int reg,
unsigned int val)
{
unsigned char buf[3];
int ret;

if (spi) {
buf[0] = reg >> 8;
buf[1] = reg & 0xFF;
buf[2] = val;
ret = spi_write_then_read(spi, buf, 3, NULL, 0);
if (ret < 0)
return ret;

dev_dbg(&spi->dev, "%s: REG: 0x%X VAL: 0x%X (%d)\n",
__func__, reg, val, ret);
buf[0] = reg >> 8;
buf[1] = reg & 0xFF;
buf[2] = val;
ret = spi_write_then_read(spi, buf, 3, NULL, 0);
if (ret < 0)
return ret;

if ((reg == AN877_ADC_REG_TRANSFER) && (val == AN877_ADC_TRANSFER_SYNC) &&
(spi_get_device_id(spi)->driver_data == CHIPID_AD9265))
ad9467_spi_write(spi, AN877_ADC_REG_TRANSFER, 0);
dev_dbg(&spi->dev, "%s: REG: 0x%X VAL: 0x%X (%d)\n",
__func__, reg, val, ret);

return 0;
}
if ((reg == AN877_ADC_REG_TRANSFER) && (val == AN877_ADC_TRANSFER_SYNC) &&
(spi_get_device_id(spi)->driver_data == CHIPID_AD9265))
return ad9467_spi_write(spi, AN877_ADC_REG_TRANSFER, 0);

return -ENODEV;
return 0;
}

static int ad9467_reg_access(struct iio_dev *indio_dev, unsigned int reg,
Expand Down

0 comments on commit c7690d2

Please sign in to comment.