RE: [char-misc-next V2] mei: add device kind to sysfs

From: Winkler, Tomas
Date: Tue Jul 28 2020 - 15:17:01 EST



>
> On Tue, Jul 28, 2020 at 09:28:36PM +0300, Tomas Winkler wrote:
> > +/**
> > + * kind_show - display device kind
> > + *
> > + * @device: device pointer
> > + * @attr: attribute pointer
> > + * @buf: char out buffer
> > + *
> > + * Return: number of the bytes printed into buf or error
>
> No need for kernel doc for static sysfs attributes, but ok...
>
> > + */
> > +static ssize_t kind_show(struct device *device,
> > + struct device_attribute *attr, char *buf) {
> > + struct mei_device *dev = dev_get_drvdata(device);
> > + ssize_t ret = 0;
>
> No need to initialize this.
Right, a leftover from an earlier version.
>
> > +
> > + mutex_lock(&dev->device_lock);
> > + if (dev->kind)
> > + ret = sprintf(buf, "%s\n", dev->kind);
> > + else
> > + ret = sprintf(buf, "%s\n", "mei");
> > + mutex_unlock(&dev->device_lock);
>
> Why do you need a lock? kind can not change, so what are you trying to
> protect from?
There might be firmware initiated reset but in this particular case you are right, the lock is not needed.

Will resend.