All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Ariana Lazar <ariana.lazar@microchip.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v6 08/11] iio: dac: mcp47feb02: rename channel mask and value macros
Date: Thu, 17 Sep 2026 01:53:34 +0100	[thread overview]
Message-ID: <20260917015334.1f43bd02@jic23-hlaptop> (raw)
In-Reply-To: <20260916-mcp47feb02_refactor-v6-8-285464651f89@microchip.com>

On Wed, 16 Sep 2026 17:16:34 +0300
Ariana Lazar <ariana.lazar@microchip.com> wrote:

> Rename generic DAC_CTRL_MASK/VAL macros to MCP47FEB02_VREF_PD_MASK/VAL
> in order to clearly indicate for which control registers these channel
> masks are suitable.
> 
> Reported-by: Jonathan Cameron <jic23@kernel.org>
> Link: https://lore.kernel.org/all/20260528125140.16a8f173@jic23-huawei/
> Signed-off-by: Ariana Lazar <ariana.lazar@microchip.com>
> ---
>  drivers/iio/dac/mcp47feb02.c | 23 +++++++++++++----------
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/dac/mcp47feb02.c b/drivers/iio/dac/mcp47feb02.c
> index 8dac4e2fb74fe4563324343ce215af3389129130..5c09ca25a75e0ecb2bfc5a2d5e62e5f7d3156810 100644
> --- a/drivers/iio/dac/mcp47feb02.c
> +++ b/drivers/iio/dac/mcp47feb02.c
> @@ -49,8 +49,8 @@
>  #define MCP47FEB02_NV_I2C_SLAVE_ADDR_MASK		GENMASK(7, 0)
>  
>  /* Voltage reference, Power-Down control register and DAC Wiperlock status register fields */
> -#define DAC_CTRL_MASK(ch)				(GENMASK(1, 0) << (2 * (ch)))
> -#define DAC_CTRL_VAL(ch, val)				((val) << (2 * (ch)))
> +#define MCP47FEB02_VREF_PD_MASK(ch)			(GENMASK(1, 0) << (2 * (ch)))
> +#define MCP47FEB02_VREF_PD_VAL(ch, val)			((val) << (2 * (ch)))
Can we drop this one...
>  
>  /* Gain Control and I2C Slave Address Register fields */
>  #define DAC_GAIN_MASK(ch)				(BIT(0) << (8 + (ch)))
> @@ -555,7 +555,8 @@ static int mcp47feb02_suspend(struct device *dev)
>  		data->chdata[ch].powerdown = true;
>  		pd_mode = data->chdata[ch].powerdown_mode + 1;
>  		ret = regmap_update_bits(data->regmap, MCP47FEB02_POWER_DOWN_REG_ADDR,
> -					 DAC_CTRL_MASK(ch), DAC_CTRL_VAL(ch, pd_mode));
> +					 MCP47FEB02_VREF_PD_MASK(ch),
> +					 MCP47FEB02_VREF_PD_VAL(ch, pd_mode));
.. and here have a local for mask.

		mask = MCP47FEB02_VREF_PD_MASK(ch);
  		ret = regmap_update_bits(data->regmap, MCP47FEB02_POWER_DOWN_REG_ADDR,
					 mask, field_prep(mask, pd_mode));		

Same in all the other cases. Will then match you do the field_get().


>  		if (ret)
>  			return ret;
>  
> @@ -587,7 +588,8 @@ static int mcp47feb02_resume(struct device *dev)
>  			return ret;
>  
>  		ret = regmap_update_bits(data->regmap, MCP47FEB02_VREF_REG_ADDR,
> -					 DAC_CTRL_MASK(ch), DAC_CTRL_VAL(ch, pd_mode));
> +					 MCP47FEB02_VREF_PD_MASK(ch),
> +					 MCP47FEB02_VREF_PD_VAL(ch, pd_mode));


