linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Andreas Werner <andreas.werner@men.de>
Cc: linux-kernel@vger.kernel.org, sameo@linux.intel.com,
	wsa@the-dreams.de, linux-i2c@vger.kernel.org
Subject: Re: [PATCH v2 3/4] mfd: menf21bmc: Add additional sysfs entries for BMC status information
Date: Mon, 25 Jan 2016 16:07:30 +0000	[thread overview]
Message-ID: <20160125160730.GV3368@x1> (raw)
In-Reply-To: <278283b66344e1ca556761abbcb87a20ecb21436.1452514293.git.andreas.werner@men.de>

On Mon, 11 Jan 2016, Andreas Werner wrote:

> This patch adds additional sysfs entries to provide status
> information to the userland.
> 
> The following informations are now provided:
>         - Get operation hours counter
>         - Get board slot address
>         - Get powercycle counter
>         - Set/get Hw Variant
> 
> Signed-off-by: Andreas Werner <andreas.werner@men.de>
> ---
>  drivers/mfd/menf21bmc.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 93 insertions(+)

Acked-by: Lee Jones <lee.jones@linaro.org>

> diff --git a/drivers/mfd/menf21bmc.c b/drivers/mfd/menf21bmc.c
> index b11bd6b..dd068c0 100644
> --- a/drivers/mfd/menf21bmc.c
> +++ b/drivers/mfd/menf21bmc.c
> @@ -20,6 +20,10 @@
>  #define BMC_CMD_REV_MAJOR	0x80
>  #define BMC_CMD_REV_MINOR	0x81
>  #define BMC_CMD_REV_MAIN	0x82
> +#define BMC_CMD_SLOT_ADDRESS	0x8c
> +#define BMC_CMD_HW_VARIANT	0x8f
> +#define BMC_CMD_PWRCYCL_CNT	0x93
> +#define BMC_CMD_OP_HRS_CNT	0x94
>  
>  static struct mfd_cell menf21bmc_cell[] = {
>  	{ .name = "menf21bmc_wdt", },
> @@ -66,11 +70,100 @@ static ssize_t menf21bmc_mode_store(struct device *dev,
>  	return size;
>  }
>  
> +static ssize_t menf21bmc_hw_variant_show(struct device *dev,
> +					 struct device_attribute *attr,
> +					 char *buf)
> +{
> +	struct i2c_client *client = to_i2c_client(dev);
> +	int val;
> +
> +	val = i2c_smbus_read_word_data(client, BMC_CMD_HW_VARIANT);
> +	if (val < 0)
> +		return val;
> +
> +	return sprintf(buf, "0x%04x\n", val);
> +
> +}
> +
> +static ssize_t menf21bmc_hw_variant_store(struct device *dev,
> +					  struct device_attribute *attr,
> +					  const char *buf, size_t size)
> +{
> +	struct i2c_client *client = to_i2c_client(dev);
> +	unsigned long hw_variant;
> +	int ret;
> +
> +	if (kstrtoul(buf, 0, &hw_variant))
> +		return -EINVAL;
> +
> +	if (hw_variant < 0 || hw_variant > 0xffff)
> +		return -EINVAL;
> +
> +	ret = i2c_smbus_write_word_data(client, BMC_CMD_HW_VARIANT,
> +					hw_variant);
> +	if (ret < 0)
> +		return ret;
> +
> +	return size;
> +
> +}
> +
> +static ssize_t menf21bmc_pwrcycl_cnt_show(struct device *dev,
> +					  struct device_attribute *attr,
> +					  char *buf)
> +{
> +	struct i2c_client *client = to_i2c_client(dev);
> +	int val;
> +
> +	val = i2c_smbus_read_word_data(client, BMC_CMD_PWRCYCL_CNT);
> +	if (val < 0)
> +		return val;
> +
> +	return sprintf(buf, "%d\n", val);
> +}
> +
> +static ssize_t menf21bmc_op_hrs_cnt_show(struct device *dev,
> +					 struct device_attribute *attr,
> +					 char *buf)
> +{
> +	struct i2c_client *client = to_i2c_client(dev);
> +	int val;
> +
> +	val = i2c_smbus_read_word_data(client, BMC_CMD_OP_HRS_CNT);
> +	if (val < 0)
> +		return val;
> +
> +	return sprintf(buf, "%d\n", val);
> +}
> +
> +static ssize_t menf21bmc_slot_address_show(struct device *dev,
> +					   struct device_attribute *attr,
> +					   char *buf)
> +{
> +	struct i2c_client *client = to_i2c_client(dev);
> +	int val;
> +
> +	val = i2c_smbus_read_byte_data(client, BMC_CMD_SLOT_ADDRESS);
> +	if (val < 0)
> +		return val;
> +
> +	return sprintf(buf, "%d\n", val);
> +}
> +
>  static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, menf21bmc_mode_show,
>  		   menf21bmc_mode_store);
> +static DEVICE_ATTR(hw_variant, S_IRUGO | S_IWUSR, menf21bmc_hw_variant_show,
> +		   menf21bmc_hw_variant_store);
> +static DEVICE_ATTR(pwrcycl_cnt, S_IRUGO, menf21bmc_pwrcycl_cnt_show, NULL);
> +static DEVICE_ATTR(op_hrs_cnt, S_IRUGO, menf21bmc_op_hrs_cnt_show, NULL);
> +static DEVICE_ATTR(slot_address, S_IRUGO, menf21bmc_slot_address_show, NULL);
>  
>  static struct attribute *menf21bmc_attributes[] = {
>  	&dev_attr_mode.attr,
> +	&dev_attr_hw_variant.attr,
> +	&dev_attr_pwrcycl_cnt.attr,
> +	&dev_attr_op_hrs_cnt.attr,
> +	&dev_attr_slot_address.attr,
>  	NULL
>  };
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2016-01-25 16:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11 12:20 [PATCH v2 0/4] remove auto exit of production and added sysfs interface Andreas Werner
2016-01-11 12:21 ` [PATCH v2 1/4] mfd: menf21bmc: Remove auto exiting of production mode and add " Andreas Werner
2016-01-25 16:08   ` Lee Jones
2016-01-11 12:21 ` [PATCH v2 2/4] doc: ABI: Added sysfs description for the menf21bmc MFD driver Andreas Werner
2016-01-11 12:21 ` [PATCH v2 3/4] mfd: menf21bmc: Add additional sysfs entries for BMC status information Andreas Werner
2016-01-25 16:07   ` Lee Jones [this message]
2016-01-11 12:22 ` [PATCH v2 4/4] doc: ABI: Add documentation for the additional sysfs " Andreas Werner

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=20160125160730.GV3368@x1 \
    --to=lee.jones@linaro.org \
    --cc=andreas.werner@men.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    --cc=wsa@the-dreams.de \
    /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).