From: Guenter Roeck <linux@roeck-us.net>
To: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Cc: "Derek John Clark" <derekjohn.clark@gmail.com>,
"Joaquín Ignacio Aramendía" <samsagax@gmail.com>,
"Jean Delvare" <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] hwmon: (oxp-sensors) Separate logic from device-specific data
Date: Tue, 7 Jan 2025 09:33:08 -0800 [thread overview]
Message-ID: <be6d995e-e1b5-4201-804e-ebedf05839e2@roeck-us.net> (raw)
In-Reply-To: <080bad40-6676-4369-9601-d2d200ae3ea2@math.uni-bielefeld.de>
On Thu, Dec 26, 2024 at 11:59:53PM +0100, Tobias Jakobi wrote:
> On 12/26/24 21:54, Guenter Roeck wrote:
> > On Thu, Dec 26, 2024 at 06:00:16PM +0100, tjakobi@math.uni-bielefeld.de wrote:
> > > From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> > >
> > > We currently have large switch-statements in all functions that
> > > write to EC registers, even though the bulk of the supported
> > > devices functions more or less the same.
> > >
> > > Factor the device-specific data out into a struct oxp_config. This
> > > only leaves logic in the corresponding functions and should make
> > > adding future devices much easier and less error-prone.
> > >
> > > Also introduce struct oxp_data which is going to be used in a
> > > later commit to cache device state.
> > >
> > > Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> > > ---
> > > drivers/hwmon/oxp-sensors.c | 517 +++++++++++++++---------------------
> > > 1 file changed, 215 insertions(+), 302 deletions(-)
> > >
> > ...
> > > +
> > > static const struct dmi_system_id dmi_table[] = {
> > > {
> > > .matches = {
> > > DMI_MATCH(DMI_BOARD_VENDOR, "AOKZOE"),
> > > DMI_EXACT_MATCH(DMI_BOARD_NAME, "AOKZOE A1 AR07"),
> > > },
> > > - .driver_data = (void *)aok_zoe_a1,
> > > + .driver_data = (void *)&config_aok_zoe,
> >
> > I have not looked at hte rest of the code, but the whole point of
> > void * is that a tyoe cast to or from it is not necessary.
> >
> > Guenter
> I'm also not happy with the cast. But it's either the cast or a warning,
> that the const qualifier is lost.
Your code is introducing that const qualifier.
>
> I'm open to suggestions here. But I don't think that leaving warnings around
> is a good idea.
Overriding a const qualifier isn't really a good idea either.
You could have used an array such as
static const struct oxp_config config_oxp[] = {
[aok_zoe_a1] = {
...
},
...
};
If multiple devices, such as aok_zoe_a1 and aya_neo_2, really don't need separate
feature flags, the unnecessary ones are just confusing and should be removed.
Thanks,
Guenter
next prev parent reply other threads:[~2025-01-07 17:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-26 17:00 [PATCH 0/4] hwmon: (oxp-sensors) Cleanup device type handling tjakobi
2024-12-26 17:00 ` [PATCH 1/4] hwmon: (oxp-sensors) Separate logic from device-specific data tjakobi
2024-12-26 20:54 ` Guenter Roeck
2024-12-26 22:59 ` Tobias Jakobi
2025-01-07 17:33 ` Guenter Roeck [this message]
2024-12-26 21:04 ` Guenter Roeck
2024-12-26 23:05 ` Tobias Jakobi
2025-01-07 17:34 ` Guenter Roeck
2024-12-26 17:00 ` [PATCH 2/4] hwmon: (oxp-sensors) Fix typos in documentation tjakobi
2024-12-26 17:00 ` [PATCH 3/4] hwmon: (oxp-sensors) Fix wording in code comment tjakobi
2024-12-26 20:52 ` Guenter Roeck
2024-12-26 22:56 ` Tobias Jakobi
2025-01-07 17:24 ` Guenter Roeck
2024-12-26 17:00 ` [PATCH 4/4] hwmon: (oxp-sensors) Cache state of PWM enable mode tjakobi
2024-12-26 21:05 ` Guenter Roeck
2024-12-26 23:13 ` Tobias Jakobi
2025-01-07 17:43 ` 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=be6d995e-e1b5-4201-804e-ebedf05839e2@roeck-us.net \
--to=linux@roeck-us.net \
--cc=derekjohn.clark@gmail.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=samsagax@gmail.com \
--cc=tjakobi@math.uni-bielefeld.de \
/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
all inboxes | Powered by JetHome®