linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/4] Start unification of of_device_id and i2c_device_id
@ 2023-08-14 21:52 Dmitry Torokhov
  2023-08-14 21:52 ` [PATCH RFC 1/4] i2c: start migrating to a pointer in i2c_device_id Dmitry Torokhov
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2023-08-14 21:52 UTC (permalink / raw)
  To: Wolfram Sang, Andy Shevchenko, Andi Shyti, Biju Das,
	Jonathan Cameron, Michael Hennerich, Peter Rosin
  Cc: linux-i2c, linux-kernel

i2c_device_id is using unsigned long as driver data, whereas
of_device_id is using a void pointer. Normally drivers use them both as
either a pointer or a scalar, but in some cases driver's authors chose
to treat one as a pointer and another as a scalar that is being used as
an index in array of chip-specific data, i.e. something like this:

	data = device_get_match_data(...);
	if (!data) {
		id = i2c_client_get_device_id(...);
		data = &some_array[id->driver_data];
	}

This makes it hard to turn device_get_match_data() into truly generic
function working well for ACPI and DT, as well as for legacy cases.

So let's try to switch i2c_device_id to also use a void pointer and
first switch drivers with the patterns above to it, and then the rest of
them.

I did a conversion of a couple of drivers in i2c to illustrate.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Dmitry Torokhov (4):
      i2c: start migrating to a pointer in i2c_device_id
      i2c: mux: ltc4306: convert to using a pointer in i2c_device_id
      i2c: mux: pca954x: convert to using a pointer in i2c_device_id
      i2c: slave-eeprom: convert to using a pointer in i2c_device_id

 drivers/i2c/i2c-core-base.c         |  2 +-
 drivers/i2c/i2c-slave-eeprom.c      | 99 ++++++++++++++++++++++++-------------
 drivers/i2c/muxes/i2c-mux-ltc4306.c |  7 ++-
 drivers/i2c/muxes/i2c-mux-pca954x.c | 28 +++++------
 include/linux/mod_devicetable.h     |  3 +-
 5 files changed, 86 insertions(+), 53 deletions(-)
---
base-commit: 21ef7b1e17d039053edaeaf41142423810572741
change-id: 20230814-i2c-id-rework-9a4742e9ee52

Best regards,
-- 
Dmitry


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-08-15 15:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-14 21:52 [PATCH RFC 0/4] Start unification of of_device_id and i2c_device_id Dmitry Torokhov
2023-08-14 21:52 ` [PATCH RFC 1/4] i2c: start migrating to a pointer in i2c_device_id Dmitry Torokhov
2023-08-15 15:55   ` Andy Shevchenko
2023-08-14 21:52 ` [PATCH RFC 2/4] i2c: mux: ltc4306: convert to using " Dmitry Torokhov
2023-08-15 15:50   ` Andy Shevchenko
2023-08-14 21:52 ` [PATCH RFC 3/4] i2c: mux: pca954x: " Dmitry Torokhov
2023-08-15 15:51   ` Andy Shevchenko
2023-08-14 21:52 ` [PATCH RFC 4/4] i2c: slave-eeprom: " Dmitry Torokhov
2023-08-15 15:53   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).