diff options
author | William Breathitt Gray <william.gray@linaro.org> | 2022-05-10 20:31:00 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2022-06-11 16:35:26 +0300 |
commit | c5a37ad0fccc95121d77c577ea5e635a867c99b9 (patch) | |
tree | 6058d01385e43ea05eb2d8af01ea9ef605fc2495 /drivers/iio/dac/cio-dac.c | |
parent | 73b8390cc27e096ab157be261ccc4eaaa6db87af (diff) | |
download | linux-c5a37ad0fccc95121d77c577ea5e635a867c99b9.tar.xz |
iio: dac: cio-dac: Utilize iomap interface
This driver doesn't need to access I/O ports directly via inb()/outb()
and friends. This patch abstracts such access by calling ioport_map()
to enable the use of more typical ioread8()/iowrite8() I/O memory
accessor calls.
Suggested-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/c973ce9a326131552caf762381edf8e90be43cc5.1652201921.git.william.gray@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/dac/cio-dac.c')
-rw-r--r-- | drivers/iio/dac/cio-dac.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/iio/dac/cio-dac.c b/drivers/iio/dac/cio-dac.c index 95813569f394..8080984dcb03 100644 --- a/drivers/iio/dac/cio-dac.c +++ b/drivers/iio/dac/cio-dac.c @@ -41,7 +41,7 @@ MODULE_PARM_DESC(base, "Measurement Computing CIO-DAC base addresses"); */ struct cio_dac_iio { int chan_out_states[CIO_DAC_NUM_CHAN]; - unsigned int base; + void __iomem *base; }; static int cio_dac_read_raw(struct iio_dev *indio_dev, @@ -71,7 +71,7 @@ static int cio_dac_write_raw(struct iio_dev *indio_dev, return -EINVAL; priv->chan_out_states[chan->channel] = val; - outw(val, priv->base + chan_addr_offset); + iowrite16(val, priv->base + chan_addr_offset); return 0; } @@ -105,18 +105,20 @@ static int cio_dac_probe(struct device *dev, unsigned int id) return -EBUSY; } + priv = iio_priv(indio_dev); + priv->base = devm_ioport_map(dev, base[id], CIO_DAC_EXTENT); + if (!priv->base) + return -ENOMEM; + indio_dev->info = &cio_dac_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = cio_dac_channels; indio_dev->num_channels = CIO_DAC_NUM_CHAN; indio_dev->name = dev_name(dev); - priv = iio_priv(indio_dev); - priv->base = base[id]; - /* initialize DAC outputs to 0V */ for (i = 0; i < 32; i += 2) - outw(0, base[id] + i); + iowrite16(0, priv->base + i); return devm_iio_device_register(dev, indio_dev); } |