>  		if (ret)
>  			return ret;
>  
> @@ -598,8 +600,8 @@ static int mcp47feb02_resume(struct device *dev)
>  			return ret;
>  
>  		ret = regmap_update_bits(data->regmap, MCP47FEB02_POWER_DOWN_REG_ADDR,
> -					 DAC_CTRL_MASK(ch),
> -					 DAC_CTRL_VAL(ch, MCP47FEB02_NORMAL_OPERATION));
> +					 MCP47FEB02_VREF_PD_MASK(ch),
> +					 MCP47FEB02_VREF_PD_VAL(ch, MCP47FEB02_NORMAL_OPERATION));
>  		if (ret)
>  			return ret;
>  	}
> @@ -656,7 +658,8 @@ static ssize_t mcp47feb02_write_powerdown(struct iio_dev *indio_dev, uintptr_t p
>  	 */
>  	tmp_pd_mode = state ? (data->chdata[reg].powerdown_mode + 1) : MCP47FEB02_NORMAL_OPERATION;
>  	ret = regmap_update_bits(data->regmap, MCP47FEB02_POWER_DOWN_REG_ADDR,
> -				 DAC_CTRL_MASK(reg), DAC_CTRL_VAL(reg, tmp_pd_mode));
> +				 MCP47FEB02_VREF_PD_MASK(reg),
> +				 MCP47FEB02_VREF_PD_VAL(reg, tmp_pd_mode));
>  	if (ret)
>  		return ret;
>  
> @@ -822,7 +825,7 @@ static int mcp47feb02_ch_scale(struct mcp47feb02_data *data, int ch, int scale)
>  	}
>  
>  	ret = regmap_update_bits(data->regmap, MCP47FEB02_VREF_REG_ADDR,
> -				 DAC_CTRL_MASK(ch), DAC_CTRL_VAL(ch, tmp_val));
> +				 MCP47FEB02_VREF_PD_MASK(ch), MCP47FEB02_VREF_PD_VAL(ch, tmp_val));
>  	if (ret)
>  		return ret;
>  
> @@ -1027,7 +1030,7 @@ static int mcp47feb02_init_ctrl_regs(struct mcp47feb02_data *data)
>  			return ret;
>  		data->chdata[i].dac_data = dac_val;
>  
> -		data->chdata[i].ref_mode = field_get(DAC_CTRL_MASK(i), vref_ch);
> +		data->chdata[i].ref_mode = field_get(MCP47FEB02_VREF_PD_MASK(i), vref_ch);
>  		data->chdata[i].use_2x_gain = field_get(DAC_GAIN_MASK(i), gain_ch);
>  
>  		/*
> @@ -1071,7 +1074,7 @@ static int mcp47feb02_init_ctrl_regs(struct mcp47feb02_data *data)
>  			break;
>  		}
>  
> -		pd_tmp = field_get(DAC_CTRL_MASK(i), pd_ch);
> +		pd_tmp = field_get(MCP47FEB02_VREF_PD_MASK(i), pd_ch);
>  		data->chdata[i].powerdown_mode = pd_tmp ? (pd_tmp - 1) : pd_tmp;
>  		data->chdata[i].powerdown = !!(data->chdata[i].powerdown_mode);
>  	}
> 


  reply	other threads:[~2026-09-17  0:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 14:16 [PATCH v6 00/11] Refactor Microchip MCP47FEB02 I2C driver in separate modules to add support for MCP48FEB02 SPI driver Ariana Lazar
2026-09-16 14:16 ` [PATCH v6 01/11] iio: dac: mcp47feb02: initialize dac_data field in channel data struct at probe Ariana Lazar
2026-09-16 14:16 ` [PATCH v6 02/11] iio: dac: mcp47feb02: Fix gain field initialization for active channels Ariana Lazar
2026-09-16 14:29   ` sashiko-bot
2026-09-16 14:16 ` [PATCH v6 03/11] iio: dac: mcp47feb02: use field_get() instead of custom dynamic macros Ariana Lazar
2026-09-16 15:22   ` Andy Shevchenko
2026-09-16 14:16 ` [PATCH v6 04/11] iio: dac: mcp47feb02: Return len when disabling EEPROM store Ariana Lazar
2026-09-16 14:16 ` [PATCH v6 05/11] iio: dac: mcp47feb02: Increase EEPROM Programming Write Cycle Time Ariana Lazar
2026-09-16 14:16 ` [PATCH v6 06/11] iio: dac: mcp47feb02: Avoid unjustified probe error on missing label Ariana Lazar
2026-09-16 14:29   ` sashiko-bot
2026-09-16 14:16 ` [PATCH v6 07/11] iio: dac: mcp47feb02: correct typo from a comment Ariana Lazar
2026-09-16 15:49   ` Joshua Crofts
2026-09-16 14:16 ` [PATCH v6 08/11] iio: dac: mcp47feb02: rename channel mask and value macros Ariana Lazar
2026-09-17  0:53   ` Jonathan Cameron [this message]
2026-09-16 14:16 ` [PATCH v6 09/11] iio: dac: mcp47feb02: refactor MCP47FEB02 I2C driver into two modules Ariana Lazar
2026-09-16 14:16 ` [PATCH v6 10/11] dt-bindings: iio: dac: add support for MCP48FEB02 SPI Ariana Lazar
2026-09-16 14:16 ` [PATCH v6 11/11] iio: dac: add support for Microchip MCP48FEB02 Ariana Lazar
2026-09-16 15:26 ` [PATCH v6 00/11] Refactor Microchip MCP47FEB02 I2C driver in separate modules to add support for MCP48FEB02 SPI driver Andy Shevchenko
2026-09-17  0:55   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260917015334.1f43bd02@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=ariana.lazar@microchip.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.