Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
To: Lee Jones <lee@kernel.org>
Cc: Colin Foster <colin.foster@in-advantage.com>,
	linux-kernel@vger.kernel.org,
	James Ogletree <jogletre@opensource.cirrus.com>,
	Fred Treven <fred.treven@cirrus.com>,
	Ben Bright <ben.bright@cirrus.com>,
	Support Opensource <support.opensource@diasemi.com>,
	Xu Yilun <yilun.xu@intel.com>, Tom Rix <trix@redhat.com>,
	Charles Keepax <ckeepax@opensource.cirrus.com>,
	Richard Fitzgerald <rf@opensource.cirrus.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	patches@opensource.cirrus.com, linux-sound@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	Orson Zhai <orsonzhai@gmail.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>
Subject: [PATCH v1 0/3] mfd: Initialize spi_device_id arrays using member names
Date: Thu,  2 Jul 2026 16:53:38 +0200	[thread overview]
Message-ID: <cover.1783003256.git.u.kleine-koenig@baylibre.com> (raw)

Hello,

this series targets to use named initializers for spi_device_id arrays.
In general these are better readable for humans and more robust to
changes in the respective struct definition.

This robustness is needed as I want to do

	diff --git a/include/linux/device-id/spi.h b/include/linux/device-id/spi.h
	index 812e7c3854a7..93d9cd45569a 100644
	--- a/include/linux/device-id/spi.h
	+++ b/include/linux/device-id/spi.h
	@@ -13,7 +13,11 @@ typedef unsigned long kernel_ulong_t;
	 
	 struct spi_device_id {
		char name[SPI_NAME_SIZE];
	-	kernel_ulong_t driver_data;	/* Data private to the driver */
	+	union {
	+		/* Data private to the driver */
	+		kernel_ulong_t driver_data;
	+		const void *driver_data_ptr;
	+	};
	 };
	 
	 #endif /* ifndef LINUX_MOD_DEVICE_ID_SPI_H */

which allows dropping several casts and eases porting CHERI to mainline
Linux. A possible follow-up change is the following example:

	diff --git a/drivers/mfd/intel-m10-bmc-spi.c b/drivers/mfd/intel-m10-bmc-spi.c
	index 94b9c99bb4f8..28a3cc84b778 100644
	--- a/drivers/mfd/intel-m10-bmc-spi.c
	+++ b/drivers/mfd/intel-m10-bmc-spi.c
	@@ -70,7 +70,7 @@ static int intel_m10_bmc_spi_probe(struct spi_device *spi)
		if (!ddata)
			return -ENOMEM;
	 
	-	info = (struct intel_m10bmc_platform_info *)id->driver_data;
	+	info = id->driver_data_ptr;
		ddata->dev = dev;
	 
		ddata->regmap = devm_regmap_init_spi_avmm(spi, &intel_m10bmc_regmap_config);
	@@ -160,9 +160,9 @@ static const struct intel_m10bmc_platform_info m10bmc_spi_n5010 = {
	 };
	 
	 static const struct spi_device_id m10bmc_spi_id[] = {
	-	{ .name = "m10-n3000", .driver_data = (kernel_ulong_t)&m10bmc_spi_n3000 },
	-	{ .name = "m10-d5005", .driver_data = (kernel_ulong_t)&m10bmc_spi_d5005 },
	-	{ .name = "m10-n5010", .driver_data = (kernel_ulong_t)&m10bmc_spi_n5010 },
	+	{ .name = "m10-n3000", .driver_data_ptr = &m10bmc_spi_n3000 },
	+	{ .name = "m10-d5005", .driver_data_ptr = &m10bmc_spi_d5005 },
	+	{ .name = "m10-n5010", .driver_data_ptr = &m10bmc_spi_n5010 },
		{ }
	 };
	 MODULE_DEVICE_TABLE(spi, m10bmc_spi_id);

increasing readability due to less explicit casting. This also yields
tighter type checking as the assignment in the first hunk results in a
warning if info wasn't a pointer to a const type.

If you consider the last patch mostly churn, just drop it.

There are no dependencies between the patches, and they are merge window
material.

Best regards
Uwe

Uwe Kleine-König (The Capable Hub) (3):
  mfd: Drop unused assignment of spi_device_id driver data
  mfd: Initialize spi_device_id arrays using member names
  mfd: Unify style of spi_device_id arrays

 drivers/mfd/altera-a10sr.c      |  2 +-
 drivers/mfd/arizona-spi.c       | 12 ++++++------
 drivers/mfd/cs40l50-spi.c       |  4 ++--
 drivers/mfd/da9052-spi.c        | 12 ++++++------
 drivers/mfd/intel-m10-bmc-spi.c |  6 +++---
 drivers/mfd/madera-spi.c        | 18 +++++++++---------
 drivers/mfd/motorola-cpcap.c    |  6 +++---
 drivers/mfd/ocelot-spi.c        |  2 +-
 drivers/mfd/rk8xx-spi.c         |  2 +-
 drivers/mfd/rsmu_spi.c          | 12 ++++++------
 drivers/mfd/sprd-sc27xx-spi.c   |  2 +-
 drivers/mfd/stmpe-spi.c         | 12 ++++++------
 drivers/mfd/tps65912-spi.c      |  2 +-
 drivers/mfd/wm831x-spi.c        | 16 ++++++++--------
 14 files changed, 54 insertions(+), 54 deletions(-)


base-commit: 4f441960e691d37c880d2cc004de06bb5b6bd5e4
-- 
2.55.0.11.g153666a7d9bb



             reply	other threads:[~2026-07-02 14:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02 14:53 Uwe Kleine-König (The Capable Hub) [this message]
2026-07-02 14:53 ` [PATCH v1 2/3] mfd: Initialize spi_device_id arrays using member names Uwe Kleine-König (The Capable Hub)

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=cover.1783003256.git.u.kleine-koenig@baylibre.com \
    --to=u.kleine-koenig@baylibre.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=ben.bright@cirrus.com \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=colin.foster@in-advantage.com \
    --cc=fred.treven@cirrus.com \
    --cc=jogletre@opensource.cirrus.com \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=orsonzhai@gmail.com \
    --cc=patches@opensource.cirrus.com \
    --cc=rf@opensource.cirrus.com \
    --cc=support.opensource@diasemi.com \
    --cc=trix@redhat.com \
    --cc=yilun.xu@intel.com \
    --cc=zhang.lyra@gmail.com \
    /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