From: Guenter Roeck <linux@roeck-us.net>
To: Armin Wolf <W_Armin@gmx.de>
Cc: jdelvare@suse.com, linux-hwmon@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] hwmon: (ftsteutates) Replace fanX_source with pwmX_auto_channels_temp
Date: Sun, 15 Jan 2023 08:23:34 -0800 [thread overview]
Message-ID: <20230115162334.GA1247593@roeck-us.net> (raw)
In-Reply-To: <20230105225107.58308-3-W_Armin@gmx.de>
On Thu, Jan 05, 2023 at 11:51:06PM +0100, Armin Wolf wrote:
> Replace the nonstandard fanX_source attributes with the standardized
> pwmX_auto_channels_temp attributes and document the special behaviour
> associated with those attributes.
>
> Tested on a Fujitsu DS3401-B1.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Applied to hwmon-next.
Thanks,
Guenter
> ---
> Documentation/hwmon/ftsteutates.rst | 5 ++
> drivers/hwmon/ftsteutates.c | 77 +++++++++++------------------
> 2 files changed, 33 insertions(+), 49 deletions(-)
>
> --
> 2.30.2
>
> diff --git a/Documentation/hwmon/ftsteutates.rst b/Documentation/hwmon/ftsteutates.rst
> index 198fa8e2819d..b3bfec36661d 100644
> --- a/Documentation/hwmon/ftsteutates.rst
> +++ b/Documentation/hwmon/ftsteutates.rst
> @@ -22,6 +22,11 @@ enhancements. It can monitor up to 4 voltages, 16 temperatures and
> 8 fans. It also contains an integrated watchdog which is currently
> implemented in this driver.
>
> +The ``pwmX_auto_channels_temp`` attributes show which temperature sensor
> +is currently driving which fan channel. This value might dynamically change
> +during runtime depending on the temperature sensor selected by
> +the fan control circuit.
> +
> The 4 voltages require a board-specific multiplier, since the BMC can
> only measure voltages up to 3.3V and thus relies on voltage dividers.
> Consult your motherboard manual for details.
> diff --git a/drivers/hwmon/ftsteutates.c b/drivers/hwmon/ftsteutates.c
> index 23dc3a74f84b..0d8ab94250a9 100644
> --- a/drivers/hwmon/ftsteutates.c
> +++ b/drivers/hwmon/ftsteutates.c
> @@ -6,9 +6,7 @@
> * Thilo Cestonaro <thilo.cestonaro@ts.fujitsu.com>
> */
> #include <linux/err.h>
> -#include <linux/fs.h>
> #include <linux/hwmon.h>
> -#include <linux/hwmon-sysfs.h>
> #include <linux/i2c.h>
> #include <linux/init.h>
> #include <linux/jiffies.h>
> @@ -16,7 +14,6 @@
> #include <linux/module.h>
> #include <linux/mutex.h>
> #include <linux/slab.h>
> -#include <linux/sysfs.h>
> #include <linux/watchdog.h>
>
> #define FTS_DEVICE_ID_REG 0x0000
> @@ -48,6 +45,8 @@
> #define FTS_NO_TEMP_SENSORS 0x10
> #define FTS_NO_VOLT_SENSORS 0x04
>
> +#define FTS_FAN_SOURCE_INVALID 0xff
> +
> static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
>
> static const struct i2c_device_id fts_id[] = {
> @@ -187,7 +186,7 @@ static int fts_update_device(struct fts_data *data)
> data->fan_source[i] = err;
> } else {
> data->fan_input[i] = 0;
> - data->fan_source[i] = 0;
> + data->fan_source[i] = FTS_FAN_SOURCE_INVALID;
> }
> }
>
> @@ -339,50 +338,6 @@ static int fts_watchdog_init(struct fts_data *data)
> return devm_watchdog_register_device(&data->client->dev, &data->wdd);
> }
>
> -static ssize_t fan_source_show(struct device *dev,
> - struct device_attribute *devattr, char *buf)
> -{
> - struct fts_data *data = dev_get_drvdata(dev);
> - int index = to_sensor_dev_attr(devattr)->index;
> - int err;
> -
> - err = fts_update_device(data);
> - if (err < 0)
> - return err;
> -
> - return sprintf(buf, "%u\n", data->fan_source[index]);
> -}
> -
> -static SENSOR_DEVICE_ATTR_RO(fan1_source, fan_source, 0);
> -static SENSOR_DEVICE_ATTR_RO(fan2_source, fan_source, 1);
> -static SENSOR_DEVICE_ATTR_RO(fan3_source, fan_source, 2);
> -static SENSOR_DEVICE_ATTR_RO(fan4_source, fan_source, 3);
> -static SENSOR_DEVICE_ATTR_RO(fan5_source, fan_source, 4);
> -static SENSOR_DEVICE_ATTR_RO(fan6_source, fan_source, 5);
> -static SENSOR_DEVICE_ATTR_RO(fan7_source, fan_source, 6);
> -static SENSOR_DEVICE_ATTR_RO(fan8_source, fan_source, 7);
> -
> -static struct attribute *fts_fan_attrs[] = {
> - &sensor_dev_attr_fan1_source.dev_attr.attr,
> - &sensor_dev_attr_fan2_source.dev_attr.attr,
> - &sensor_dev_attr_fan3_source.dev_attr.attr,
> - &sensor_dev_attr_fan4_source.dev_attr.attr,
> - &sensor_dev_attr_fan5_source.dev_attr.attr,
> - &sensor_dev_attr_fan6_source.dev_attr.attr,
> - &sensor_dev_attr_fan7_source.dev_attr.attr,
> - &sensor_dev_attr_fan8_source.dev_attr.attr,
> - NULL
> -};
> -
> -static const struct attribute_group fts_attr_group = {
> - .attrs = fts_fan_attrs
> -};
> -
> -static const struct attribute_group *fts_attr_groups[] = {
> - &fts_attr_group,
> - NULL
> -};
> -
> static umode_t fts_is_visible(const void *devdata, enum hwmon_sensor_types type, u32 attr,
> int channel)
> {
> @@ -408,6 +363,7 @@ static umode_t fts_is_visible(const void *devdata, enum hwmon_sensor_types type,
> break;
> }
> break;
> + case hwmon_pwm:
> case hwmon_in:
> return 0444;
> default:
> @@ -460,6 +416,19 @@ static int fts_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
> break;
> }
> break;
> + case hwmon_pwm:
> + switch (attr) {
> + case hwmon_pwm_auto_channels_temp:
> + if (data->fan_source[channel] == FTS_FAN_SOURCE_INVALID)
> + *val = 0;
> + else
> + *val = BIT(data->fan_source[channel]);
> +
> + return 0;
> + default:
> + break;
> + }
> + break;
> case hwmon_in:
> switch (attr) {
> case hwmon_in_input:
> @@ -576,6 +545,16 @@ static const struct hwmon_channel_info *fts_info[] = {
> HWMON_F_INPUT | HWMON_F_ALARM,
> HWMON_F_INPUT | HWMON_F_ALARM
> ),
> + HWMON_CHANNEL_INFO(pwm,
> + HWMON_PWM_AUTO_CHANNELS_TEMP,
> + HWMON_PWM_AUTO_CHANNELS_TEMP,
> + HWMON_PWM_AUTO_CHANNELS_TEMP,
> + HWMON_PWM_AUTO_CHANNELS_TEMP,
> + HWMON_PWM_AUTO_CHANNELS_TEMP,
> + HWMON_PWM_AUTO_CHANNELS_TEMP,
> + HWMON_PWM_AUTO_CHANNELS_TEMP,
> + HWMON_PWM_AUTO_CHANNELS_TEMP
> + ),
> HWMON_CHANNEL_INFO(in,
> HWMON_I_INPUT,
> HWMON_I_INPUT,
> @@ -672,7 +651,7 @@ static int fts_probe(struct i2c_client *client)
> revision = err;
>
> hwmon_dev = devm_hwmon_device_register_with_info(&client->dev, "ftsteutates", data,
> - &fts_chip_info, fts_attr_groups);
> + &fts_chip_info, NULL);
> if (IS_ERR(hwmon_dev))
> return PTR_ERR(hwmon_dev);
next prev parent reply other threads:[~2023-01-15 16:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-05 22:51 [PATCH v2 0/3] (ftsteutates) Various fixes Armin Wolf
2023-01-05 22:51 ` [PATCH v2 1/3] hwmon: (ftsteutates) Convert to devm_hwmon_device_register_with_info() Armin Wolf
2023-01-15 16:22 ` Guenter Roeck
2023-01-05 22:51 ` [PATCH v2 2/3] hwmon: (ftsteutates) Replace fanX_source with pwmX_auto_channels_temp Armin Wolf
2023-01-15 16:23 ` Guenter Roeck [this message]
2023-01-05 22:51 ` [PATCH v2 3/3] hwmon: (ftsteutates) Add support for fanX_fault attributes Armin Wolf
2023-01-15 16:24 ` Guenter Roeck
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=20230115162334.GA1247593@roeck-us.net \
--to=linux@roeck-us.net \
--cc=W_Armin@gmx.de \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@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 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).