From: Jonathan Cameron <jic23@kernel.org>
To: Ariana Lazar <ariana.lazar@microchip.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"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 v7 09/11] iio: dac: mcp47feb02: refactor MCP47FEB02 I2C driver into two modules
Date: Sun, 20 Sep 2026 23:52:29 +0100 [thread overview]
Message-ID: <178994474989.706584.9211319682095053097.b4-review@b4> (raw)
In-Reply-To: <20260918-mcp47feb02_refactor-v7-9-82ca794eafe2@microchip.com>
> 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@microchip.com>
Sashiko makes a point about change of Kconfig symbol and make
oldconfig etc. Not ideal but we've done this before and I don't
think it has proved a signficant problem in practice. We could
carry an extra symbol to avoid the problem but it is going to
be a long term bit of mess so I think what you have here is the
way to go.
Otherwise a few small things inline.
> 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 7312c2c96141..91fad42df216 100644
> --- a/drivers/iio/dac/mcp47feb02.c
> +++ b/drivers/iio/dac/mcp47feb02-core.c
> unsigned int val)
> @@ -440,8 +235,6 @@ static int mcp47feb02_write_to_eeprom(struct mcp47feb02_data *data, unsigned int
> * Wait until the currently occurring EEPROM Write Cycle is completed.
> * Only serial commands to the volatile memory are allowed.
> */
> - guard(mutex)(&data->lock);
> -
What is this change doing in this patch? Looking at the code I think
is indeed a good thing to do, just shouldn't be hidden down in here.
Break this out as a separate precursor patch.
> ret = regmap_read_poll_timeout(data->regmap, MCP47FEB02_GAIN_CTRL_STATUS_REG_ADDR,
> eewa_val,
> !(eewa_val & MCP47FEB02_GAIN_BIT_STATUS_EEWA_MASK),
> @@ -467,6 +260,8 @@ static ssize_t store_eeprom_store(struct device *dev, struct device_attribute *a
> if (!state)
> return len;
>
> + guard(mutex)(&data->lock);
> +
> /*
> * Verify DAC Wiper and DAC Configuration are unlocked. If both are disabled,
> * writing to EEPROM is available.
> @@ -575,12 +370,10 @@ static int mcp47feb02_resume(struct device *dev)
> guard(mutex)(&data->lock);
>
> for_each_set_bit(ch, &data->active_channels_mask, data->phys_channels) {
> - u8 pd_mode;
> u32 mask;
> int ret;
>
> data->chdata[ch].powerdown = false;
> - pd_mode = data->chdata[ch].powerdown_mode + 1;
>
> ret = regmap_write(data->regmap, REG_ADDR(ch), data->chdata[ch].dac_data);
> if (ret)
> @@ -588,7 +381,7 @@ static int mcp47feb02_resume(struct device *dev)
>
> mask = MCP47FEB02_VREF_PD_MASK(ch);
> ret = regmap_update_bits(data->regmap, MCP47FEB02_VREF_REG_ADDR,
> - mask, field_prep(mask, pd_mode));
> + mask, field_prep(mask, data->chdata[ch].ref_mode));
> if (ret)
> return ret;
>
> @@ -668,7 +461,7 @@ static ssize_t mcp47feb02_write_powerdown(struct iio_dev *indio_dev, uintptr_t p
> return len;
> }
>
> -static DEFINE_SIMPLE_DEV_PM_OPS(mcp47feb02_pm_ops, mcp47feb02_suspend, mcp47feb02_resume);
> +EXPORT_SIMPLE_DEV_PM_OPS(mcp47feb02_pm_ops, mcp47feb02_suspend, mcp47feb02_resume);
Sashiko:
[Severity: Low]
Does this macro export the PM ops symbol without the intended IIO_MCP47FEB02
namespace?
The driver establishes a dedicated namespace IIO_MCP47FEB02 for its core
exported symbols, but mcp47feb02_pm_ops is exported using
EXPORT_SIMPLE_DEV_PM_OPS, which places it into the global namespace.
Should this use EXPORT_NS_SIMPLE_DEV_PM_OPS(mcp47feb02_pm_ops,
mcp47feb02_suspend, mcp47feb02_resume, IIO_MCP47FEB02) instead to
maintain namespace encapsulation?
-
That is a good spot. Yes, this should use the NS variant.
Thanks,
Jonathan
--
Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
next prev parent reply other threads:[~2026-09-20 22:52 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 9:06 [PATCH v7 00/11] Refactor Microchip MCP47FEB02 I2C driver in separate modules to add support for MCP48FEB02 SPI driver Ariana Lazar
2026-09-18 9:06 ` [PATCH v7 01/11] iio: dac: mcp47feb02: initialize dac_data field in channel data struct at probe Ariana Lazar
2026-09-18 9:48 ` Andy Shevchenko
2026-09-18 9:06 ` [PATCH v7 02/11] iio: dac: mcp47feb02: Fix gain field initialization for active channels Ariana Lazar
2026-09-18 9:48 ` Andy Shevchenko
2026-09-18 9:06 ` [PATCH v7 03/11] iio: dac: mcp47feb02: use field_get() instead of custom dynamic macros Ariana Lazar
2026-09-18 9:17 ` sashiko-bot
2026-09-18 9:46 ` Andy Shevchenko
2026-09-20 18:44 ` Jonathan Cameron
2026-09-18 9:06 ` [PATCH v7 04/11] iio: dac: mcp47feb02: Return len when disabling EEPROM store Ariana Lazar
2026-09-18 9:49 ` Andy Shevchenko
2026-09-18 9:06 ` [PATCH v7 05/11] iio: dac: mcp47feb02: Increase EEPROM Programming Write Cycle Time Ariana Lazar
2026-09-18 9:49 ` Andy Shevchenko
2026-09-18 9:06 ` [PATCH v7 06/11] iio: dac: mcp47feb02: Avoid unjustified probe error on missing label Ariana Lazar
2026-09-18 9:22 ` sashiko-bot
2026-09-18 9:50 ` Andy Shevchenko
2026-09-20 22:52 ` Jonathan Cameron
2026-09-18 9:06 ` [PATCH v7 07/11] iio: dac: mcp47feb02: correct typo from a comment Ariana Lazar
2026-09-18 9:51 ` Andy Shevchenko
2026-09-18 9:06 ` [PATCH v7 08/11] iio: dac: mcp47feb02: use field_prep() instead of custom dynamic macros Ariana Lazar
2026-09-18 9:06 ` [PATCH v7 09/11] iio: dac: mcp47feb02: refactor MCP47FEB02 I2C driver into two modules Ariana Lazar
2026-09-18 9:28 ` sashiko-bot
2026-09-20 22:52 ` Jonathan Cameron [this message]
2026-09-18 9:06 ` [PATCH v7 10/11] dt-bindings: iio: dac: add support for MCP48FEB02 SPI Ariana Lazar
2026-09-18 9:06 ` [PATCH v7 11/11] iio: dac: add support for Microchip MCP48FEB02 Ariana Lazar
2026-09-18 9:52 ` [PATCH v7 00/11] Refactor Microchip MCP47FEB02 I2C driver in separate modules to add support for MCP48FEB02 SPI driver Andy Shevchenko
2026-09-20 23:08 ` Jonathan Cameron
2026-09-21 14:16 ` Ariana.Lazar
2026-09-21 23:56 ` 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=178994474989.706584.9211319682095053097.b4-review@b4 \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox