All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Puranjay Mohan" <puranjay@kernel.org>,
	"Marcelo Schmitt" <marcelo.schmitt@analog.com>,
	"Antoniu Miclaus" <antoniu.miclaus@analog.com>,
	"Ramona Gradinariu" <ramona.gradinariu@analog.com>,
	"Petre Rodan" <petre.rodan@subdimension.ro>,
	"Dan Robertson" <dan@dlrobertson.com>,
	"Herve Codina" <herve.codina@bootlin.com>,
	"Matti Vaittinen" <mazziesaccount@gmail.com>,
	"Francesco Dolcini" <francesco@dolcini.it>,
	"João Paulo Gonçalves" <jpaulo.silvagoncalves@gmail.com>,
	"Hugo Villeneuve" <hvilleneuve@dimonoff.com>,
	"Anshul Dalal" <anshulusr@gmail.com>,
	"Gustavo Silva" <gustavograzs@gmail.com>,
	"Andreas Klinger" <ak@it-klinger.de>,
	"Tomasz Duszynski" <tduszyns@gmail.com>,
	"Ariana Lazar" <ariana.lazar@microchip.com>,
	"Rui Miguel Silva" <rmfrfs@gmail.com>,
	"Linus Walleij" <linusw@kernel.org>,
	"Javier Carrasco" <javier.carrasco.cruz@gmail.com>,
	"Li peiyu" <579lpy@gmail.com>,
	"Lorenzo Bianconi" <lorenzo@kernel.org>,
	"Alex Lanzano" <lanzano.alex@gmail.com>,
	"Jagath Jog J" <jagathjog1996@gmail.com>,
	"Jean-Baptiste Maneyrol" <jean-baptiste.maneyrol@tdk.com>,
	"Remi Buisson" <remi.buisson@tdk.com>,
	"Christian Eggers" <ceggers@arri.de>,
	"Mudit Sharma" <muditsharma.info@gmail.com>,
	"Kevin Tsai" <ktsai@capellamicro.com>,
	"Ondřej Jirman" <megi@xff.cz>,
	"Dixit Parmar" <dixitparmar19@gmail.com>,
	"Gerald Loacker" <gerald.loacker@wolfvision.net>,
	"Akhilesh Patil" <akhilesh@ee.iitb.ac.in>,
	"Eddie James" <eajames@linux.ibm.com>,
	"Petar Stoykov" <petar.stoykov@prodrive-technologies.com>,
	"Song Qiang" <songqiang1304521@gmail.com>,
	"Siratul Islam" <email@sirat.me>, "Crt Mori" <cmo@melexis.com>,
	"Waqar Hameed" <waqar.hameed@axis.com>,
	"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
	"Gustavo Vaz" <gustavo.vaz@usp.br>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"Marcus Folkesson" <marcus.folkesson@gmail.com>,
	"Guenter Roeck" <linux@roeck-us.net>,
	"Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>,
	"Chuang Zhu" <git@chuang.cz>,
	"Kyle Hsieh" <kylehsieh1995@gmail.com>,
	"Giorgi Tchankvetadze" <giorgitchankvetadze1997@gmail.com>,
	"Chen-Yu Tsai" <wens@kernel.org>,
	"Oleksij Rempel" <o.rempel@pengutronix.de>,
	"Romain Gantois" <romain.gantois@bootlin.com>,
	"Sander Vanheule" <sander@svanheule.net>,
	"David Jander" <david@protonic.nl>, "Andrew Davis" <afd@ti.com>,
	chuguangqing <chuguangqing@inspur.com>,
	"Shrikant Raskar" <raskar.shree97@gmail.com>,
	"Kurt Borja" <kuurtb@gmail.com>,
	"Denis Benato" <benato.denis96@gmail.com>,
	"Ethan Tidmore" <ethantidmore06@gmail.com>,
	"Tomas Borquez" <tomasborquez13@gmail.com>,
	"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
	"Shi Hao" <i.shihao.999@gmail.com>,
	"Xichao Zhao" <zhao.xichao@vivo.com>,
	"Erikas Bitovtas" <xerikasxx@gmail.com>,
	"Aldo Conte" <aldocontelk@gmail.com>,
	"Colin Ian King" <colin.i.king@gmail.com>,
	"Gabriel Almeida" <gabrielsousa230@gmail.com>,
	"Gabriela Victor" <gabevictor333@gmail.com>,
	"Beatriz Viana Costa" <beatrizvianacosta16@gmail.com>,
	"Frank Li" <Frank.Li@nxp.com>,
	"Adrian Fluturel" <fluturel.adrian@gmail.com>,
	"Antoni Pokusinski" <apokusinski01@gmail.com>,
	"Yasin Lee" <yasin.lee.x@gmail.com>,
	"Felix Gu" <ustc.gu@gmail.com>,
	"Ben Collins" <bcollins@watter.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 7/7] iio: Initialize i2c_device_id arrays using member names
Date: Thu, 21 May 2026 15:20:09 +0200	[thread overview]
Message-ID: <ag8BYvxUs0Jni5op@monoceros> (raw)
In-Reply-To: <20260521130444.197d2867@jic23-huawei>

[-- Attachment #1: Type: text/plain, Size: 7467 bytes --]

Hello Jonathan,

On Thu, May 21, 2026 at 01:04:44PM +0100, Jonathan Cameron wrote:
> On Tue, 19 May 2026 21:51:20 +0200
> Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:
> > On Tue, May 19, 2026 at 07:39:13PM +0100, Jonathan Cameron wrote:
> > > On Tue, 19 May 2026 10:13:09 +0200
> > > Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:
> > >   
> > > > While being less compact, using named initializers allows to more easily
> > > > see which members of the structs are assigned which value without having
> > > > to lookup the declaration of the struct. And it's also more robust
> > > > against changes to the struct definition.
> > > > 
> > > > The mentioned robustness is relevant for a planned change to struct
> > > > i2c_device_id that replaces .driver_data by an anonymous union.
> > > > 
> > > > This patch doesn't modify the compiled arrays, only their representation
> > > > in source form benefits. The former was confirmed with x86 and arm64
> > > > builds.
> > > > 
> > > > Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>  
> > > 
> > > I'd prefer it split into cases you care about (not just name) and the name only ones.
> > > That is unless I'm missing some potential change that breaks initializing
> > > just the first element and hence not the union you plan to add.
> > > 
> > > It's a lot of churn and the name one isn't enabling anything new unless
> > > I'm missing something.  
> > 
> > Today all hunks are about using named initializers to improve
> > readability, so the split into only .name vs. .name+.driver_data feels
> > very artificial to me. But if you think that's the compromise to use,
> > I'll adapt.
> > 
> > > We also get fixes in these annoyingly often so chances are this will mess
> > > up backports.  Might even be worth splitting it up into directories
> > > just to reduce that backport mess.  
> > 
> > In my opinion this is the reason to do this kind of cleanup with one
> > patch per driver. This doesn't only make backports easier, it also
> > allows to better record who reviewed and acked what, it reduces merge
> > conflicts (because if one driver is updated in your tree already since
> > my base, with one subsystem patch you get a merge conflict which makes
> > the whole patch unapplicable, with one patch per driver only one out of
> > (here) 208 fails).
> > 
> > But that isn't popular with most subsystem maintainers and so I went
> > with one patch per subsystem. 🤷
> 
> Meh.  This is going to be painful whatever, so to have it as fresh
> as possible I'll pick it up now as one giant patch.

\o/, thanks.

> Note there are already conflicts... Fixed up:
> light/tsl2772.c (a couple more entries)
> light/vcnl4000.c (data is now all pointers, not enum values).
> 
> Bunch of line changes in other drivers, but otherwise went in fine.

I reproduced the issue, my conflict resolution (on top of next-20260521)
looks as follows:

diff --cc drivers/iio/light/tsl2772.c
index 9ba8140c8bc1,1b1c704f1d6c..000000000000
--- a/drivers/iio/light/tsl2772.c
+++ b/drivers/iio/light/tsl2772.c
@@@ -1900,19 -1888,17 +1900,19 @@@ static int tsl2772_resume(struct devic
  }
  
  static const struct i2c_device_id tsl2772_idtable[] = {
- 	{ "tsl2571", tsl2571 },
- 	{ "tsl2671", tsl2671 },
- 	{ "tmd2671", tmd2671 },
- 	{ "tsl2771", tsl2771 },
- 	{ "tmd2771", tmd2771 },
- 	{ "tsl2572", tsl2572 },
- 	{ "tsl2672", tsl2672 },
- 	{ "tmd2672", tmd2672 },
- 	{ "tsl2772", tsl2772 },
- 	{ "tmd2772", tmd2772 },
- 	{ "apds9900", apds9900 },
- 	{ "apds9901", apds9900 },
- 	{ "apds9930", apds9930 },
+ 	{ .name = "tsl2571", .driver_data = tsl2571 },
+ 	{ .name = "tsl2671", .driver_data = tsl2671 },
+ 	{ .name = "tmd2671", .driver_data = tmd2671 },
+ 	{ .name = "tsl2771", .driver_data = tsl2771 },
+ 	{ .name = "tmd2771", .driver_data = tmd2771 },
+ 	{ .name = "tsl2572", .driver_data = tsl2572 },
+ 	{ .name = "tsl2672", .driver_data = tsl2672 },
+ 	{ .name = "tmd2672", .driver_data = tmd2672 },
+ 	{ .name = "tsl2772", .driver_data = tsl2772 },
+ 	{ .name = "tmd2772", .driver_data = tmd2772 },
++	{ .name = "apds9900", .driver_data = apds9900 },
++	{ .name = "apds9901", .driver_data = apds9900 },
+ 	{ .name = "apds9930", .driver_data = apds9930 },
  	{ }
  };
  
diff --cc drivers/iio/light/vcnl4000.c
index 88fc7424ae35,fc2161d5f3c7..000000000000
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@@ -2039,18 -2142,6 +2039,18 @@@ static int vcnl4000_runtime_resume(stru
  static DEFINE_RUNTIME_DEV_PM_OPS(vcnl4000_pm_ops, vcnl4000_runtime_suspend,
  				 vcnl4000_runtime_resume, NULL);
  
 +static const struct i2c_device_id vcnl4000_id[] = {
- 	{ "cm36672p", (kernel_ulong_t)&cm36672p_spec },
- 	{ "cm36686", (kernel_ulong_t)&vcnl4040_spec },
- 	{ "vcnl4000", (kernel_ulong_t)&vcnl4000_spec },
- 	{ "vcnl4010", (kernel_ulong_t)&vcnl4010_spec },
- 	{ "vcnl4020", (kernel_ulong_t)&vcnl4010_spec },
- 	{ "vcnl4040", (kernel_ulong_t)&vcnl4040_spec },
- 	{ "vcnl4200", (kernel_ulong_t)&vcnl4200_spec },
++	{ .name = "cm36672p", .driver_data = (kernel_ulong_t)&cm36672p_spec },
++	{ .name = "cm36686", .driver_data = (kernel_ulong_t)&vcnl4040_spec },
++	{ .name = "vcnl4000", .driver_data = (kernel_ulong_t)&vcnl4000_spec },
++	{ .name = "vcnl4010", .driver_data = (kernel_ulong_t)&vcnl4010_spec },
++	{ .name = "vcnl4020", .driver_data = (kernel_ulong_t)&vcnl4010_spec },
++	{ .name = "vcnl4040", .driver_data = (kernel_ulong_t)&vcnl4040_spec },
++	{ .name = "vcnl4200", .driver_data = (kernel_ulong_t)&vcnl4200_spec },
 +	{ }
 +};
 +MODULE_DEVICE_TABLE(i2c, vcnl4000_id);
 +
  static struct i2c_driver vcnl4000_driver = {
  	.driver = {
  		.name   = VCNL4000_DRV_NAME,
diff --git a/drivers/iio/adc/rtq6056.c b/drivers/iio/adc/rtq6056.c
index e2b1da13c0d3..ae50fb27bac9 100644
--- a/drivers/iio/adc/rtq6056.c
+++ b/drivers/iio/adc/rtq6056.c
@@ -872,8 +872,8 @@ static const struct richtek_dev_data rtq6059_devdata = {
 };
 
 static const struct i2c_device_id rtq6056_id[] = {
-	{ "rtq6056", (kernel_ulong_t)&rtq6056_devdata },
-	{ "rtq6059", (kernel_ulong_t)&rtq6059_devdata },
+	{ .name = "rtq6056", .driver_data = (kernel_ulong_t)&rtq6056_devdata },
+	{ .name = "rtq6059", .driver_data = (kernel_ulong_t)&rtq6059_devdata },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, rtq6056_id);

The last hunk was made necessary by commit
ce80292ead5bb42b50a6b63e44fd95c0edf9d334. And I'm pretty sure that the
following is possible on top:

 static const struct of_device_id rtq6056_device_match[] = {
-	{ .compatible = "richtek,rtq6056", .data = &rtq6056_devdata },
-	{ .compatible = "richtek,rtq6059", .data = &rtq6059_devdata },
+	{ .compatible = "richtek,rtq6056" },
+	{ .compatible = "richtek,rtq6059" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, rtq6056_device_match);

> There are a few new instances in tree, though from a quick glance
> maybe no i2c ones.  Since you sent the first series I've been looking
> out for this in reviews, but some stuff was a already queued.
> 
> Anyhow, new ones can be dealt with in follow up patches.

There will more some more drivers I missed in other subsystems, so I'll
have to reiterate anyhow. If you catch drivers before going in, that's
great, but it's not a problem if you miss a few.

Thanks for your cooperation,
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2026-05-21 13:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19  8:13 [PATCH v2 0/7] iio: Rework i2c_device_id initialisation Uwe Kleine-König (The Capable Hub)
2026-05-19  8:13 ` [PATCH v2 1/7] iio: Drop unused driver_data in four i2c drivers Uwe Kleine-König (The Capable Hub)
2026-05-19  8:13 ` [PATCH v2 2/7] iio: accel: bmc150: Explicitly set .driver_data Uwe Kleine-König (The Capable Hub)
2026-05-19 18:42   ` Jonathan Cameron
2026-05-19  8:13 ` [PATCH v2 3/7] iio: adc: ad7091r5: Simplify driver_data handling Uwe Kleine-König (The Capable Hub)
2026-05-19 18:49   ` Jonathan Cameron
2026-05-21 17:15   ` Marcelo Schmitt
2026-05-22 11:59     ` Jonathan Cameron
2026-05-19  8:13 ` [PATCH v2 4/7] iio: dac: max5821: Drop unused i2c driver data Uwe Kleine-König (The Capable Hub)
2026-05-19 19:06   ` Jonathan Cameron
2026-05-19  8:13 ` [PATCH v2 5/7] iio: proximity: sx9324: Drop unused " Uwe Kleine-König (The Capable Hub)
2026-05-19 19:08   ` Jonathan Cameron
2026-05-19  8:13 ` [PATCH v2 6/7] iio: proximity: sx9360: " Uwe Kleine-König (The Capable Hub)
2026-05-19 19:09   ` Jonathan Cameron
2026-05-19  8:13 ` [PATCH v2 7/7] iio: Initialize i2c_device_id arrays using member names Uwe Kleine-König (The Capable Hub)
2026-05-19 11:35   ` Matti Vaittinen
2026-05-19 15:46   ` Sirat
2026-05-19 18:39   ` Jonathan Cameron
2026-05-19 19:51     ` Uwe Kleine-König (The Capable Hub)
2026-05-21 12:04       ` Jonathan Cameron
2026-05-21 13:20         ` Uwe Kleine-König (The Capable Hub) [this message]
2026-05-22 11:10           ` 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=ag8BYvxUs0Jni5op@monoceros \
    --to=u.kleine-koenig@baylibre.com \
    --cc=579lpy@gmail.com \
    --cc=Frank.Li@nxp.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=afd@ti.com \
    --cc=ak@it-klinger.de \
    --cc=akhilesh@ee.iitb.ac.in \
    --cc=aldocontelk@gmail.com \
    --cc=andy@kernel.org \
    --cc=anshulusr@gmail.com \
    --cc=antoniu.miclaus@analog.com \
    --cc=apokusinski01@gmail.com \
    --cc=ariana.lazar@microchip.com \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=bcollins@watter.com \
    --cc=beatrizvianacosta16@gmail.com \
    --cc=benato.denis96@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=ceggers@arri.de \
    --cc=chuguangqing@inspur.com \
    --cc=cmo@melexis.com \
    --cc=colin.i.king@gmail.com \
    --cc=dan@dlrobertson.com \
    --cc=david@protonic.nl \
    --cc=dixitparmar19@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=eajames@linux.ibm.com \
    --cc=email@sirat.me \
    --cc=ethantidmore06@gmail.com \
    --cc=fluturel.adrian@gmail.com \
    --cc=francesco@dolcini.it \
    --cc=gabevictor333@gmail.com \
    --cc=gabrielsousa230@gmail.com \
    --cc=gerald.loacker@wolfvision.net \
    --cc=giorgitchankvetadze1997@gmail.com \
    --cc=git@chuang.cz \
    --cc=gustavo.vaz@usp.br \
    --cc=gustavograzs@gmail.com \
    --cc=herve.codina@bootlin.com \
    --cc=hvilleneuve@dimonoff.com \
    --cc=i.shihao.999@gmail.com \
    --cc=jagathjog1996@gmail.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=jean-baptiste.maneyrol@tdk.com \
    --cc=jic23@kernel.org \
    --cc=jpaulo.silvagoncalves@gmail.com \
    --cc=ktsai@capellamicro.com \
    --cc=kuurtb@gmail.com \
    --cc=kylehsieh1995@gmail.com \
    --cc=lanzano.alex@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linusw@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lorenzo@kernel.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=marcus.folkesson@gmail.com \
    --cc=mazziesaccount@gmail.com \
    --cc=megi@xff.cz \
    --cc=muditsharma.info@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=o.rempel@pengutronix.de \
    --cc=petar.stoykov@prodrive-technologies.com \
    --cc=petre.rodan@subdimension.ro \
    --cc=puranjay@kernel.org \
    --cc=ramona.gradinariu@analog.com \
    --cc=raskar.shree97@gmail.com \
    --cc=remi.buisson@tdk.com \
    --cc=rmfrfs@gmail.com \
    --cc=romain.gantois@bootlin.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sander@svanheule.net \
    --cc=songqiang1304521@gmail.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=tduszyns@gmail.com \
    --cc=tomasborquez13@gmail.com \
    --cc=ustc.gu@gmail.com \
    --cc=waqar.hameed@axis.com \
    --cc=wens@kernel.org \
    --cc=xerikasxx@gmail.com \
    --cc=yasin.lee.x@gmail.com \
    --cc=zhao.xichao@vivo.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 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.