Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1306030 > unrolled thread
| Started by | Lee Jones <lee.jones@linaro.org> |
|---|---|
| First post | 2016-01-11 11:40 +0100 |
| Last post | 2016-01-11 11:50 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH 3/4] mfd/menf21bmc.c: add additional sysfs entries for BMC status information Lee Jones <lee.jones@linaro.org> - 2016-01-11 11:40 +0100
Re: [PATCH 3/4] mfd/menf21bmc.c: add additional sysfs entries for BMC status information Andreas Werner <andreas.werner@men.de> - 2016-01-11 11:50 +0100
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2016-01-11 11:40 +0100 |
| Subject | Re: [PATCH 3/4] mfd/menf21bmc.c: add additional sysfs entries for BMC status information |
| Message-ID | <qPI3g-13k-15@gated-at.bofh.it> |
On Wed, 16 Dec 2015, 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 | 99 +++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 96 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mfd/menf21bmc.c b/drivers/mfd/menf21bmc.c
> index 742ffe7..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", },
> @@ -28,7 +32,7 @@ static struct mfd_cell menf21bmc_cell[] = {
> };
>
> static ssize_t menf21bmc_mode_show(struct device *dev,
> - struct device_attribute *attr, char *buf)
> + struct device_attribute *attr, char *buf)
This is an irrelevant change. Please split it out.
> {
> struct i2c_client *client = to_i2c_client(dev);
> int val;
> @@ -41,8 +45,8 @@ static ssize_t menf21bmc_mode_show(struct device *dev,
> }
>
> static ssize_t menf21bmc_mode_store(struct device *dev,
> - struct device_attribute *attr,
> - const char *buf, size_t size)
> + struct device_attribute *attr,
> + const char *buf, size_t size)
This is an irrelevant change. Please split it out.
> {
> struct i2c_client *client = to_i2c_client(dev);
> unsigned long mode_val;
> @@ -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
[toc] | [next] | [standalone]
| From | Andreas Werner <andreas.werner@men.de> |
|---|---|
| Date | 2016-01-11 11:50 +0100 |
| Message-ID | <qPIcW-17S-5@gated-at.bofh.it> |
| In reply to | #1306030 |
On Mon, Jan 11, 2016 at 10:30:39AM +0000, Lee Jones wrote:
> On Wed, 16 Dec 2015, 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 | 99 +++++++++++++++++++++++++++++++++++++++++++++++--
> > 1 file changed, 96 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/mfd/menf21bmc.c b/drivers/mfd/menf21bmc.c
> > index 742ffe7..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", },
> > @@ -28,7 +32,7 @@ static struct mfd_cell menf21bmc_cell[] = {
> > };
> >
> > static ssize_t menf21bmc_mode_show(struct device *dev,
> > - struct device_attribute *attr, char *buf)
> > + struct device_attribute *attr, char *buf)
>
> This is an irrelevant change. Please split it out.
Argh, my mistake. I will fix it and resend this patch.
>
> > {
> > struct i2c_client *client = to_i2c_client(dev);
> > int val;
> > @@ -41,8 +45,8 @@ static ssize_t menf21bmc_mode_show(struct device *dev,
> > }
> >
> > static ssize_t menf21bmc_mode_store(struct device *dev,
> > - struct device_attribute *attr,
> > - const char *buf, size_t size)
> > + struct device_attribute *attr,
> > + const char *buf, size_t size)
>
> This is an irrelevant change. Please split it out.
>
> > {
> > struct i2c_client *client = to_i2c_client(dev);
> > unsigned long mode_val;
> > @@ -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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web