Re: [PATCH v3 1/1] platform/chrome: Poke kb_wake_angle attribute visibility when needed

From: Gwendal Grignou
Date: Fri Nov 18 2022 - 01:43:34 EST


On Thu, Nov 17, 2022 at 6:01 PM Tzung-Bi Shih <tzungbi@xxxxxxxxxx> wrote:
>
> On Wed, Nov 16, 2022 at 10:23:38AM -0800, Gwendal Grignou wrote:
> > [+chrome-platform@xxxxxxxxxxxxxxx]
>
> Please also Cc to the mailing list if the patch gets chance to have
> next version.
>
> > On Mon, Nov 14, 2022 at 8:10 PM Gwendal Grignou <gwendal@xxxxxxxxxxxx> wrote:
> [...]
> > > > Expose the attribute group to alter to close a potiential race between
> > > > cros-ec-sensorhub and cros-ec-sysfs (that creates the attribute group
> > > > on behalf of the class driver).
>
> I failed to realize the potential race. Could you explain it a bit?
The decision to show or not an attribute is done at the attribute file
creation time, once. If the module cros_ec_sysfs is loaded before
cros_ec_sensorhub, the attribute kb_wake_angle will never be shown. If
it is loaded after, and there are 2 accelerometers, the is_visible()
function will return true and the attribute is shown.

This patch ensures the attribute is_visible() is run again after the
sensorhub driver is loaded.

Gwendal.
>
> > > > diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h
> > > > index 02599687770c5..c6dca260bbd5d 100644
> > > > --- a/include/linux/platform_data/cros_ec_proto.h
> > > > +++ b/include/linux/platform_data/cros_ec_proto.h
> > > > @@ -191,6 +191,7 @@ struct cros_ec_platform {
> > > > /**
> > > > * struct cros_ec_dev - ChromeOS EC device entry point.
> > > > * @class_dev: Device structure used in sysfs.
> > > > + * @groups: sysfs attributes groups for this EC.
>
> The field name has extra "s".