Skip to contentSkip to conversation

iio: dac: cio-dac: Migrate to the regmap API

PATCH Superseded William Breathitt Gray 1 participant 2 messages Mar 11, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: dac: cio-dac: Migrate to the regmap API

The regmap API supports IO port accessors so we can take advantage of regmap abstractions rather than handling access to the device registers directly in the driver.

---
 drivers/iio/dac/Kconfig   |  1 +
 drivers/iio/dac/cio-dac.c | 71 +++++++++++++++++++++++++++++----------
 2 files changed, 54 insertions(+), 18 deletions(-)
drivers/iio/dac/Kconfig +1 -0
index d3f90cf86143..3acd9c3f388e 100644
@@ -277,6 +277,7 @@ config CIO_DAC
 	tristate "Measurement Computing CIO-DAC IIO driver"
 	depends on X86 && (ISA_BUS || PC104)
 	select ISA_BUS_API
+	select REGMAP_MMIO
 	help
 	  Say yes here to build support for the Measurement Computing CIO-DAC
 	  analog output device family (CIO-DAC16, CIO-DAC08, PC104-DAC06). The
drivers/iio/dac/cio-dac.c +53 -18

136 lines not on this page · raw message

base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6

Signature · 1 line
2.39.2
#1 lore raw
Quoted 6 lines · William Breathitt Gray

The regmap API supports IO port accessors so we can take advantage of regmap abstractions rather than handling access to the device registers directly in the driver.

[...]

Quoted 5 lines
drivers/iio/dac/cio-dac.c +0 -1
@@ -117,8 +148,12 @@ static int cio_dac_probe(struct device *dev, unsigned int id)
 	indio_dev->name = dev_name(dev);
 
 	/* initialize DAC outputs to 0V */
-	for (i = 0; i < CIO_DAC_NUM_CHAN; i++)

drivers/iio/dac/cio-dac.c static int cio_dac_probe(struct device *dev, unsigned int id) · line 159

Quoted 10 lines
drivers/iio/dac/cio-dac.c +6 -1
-		iowrite16(0, priv->base + i);
+	for (i = 0; i < CIO_DAC_NUM_CHAN; i++) {
+		offset = i * CIO_DAC_CHANNEL_STRIDE;
+		err = regmap_write(priv->map, CIO_DAC_BASE + offset, 0);
+		if (err)
+			return err;
+	}
 
 	return devm_iio_device_register(dev, indio_dev);
 }

As soon as I sent this I realized this last hunk is no longer necessary because the chan_out_states array is gone so we don't need to match its initialized state. I'll remove this block as superfluous and submit a v2 patch shortly.

William Breathitt Gray