Re: [PATCH 1/4] hwmon: (oxp-sensors) Separate logic from device-specific data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxx wrote:
> > > From: Tobias Jakobi <tjakobi@xxxxxxxxxxxxxxxxxxxxx>
> > > 
> > > 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@xxxxxxxxxxxxxxxxxxxxx>
> > > ---
> > >   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




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux