Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1641240 > unrolled thread
| Started by | Chris Packham <chris.packham@alliedtelesis.co.nz> |
|---|---|
| First post | 2017-05-15 03:40 +0200 |
| Last post | 2017-05-15 23:10 +0200 |
| Articles | 3 — 3 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.
[PATCH v4 3/3] hwmon: (adt7475) add high frequency support Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-05-15 03:40 +0200
Re: [PATCH v4 3/3] hwmon: (adt7475) add high frequency support Guenter Roeck <linux@roeck-us.net> - 2017-05-15 15:30 +0200
Re: [PATCH v4 3/3] hwmon: (adt7475) add high frequency support Chris Packham <Chris.Packham@alliedtelesis.co.nz> - 2017-05-15 23:10 +0200
| From | Chris Packham <chris.packham@alliedtelesis.co.nz> |
|---|---|
| Date | 2017-05-15 03:40 +0200 |
| Subject | [PATCH v4 3/3] hwmon: (adt7475) add high frequency support |
| Message-ID | <tHd9n-1bf-5@gated-at.bofh.it> |
Systems using 4-wire fans usually require high frequency (22.5kHz)
output on the pwm. Add 22500 as a valid option in the pwmfreq_table. In
high frequency mode the low-order bit are ignored so they can safely be
set to 0.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
Changes in v3:
- New
Changes in v4:
- Fix pwmfreq_table array indexing
drivers/hwmon/adt7475.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
index 3056076fae27..1baa213a60bd 100644
--- a/drivers/hwmon/adt7475.c
+++ b/drivers/hwmon/adt7475.c
@@ -934,7 +934,7 @@ static ssize_t set_pwmctrl(struct device *dev, struct device_attribute *attr,
/* List of frequencies for the PWM */
static const int pwmfreq_table[] = {
- 11, 14, 22, 29, 35, 44, 58, 88
+ 11, 14, 22, 29, 35, 44, 58, 88, 22500
};
static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr,
@@ -942,9 +942,10 @@ static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr,
{
struct adt7475_data *data = adt7475_update_device(dev);
struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
+ int i = clamp_val(data->range[sattr->index] & 0xf, 0,
+ ARRAY_SIZE(pwmfreq_table) - 1);
- return sprintf(buf, "%d\n",
- pwmfreq_table[data->range[sattr->index] & 7]);
+ return sprintf(buf, "%d\n", pwmfreq_table[i]);
}
static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr,
@@ -965,7 +966,7 @@ static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr,
data->range[sattr->index] =
adt7475_read(TEMP_TRANGE_REG(sattr->index));
- data->range[sattr->index] &= ~7;
+ data->range[sattr->index] &= ~0xf;
data->range[sattr->index] |= out;
i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index),
--
2.11.0.24.ge6920cf
[toc] | [next] | [standalone]
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2017-05-15 15:30 +0200 |
| Message-ID | <tHoet-iQ-9@gated-at.bofh.it> |
| In reply to | #1641240 |
On 05/14/2017 06:30 PM, Chris Packham wrote:
> Systems using 4-wire fans usually require high frequency (22.5kHz)
> output on the pwm. Add 22500 as a valid option in the pwmfreq_table. In
> high frequency mode the low-order bit are ignored so they can safely be
> set to 0.
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Applied to hwmon-next.
Thanks,
Guenter
> ---
> Changes in v3:
> - New
> Changes in v4:
> - Fix pwmfreq_table array indexing
>
> drivers/hwmon/adt7475.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
> index 3056076fae27..1baa213a60bd 100644
> --- a/drivers/hwmon/adt7475.c
> +++ b/drivers/hwmon/adt7475.c
> @@ -934,7 +934,7 @@ static ssize_t set_pwmctrl(struct device *dev, struct device_attribute *attr,
>
> /* List of frequencies for the PWM */
> static const int pwmfreq_table[] = {
> - 11, 14, 22, 29, 35, 44, 58, 88
> + 11, 14, 22, 29, 35, 44, 58, 88, 22500
> };
>
> static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr,
> @@ -942,9 +942,10 @@ static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr,
> {
> struct adt7475_data *data = adt7475_update_device(dev);
> struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
> + int i = clamp_val(data->range[sattr->index] & 0xf, 0,
> + ARRAY_SIZE(pwmfreq_table) - 1);
>
> - return sprintf(buf, "%d\n",
> - pwmfreq_table[data->range[sattr->index] & 7]);
> + return sprintf(buf, "%d\n", pwmfreq_table[i]);
> }
>
> static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr,
> @@ -965,7 +966,7 @@ static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr,
>
> data->range[sattr->index] =
> adt7475_read(TEMP_TRANGE_REG(sattr->index));
> - data->range[sattr->index] &= ~7;
> + data->range[sattr->index] &= ~0xf;
> data->range[sattr->index] |= out;
>
> i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index),
>
[toc] | [prev] | [next] | [standalone]
| From | Chris Packham <Chris.Packham@alliedtelesis.co.nz> |
|---|---|
| Date | 2017-05-15 23:10 +0200 |
| Message-ID | <tHvpD-4RT-1@gated-at.bofh.it> |
| In reply to | #1641665 |
On 16/05/17 01:26, Guenter Roeck wrote: > On 05/14/2017 06:30 PM, Chris Packham wrote: >> Systems using 4-wire fans usually require high frequency (22.5kHz) >> output on the pwm. Add 22500 as a valid option in the pwmfreq_table. In >> high frequency mode the low-order bit are ignored so they can safely be >> set to 0. >> >> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> > > Applied to hwmon-next. > > Thanks, > Guenter > Thank you for your feedback (and patience).
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web