From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
"Jean Delvare" <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org,
"George Joseph" <george.joseph@fairview5.com>,
"Juerg Haefliger" <juergh@proton.me>,
"Riku Voipio" <riku.voipio@iki.fi>,
"Carsten Spieß" <mail@carsten-spiess.de>,
"Zev Weiss" <zev@bewilderbeest.net>,
"Eric Tremblay" <etremblay@distech-controls.com>,
"Greg KH" <gregkh@linuxfoundation.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Grant Peltier" <grantpeltier93@gmail.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Rob Herring" <robh@kernel.org>,
"Mariel Tinaco" <Mariel.Tinaco@analog.com>,
"Peter Yin" <peteryin.openbmc@gmail.com>,
"Potin Lai" <potin.lai.pt@gmail.com>,
"Konstantin Aladyshev" <aladyshev22@gmail.com>,
"Patrick Rudolph" <patrick.rudolph@9elements.com>,
"Eddie James" <eajames@linux.ibm.com>,
"Lakshmi Yadlapati" <lakshmiy@us.ibm.com>,
linux-i2c@vger.kernel.org
Subject: Re: [PATCH] hwmon: Initialize i2c_device_id structures by name
Date: Sat, 7 Dec 2024 20:44:45 +0200 [thread overview]
Message-ID: <Z1SXnV93Q_1iqM6q@smile.fi.intel.com> (raw)
In-Reply-To: <403cc23e-db63-4091-932d-0ec82a32c52b@roeck-us.net>
On Sat, Dec 07, 2024 at 07:32:43AM -0800, Guenter Roeck wrote:
> On 12/7/24 01:13, Uwe Kleine-König wrote:
> > Hello Guenter,
> >
> > [dropped Jose Ramon San Buenaventura from Cc: who's address bounced]
> >
> > On Thu, Dec 05, 2024 at 08:27:15AM -0800, Guenter Roeck wrote:
> > > On Thu, Dec 05, 2024 at 04:28:33PM +0100, Uwe Kleine-König wrote:
> > > > I intend to change the definition of struct i2c_device_id to look as
> > > > follows:
> > > >
> > > > struct i2c_device_id {
> > > > char name[I2C_NAME_SIZE];
> > > > /* Data private to the driver */
> > > > union {
> > > > kernel_ulong_t driver_data;
> > > > const void *driver_data_ptr;
> > > > };
> > > > };
> > > >
> > > > That the initializers for these structures also work with this new
> > > > definition, they must use named members.
> > > >
> > > > The motivation for that change is to be able to drop many casts from
> > > > pointer to kernel_ulong_t. So once the definition is updated,
> > > > initializers that today use:
> > > >
> > > > {"adp4000", (kernel_ulong_t)&pmbus_info_one},
> > > >
> > > > can be changed to
> > > >
> > > > { .name = "adp4000", .driver_data_ptr = &pmbus_info_one },
> > > >
> > >
> > > How about introducing a macro for that instead, similar to I3C_DEVICE() ?
> >
> > OK, for now we'd have then:
> >
> > #define I2C_DEVICE_ID_PTR(_name, _driver_data_ptr) \
> > { .name = (_name), .driver_data = (kernel_ulong_t)_driver_data_ptr }
> >
> > #define I2C_DEVICE_ID_ULONG(_name, _driver_data) \
> > { .name = (_name), .driver_data = _driver_data }
> >
> > plus maybe:
> >
> > #define I2C_DEVICE_ID(_name) \
> > { .name = (_name) }
> >
> > for the drivers that don't need driver data?
> >
>
> Something like that, though I'd even hide the parameter type and just have
>
> #define I2C_DEVICE_ID_DATA(_name, _data) \
> { .name = (_name), .driver_data = (kernel_ulong_t)_data }
>
> #define I2C_DEVICE_ID(_name) \
> { .name = (_name) }
It's better, if we go this way, to keep this in sync with above by changing as
#define I2C_DEVICE_ID(_name) I2C_DEVICE_ID_DATA(_name, 0)
> where I2C_DEVICE_ID_DATA() would accept any type.
>
> > When all drivers are converted accordingly, we could change the
> > definition of i2c_device_id in a commit that only touches i2c core
> > things to introduce the stronger type checking.
>
> The stronger type checking would not be possible with that, though.
> Does that really add value ? I personally prefer the opaque style where
> driver users can provide (almost) any type they want/need.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-12-07 18:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-05 15:28 [PATCH] hwmon: Initialize i2c_device_id structures by name Uwe Kleine-König
2024-12-05 16:27 ` Guenter Roeck
2024-12-07 9:13 ` Uwe Kleine-König
2024-12-07 15:32 ` Guenter Roeck
2024-12-07 18:44 ` Andy Shevchenko [this message]
2024-12-07 18:46 ` Andy Shevchenko
2024-12-07 21:51 ` Guenter Roeck
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=Z1SXnV93Q_1iqM6q@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=Mariel.Tinaco@analog.com \
--cc=aladyshev22@gmail.com \
--cc=conor.dooley@microchip.com \
--cc=eajames@linux.ibm.com \
--cc=etremblay@distech-controls.com \
--cc=george.joseph@fairview5.com \
--cc=grantpeltier93@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jdelvare@suse.com \
--cc=juergh@proton.me \
--cc=lakshmiy@us.ibm.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mail@carsten-spiess.de \
--cc=patrick.rudolph@9elements.com \
--cc=peteryin.openbmc@gmail.com \
--cc=peterz@infradead.org \
--cc=potin.lai.pt@gmail.com \
--cc=riku.voipio@iki.fi \
--cc=robh@kernel.org \
--cc=u.kleine-koenig@baylibre.com \
--cc=wsa+renesas@sang-engineering.com \
--cc=zev@bewilderbeest.net \
/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