Re: [PATCH v8 3/5] iio: dac: mcp47feb02: refactor MCP47FEB02 I2C driver into two modules

From: Jonathan Cameron

Date: Sun Sep 27 2026 - 14:35:06 EST


On Thu, 24 Sep 2026 15:59:21 +0300
Ariana Lazar <ariana.lazar@xxxxxxxxxxxxx> wrote:

> Prepare the driver for the bus-specific code by refactoring into separate
> files. The renamed file will contain the common DAC functionality shared by
> the MCP47FxBy1/2/4/8 I2C and MCP48FxBy1/2/4/8 SPI drivers. The MCP47FEB02
> driver was refactored into two modules: mcp47feb02-core.c and
> mcp47feb02-i2c.c in order to prepare the support for SPI MCP48FxBy1/2/4/8
> DAC family on top of the current implementation.
>
> Signed-off-by: Ariana Lazar <ariana.lazar@xxxxxxxxxxxxx>
> ---
> MAINTAINERS | 2 +-
> drivers/iio/dac/Kconfig | 9 +-
> drivers/iio/dac/Makefile | 3 +-
> .../iio/dac/{mcp47feb02.c => mcp47feb02-core.c} | 322 ++-------------------
> drivers/iio/dac/mcp47feb02-i2c.c | 145 ++++++++++
> drivers/iio/dac/mcp47feb02.h | 43 +++
> 6 files changed, 219 insertions(+), 305 deletions(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 2e98d052fbdcf43f70376fdb3a553e97bf91dc82..ecc22d1149d19ae7798ebd54c52b1b2486d1f9f1 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -16352,7 +16352,7 @@ M: Ariana Lazar <ariana.lazar@xxxxxxxxxxxxx>
> L: linux-iio@xxxxxxxxxxxxxxx
> S: Supported
> F: Documentation/devicetree/bindings/iio/dac/microchip,mcp47feb02.yaml
> -F: drivers/iio/dac/mcp47feb02.c
> +F: drivers/iio/dac/mcp47feb02*
>
> MCP4821 DAC DRIVER
> M: Anshul Dalal <anshulusr@xxxxxxxxx>
> diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
> index b6c8873c68c54d13f80ea7116bee1ac00f374574..8121a71945f63a23b35fcab010fda1d03d0afba0 100644
> --- a/drivers/iio/dac/Kconfig
> +++ b/drivers/iio/dac/Kconfig
> @@ -611,9 +611,13 @@ config MCP47A1
> will be called mcp47a1.
>
> config MCP47FEB02
> - tristate "MCP47F(E/V)B01/02/04/08/11/12/14/18/21/22/24/28 DAC driver"
> + tristate
> +
> +config MCP47FEB02_I2C
> + tristate "MCP47F(E/V)B01/02/04/08/11/12/14/18/21/22/24/28 I2C DAC driver"
> depends on I2C
> select REGMAP_I2C
> + select MCP47FEB02
> help
> Say yes here if you want to build the driver for the Microchip:
> - 8-bit DAC:
> @@ -629,7 +633,8 @@ config MCP47FEB02
> (DAC) with I2C interface.
>
> To compile this driver as a module, choose M here: the module
> - will be called mcp47feb02.
> + will be called mcp47feb02_i2c and you will also get
> + mcp47feb02_core for the core module.
>
> config MCP4821
> tristate "MCP4801/02/11/12/21/22 DAC driver"
> diff --git a/drivers/iio/dac/Makefile b/drivers/iio/dac/Makefile
> index 8dc644522b1e52152abacc32cacb6ee90881ef9a..4394278d9fd874b94ae2d680378fb3b043ac8672 100644
> --- a/drivers/iio/dac/Makefile
> +++ b/drivers/iio/dac/Makefile
> @@ -57,7 +57,8 @@ obj-$(CONFIG_MCF54415_DAC) += mcf54415_dac.o
> obj-$(CONFIG_MCP4725) += mcp4725.o
> obj-$(CONFIG_MCP4728) += mcp4728.o
> obj-$(CONFIG_MCP47A1) += mcp47a1.o
> -obj-$(CONFIG_MCP47FEB02) += mcp47feb02.o
> +obj-$(CONFIG_MCP47FEB02) += mcp47feb02-core.o
> +obj-$(CONFIG_MCP47FEB02_I2C) += mcp47feb02-i2c.o
> obj-$(CONFIG_MCP4821) += mcp4821.o
> obj-$(CONFIG_MCP4922) += mcp4922.o
> obj-$(CONFIG_STM32_DAC_CORE) += stm32-dac-core.o
> diff --git a/drivers/iio/dac/mcp47feb02.c b/drivers/iio/dac/mcp47feb02-core.c
> similarity index 73%
> rename from drivers/iio/dac/mcp47feb02.c
> rename to drivers/iio/dac/mcp47feb02-core.c
> index 8f8a67919cc2ecdb203ad350174bac2be1a307dc..29d69cb2f68b5d7c6a615481bb1045aed468e9cf 100644
> --- a/drivers/iio/dac/mcp47feb02.c
> +++ b/drivers/iio/dac/mcp47feb02-core.c
> @@ -1,8 +1,8 @@
> // SPDX-License-Identifier: GPL-2.0+
> /*
> - * IIO driver for MCP47FEB02 Multi-Channel DAC with I2C interface
> + * IIO driver for MCP47FEB02 Multi-Channel DAC with I2C and SPI interface
> *
> - * Copyright (C) 2025 Microchip Technology Inc. and its subsidiaries
> + * Copyright (C) 2025-2026 Microchip Technology Inc. and its subsidiaries
> *
> * Author: Ariana Lazar <ariana.lazar@xxxxxxxxxxxxx>
> *
> @@ -16,7 +16,6 @@
> #include <linux/bitfield.h>
> #include <linux/delay.h>
> #include <linux/err.h>
> -#include <linux/i2c.h>
> #include <linux/iio/iio.h>
> #include <linux/iio/sysfs.h>
> #include <linux/kstrtox.h>
> @@ -29,6 +28,8 @@
> #include <linux/types.h>
> #include <linux/units.h>
>
> +#include "mcp47feb02.h"
> +
> /* Register addresses must be left shifted with 3 positions in order to append command mask */
> #define MCP47FEB02_DAC0_REG_ADDR 0x00
> #define MCP47FEB02_VREF_REG_ADDR 0x40
> @@ -82,220 +83,12 @@ enum mcp47feb02_gain_bit_mode {
> MCP47FEB02_GAIN_BIT_X2 = 1,
> };
>
> -static const char * const mcp47feb02_powerdown_modes[] = {
> +const char * const mcp47feb02_powerdown_modes[] = {

Why is this change here? Whilst you add the extern to the
header, I'm not seeing it used outside of this file.


> "1kohm_to_gnd",
> "100kohm_to_gnd",
> "open_circuit",
> };

Thanks,

Jonathan