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

From: Greg Kroah-Hartman
Date: Tue Jul 28 2020 - 14:52:30 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.

> +
> + 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?

thanks,

greg k-h