linux-kernel.vger.kernel.org archive mirror
 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
Subject: Re: [char-misc-next 2/3] mei: export fw status registers through sysfs
Date: Wed, 26 Nov 2014 19:05:38 -0800	[thread overview]
Message-ID: <20141127030538.GB8656@kroah.com> (raw)
In-Reply-To: <1416409300-14431-2-git-send-email-tomas.winkler@intel.com>

On Wed, Nov 19, 2014 at 05:01:39PM +0200, Tomas Winkler wrote:
> The interface is for applications that monitor
> the fw health.
> 
> We use device_create_with_groups interface
> to register attribute with the mei class device
> 
> Signed-off-by :Tomas Winkler <tomas.winkler@intel.com>
> 
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> ---
>  drivers/misc/mei/main.c | 43 +++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 41 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
> index 5d6a15c3619a..3c019c0e60eb 100644
> --- a/drivers/misc/mei/main.c
> +++ b/drivers/misc/mei/main.c
> @@ -627,6 +627,44 @@ out:
>  	return mask;
>  }
>  
> +/**
> + * fw_status_show - mei device attribute show method
> + *
> + * @device: device pointer
> + * @attr: attribute pointer
> + * @buf:  char out buffer
> + *
> + * Return: number of the bytes printed into buf or error
> + */
> +static ssize_t fw_status_show(struct device *device,
> +		struct device_attribute *attr, char *buf)
> +{
> +	struct mei_device *dev = dev_get_drvdata(device);
> +	struct mei_fw_status fw_status;
> +	int err, i;
> +	ssize_t cnt = 0;
> +
> +	mutex_lock(&dev->device_lock);
> +	err = mei_fw_status(dev, &fw_status);
> +	mutex_unlock(&dev->device_lock);
> +	if (err) {
> +		dev_err(device, "read fw_status error = %d\n", err);
> +		return err;
> +	}
> +
> +	for (i = 0; i < fw_status.count; i++)
> +		cnt += scnprintf(buf + cnt, PAGE_SIZE - cnt, "%08X\n",
> +				fw_status.status[i]);

That really looks like more than a "one value per file" thing.

Hint, if you are ever worrying about the size of the buffer for your
sysfs file, you are doing something wrong.

thanks,

greg k-h

  parent reply	other threads:[~2014-11-27  3:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-19 15:01 [char-misc-next 1/3] mei: read and print all six FW status registers Tomas Winkler
2014-11-19 15:01 ` [char-misc-next 2/3] mei: export fw status registers through sysfs Tomas Winkler
2014-11-27  3:04   ` Greg KH
2014-11-27  3:05   ` Greg KH [this message]
2014-11-19 15:01 ` [char-misc-next 3/3] mei: add ABI documentation for fw_status exported " Tomas Winkler
2014-11-27  3:05   ` Greg KH

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=20141127030538.GB8656@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).