Re: [PATCH 2/3] hwmon: (coretemp) Remove unnecessary dependency of array index

From: Zhang, Rui
Date: Fri Dec 01 2023 - 12:31:41 EST



> > >         mutex_lock(&tdata->update_lock);
> > > @@ -445,7 +441,6 @@ static int create_core_attrs(struct temp_data
> > > *tdata, struct device *dev,
> > >                 tdata->sd_attrs[i].dev_attr.attr.name = tdata-
> > > >attr_name[i];
> > >                 tdata->sd_attrs[i].dev_attr.attr.mode = 0444;
> > >                 tdata->sd_attrs[i].dev_attr.show = rd_ptr[i];
> > > -               tdata->sd_attrs[i].index = attr_no;
> >
> > I was naively thinking if we could nuke that "index". I can see
> > that used
> > in couple macros, but seems like we can lose it?
> >
> > Completely untested.. and uncertain :-)
> >
>
> If you had suggested to replace
>         struct sensor_device_attribute sd_attrs[TOTAL_ATTRS];
> with
>         struct device_attribute sd_attrs[TOTAL_ATTRS];
> what you suggested may actually be possible and make sense.

Too late for me today.
Let me check if I can convert it to use device_attribute instead
tomorrow.

thanks,
rui