All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Tomas Winkler <tomas.winkler@intel.com>
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org,
	Natalia Ovsyanikov <natalia.ovsyanikov@intel.com>
Subject: Re: [char-misc-next 2/3] mei: adding sysfs fw_status attribute
Date: Wed, 24 Jul 2013 09:00:08 -0700	[thread overview]
Message-ID: <20130724160008.GA17083@kroah.com> (raw)
In-Reply-To: <1374680517-30894-3-git-send-email-tomas.winkler@intel.com>

On Wed, Jul 24, 2013 at 06:41:56PM +0300, Tomas Winkler wrote:
> Export fw status register through sysfs interface.
> The interface is for applications that monitors
> fw health.
> 
> Signed-off-by: Natalia Ovsyanikov <natalia.ovsyanikov@intel.com>
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> ---
>  drivers/misc/mei/main.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 51 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
> index 173ff09..64e36a8 100644
> --- a/drivers/misc/mei/main.c
> +++ b/drivers/misc/mei/main.c
> @@ -659,6 +659,44 @@ out:
>  	return mask;
>  }
>  
> +/**
> + * mei_show_fw_status - mei device attribute show method
> + *
> + * @dev:  device pointer
> + * @attr: attribute pointer
> + * @buf:  char out buffer
> + *
> + * returns number of the bytes, printed into the buffer
> + */
> +
> +static ssize_t mei_show_fw_status(struct device *device,
> +		struct device_attribute *attr, char *buf)
> +{
> +	struct mei_device *dev = dev_get_drvdata(device);
> +	u32 fw_status;
> +	int err;
> +
> +	mutex_lock(&dev->device_lock);
> +	err = mei_fw_status(dev, &fw_status);
> +	mutex_unlock(&dev->device_lock);
> +	if (err) {
> +		dev_err(device, "attribute show: read fw_status error = %d\n",
> +			err);
> +		return err;
> +	}
> +
> +	dev_dbg(device, "attribute show: fw_status 0x%x\n", fw_status);
> +	return sprintf(buf, "%08X\n", fw_status);
> +}
> +static DEVICE_ATTR(fw_status, S_IRUGO, mei_show_fw_status, NULL);
> +static struct attribute *mei_attributes[] = {
> +	&dev_attr_fw_status.attr,
> +	NULL
> +};
> +static const struct attribute_group mei_attr_group = {
> +	.attrs  = mei_attributes,
> +};
> +
>  /*
>   * file operations structure will be used for mei char device.
>   */
> @@ -685,17 +723,22 @@ static struct miscdevice  mei_misc_device = {
>  		.minor = MISC_DYNAMIC_MINOR,
>  };
>  
> -
>  int mei_register(struct mei_device *dev)
>  {
> +	struct device *device = &dev->pdev->dev;
>  	int ret;
> -	mei_misc_device.parent = &dev->pdev->dev;
> +
> +	mei_misc_device.parent = device;
>  	ret = misc_register(&mei_misc_device);
>  	if (ret)
>  		return ret;
>  
> +	ret = sysfs_create_group(&device->kobj, &mei_attr_group);
> +	if (ret)
> +		return ret;

And you just lost the race with userspace (you told it you had a device,
it went and scanned your attributes and saved them, then you registered
more...)

Please use the dev_groups field for your class to properly have the
driver core register these before userspace is told about the device,
that's the correct way to do this.

thanks,

greg k-h

  reply	other threads:[~2013-07-24 16:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24 15:41 [char-misc-next 0/3] mei: export fw status register through sysfs Tomas Winkler
2013-07-24 15:41 ` [char-misc-next 1/3] mei me: add handler for me_hw_ops fw_status Tomas Winkler
2013-07-24 15:41 ` [char-misc-next 2/3] mei: adding sysfs fw_status attribute Tomas Winkler
2013-07-24 16:00   ` Greg KH [this message]
2013-07-24 16:20     ` Winkler, Tomas
2013-07-24 16:26       ` Greg KH
2013-07-24 18:04         ` Winkler, Tomas
2013-07-24 20:29           ` Greg KH
2013-07-28  8:48             ` Winkler, Tomas
2013-07-28 15:31               ` Greg KH
2013-07-29 22:27                 ` Winkler, Tomas
2013-07-29 22:38                   ` Greg KH
2013-07-29 23:08                     ` Winkler, Tomas
2013-07-29 23:17                       ` Greg KH
2013-08-01  7:21                         ` Winkler, Tomas
2013-08-01  7:32                           ` Greg KH
2013-07-24 15:41 ` [char-misc-next 3/3] mei: update ABI for fw_status register exported through sysfs Tomas Winkler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130724160008.GA17083@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natalia.ovsyanikov@intel.com \
    --cc=tomas.winkler@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.