All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] hwmon: (nct7802) Add pwm mode
Date: Sat, 04 Jul 2015 22:19:45 +0000	[thread overview]
Message-ID: <55985C01.1040105@roeck-us.net> (raw)
In-Reply-To: <1436044026-2882-1-git-send-email-const@MakeLinux.com>

Hi Constantine,

On 07/04/2015 02:07 PM, Constantine Shulyupin wrote:
> Introduced: show_pwm_mode, pwm1_mode, pwm2_mode, pwm2_mode
> Signed-off-by: Constantine Shulyupin <const@MakeLinux.com>
> ---
>   drivers/hwmon/nct7802.c | 26 ++++++++++++++++++++++++++
>   1 file changed, 26 insertions(+)
>
> diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c
> index 56b6f7b..16e0d17 100644
> --- a/drivers/hwmon/nct7802.c
> +++ b/drivers/hwmon/nct7802.c
> @@ -102,6 +102,24 @@ static ssize_t store_temp_type(struct device *dev,
>   	return err ? : count;
>   }
>
> +static ssize_t show_pwm_mode(struct device *dev, struct device_attribute *attr,
> +			     char *buf)
> +{
> +	struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
> +	struct nct7802_data *data = dev_get_drvdata(dev);
> +	unsigned int regval;
> +	int ret;
> +
> +	if (sattr->index > 1)
> +		return sprintf(buf, "1\n");
> +
> +	ret = regmap_read(data->regmap, sattr->nr, &regval);
> +	if (ret < 0)
> +		return ret;
> +
> +	return sprintf(buf, "%u\n", !(regval & (1 << sattr->index)));
> +}
> +
>   static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr,
>   			char *buf)
>   {
> @@ -765,6 +783,11 @@ static SENSOR_DEVICE_ATTR_2(fan3_alarm, S_IRUGO, show_alarm, NULL, 0x1a, 2);
>   static SENSOR_DEVICE_ATTR_2(fan3_beep, S_IRUGO | S_IWUSR, show_beep, store_beep,
>   			    0x5b, 2);
>
> +/* 7.2.89 Fan Control Output Type */
> +static SENSOR_DEVICE_ATTR_2(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0x5E, 0);
> +static SENSOR_DEVICE_ATTR_2(pwm2_mode, S_IRUGO, show_pwm_mode, NULL, 0x5E, 1);
> +static SENSOR_DEVICE_ATTR_2(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 0, 2);

You don't really need SENSOR_DEVICE_ATTR_2 here; SENSOR_DEVICE_ATTR
is good enough. The register address doesn't change, and isn't used
for index = 2 anyway, so you can just hard-code it in show_pwm_mode().

Thanks,
Guenter


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

      reply	other threads:[~2015-07-04 22:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-04 21:07 [lm-sensors] [PATCH] hwmon: (nct7802) Add pwm mode Constantine Shulyupin
2015-07-04 21:07 ` Constantine Shulyupin
2015-07-04 22:19 ` Guenter Roeck [this message]

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=55985C01.1040105@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=lm-sensors@vger.kernel.org \
    /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.