From patchwork Sat Dec 24 04:18:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13081274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7867C4167B for ; Sat, 24 Dec 2022 04:19:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232830AbiLXETZ (ORCPT ); Fri, 23 Dec 2022 23:19:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230242AbiLXETT (ORCPT ); Fri, 23 Dec 2022 23:19:19 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AF941CB14; Fri, 23 Dec 2022 20:19:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1671855540; bh=5PoiGuKTjTB2f9D4z+MnZKdOvcx2VJpMI8xwt9UGaxg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=WnFVltG1bY+7NVl6gfuDWom0b0Dx0Mgy2UI4yUSie5PlVXvx+jB0G3pNanK3QlyTs DOYrBpfsM4b13rWxYC4mCQcp2LzxA7Lbxh90GGVIUj5MOtuQuVzON7evI7lA7izLbM eV6wOr+kOglPbgIJz2M2fTUNYJZw4KGeTqPCIaDJpUOX2He9oBaU2vzaFXOPLxW0+L SBcJAENjN6uNEnWvZSMaBtFHGPfL0vV0132jCZZ5SKePeaRLsZf0hmGRPYosJN8+Ou KX69b+CeOGgH4qq+2ggfccxhmKV1CnohV0xk58LJ6viuve3XSeBWWNs9H9f3J6NTHU QGOJCGQjEJdfw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MirjS-1od9Tk2KYO-00euL0; Sat, 24 Dec 2022 05:19:00 +0100 From: Armin Wolf To: jdelvare@suse.com, linux@roeck-us.net Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] hwmon: (ftsteutates) Fix scaling of measurements Date: Sat, 24 Dec 2022 05:18:53 +0100 Message-Id: <20221224041855.83981-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221224041855.83981-1-W_Armin@gmx.de> References: <20221224041855.83981-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:zwsmSLNj/mM9MGI2msAmznXpdXUl/1DAJ8f8clp9J97TVKEyIhw AoGW6GY3BGa5Wll0tpAH7rabhsDh4rDa/JHVkU/DCYoGmo72w9JLjiVMFkV7H7XKhl/QH/g ju45yhE8jQw5dlCefEvkMpOrR8PSpwuRgBrmvLEyh4C62QnlmZkutxT9VCNN9qQHpCMkT/Z bTHizQjYALjtuZgpdCqaQ== UI-OutboundReport: notjunk:1;M01:P0:AOpju1sjKI8=;5PPtJWo1UXanX9WNFPqb27wSHH0 pUDlqwuEnp9RuN9cudXP5f8l+ybmehDFT/1wG1soDFFQHwHNStqH57zCPTHlY8YI8v0la347F 0by9KCCfAco79UG4A9oSh81pINHeFZJZ2sPPo42Z0SsBvgrGc/XOp0HKnMhVSmfxXouZmH/f5 sFPXQS6BrrBj61necy2ERgAvO0FlC3cTHqCmFyPKGnD9N0ghzOh7IfEDT3yO6I2aPW/Tgq+EW tLwtX+VQjuoFFM3ZT1dVEo3Xcx6fl01sK1OdTxLGPRk58FBLmHzTH6rqUPD3jaQra2UPB74TB hhg8bU1hX6VjlAi15ZvYHhfySoVniLTlyZ8rmPvIawu6UmAX0vbnCSHunbb5x/QWuwFWwOI3r T1rR2NcMcCAG1Ez/wDqU7/Mj5pABBTXLnVZZegVopHB8g9kWod3axREl/BRejDhrnYilId+Bi 47AOgvVMPaLHQmww+mlzPf67uw6QnF3Xy3v7Qb2FkIH5f8bbq3OvaVnKbKGZ1OuQmLNL/3BUJ sHiND6AxZwc2Lkehg2uR2ZPQVD6E1eKww//lLccn1fg3Zx3vzJl2zSWUQCzIonBF+OKMHxu5L oOBbmMylbtTpOefigQ1PebBmgeP6mGRHQ2L4tTruL4JfEvBtVuF4sawnDxtmCystHOIKFZEoH 5d0UeK5ZUGWFB9w9aZ7xfuu5vU5GVytaTkYAMx0CVYUqUVd3l+6JNF0ciydjtrSnwY7jZL72t n/eZuk925vseTbXqDuYn78ENAi5EYHgZDZf8Xj2N8E19He00q0Nn+OzJM5zBSej4wyv6UtjhT BLqADd2ah17GZw1l/T7NLmmLA1FU7S3KjMCypKh3yBymJm6pG+qhptv4iX+42pLQdgUkSWeSg EQ3AVbQkU7/rF9f7GE8TRUcWiy38Ek2iKD8oEugXMrcVm7OGij/vu7aKslPOgswO1QZrtHTUr 1qjjlcnpXeeOAUIRH9yulzUQAN8= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org A user complained that the ftsteutates driver was displaying bogus values since its introduction. This happens because the sensor measurements need to be scaled in order to produce meaningful results: - the fan speed needs to be multiplied by 60 since its in RPS - the temperature is in degrees celsius and needs an offset of 64 - the voltage is in 1/256 of 3.3V The offical datasheet says the voltage needs to be divided by 256, but this is likely an off-by-one-error, since even the BIOS devides by 255 (otherwise 3.3V could not be measured). The voltage channels additionally need a board-specific multiplier, however this can be done by the driver since its board-specific. The reason the missing scaling of measurements is the way Fujitsu used this driver when it was still out-of-tree. Back then, all scaling was done in userspace by libsensors, even the generic one. Tested on a Fujitsu DS3401-B1. Fixes: 08426eda58e0 ("hwmon: Add driver for FTS BMC chip "Teutates"") Signed-off-by: Armin Wolf --- Documentation/hwmon/ftsteutates.rst | 4 ++++ drivers/hwmon/ftsteutates.c | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) -- 2.30.2 diff --git a/Documentation/hwmon/ftsteutates.rst b/Documentation/hwmon/ftsteutates.rst index 58a2483d8d0d..198fa8e2819d 100644 --- a/Documentation/hwmon/ftsteutates.rst +++ b/Documentation/hwmon/ftsteutates.rst @@ -22,6 +22,10 @@ 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 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. + To clear a temperature or fan alarm, execute the following command with the correct path to the alarm file:: diff --git a/drivers/hwmon/ftsteutates.c b/drivers/hwmon/ftsteutates.c index f5b8e724a8ca..ffa0bb364877 100644 --- a/drivers/hwmon/ftsteutates.c +++ b/drivers/hwmon/ftsteutates.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -347,13 +348,15 @@ static ssize_t in_value_show(struct device *dev, { struct fts_data *data = dev_get_drvdata(dev); int index = to_sensor_dev_attr(devattr)->index; - int err; + int value, err; err = fts_update_device(data); if (err < 0) return err; - return sprintf(buf, "%u\n", data->volt[index]); + value = DIV_ROUND_CLOSEST(data->volt[index] * 3300, 255); + + return sprintf(buf, "%d\n", value); } static ssize_t temp_value_show(struct device *dev, @@ -361,13 +364,15 @@ static ssize_t temp_value_show(struct device *dev, { struct fts_data *data = dev_get_drvdata(dev); int index = to_sensor_dev_attr(devattr)->index; - int err; + int value, err; err = fts_update_device(data); if (err < 0) return err; - return sprintf(buf, "%u\n", data->temp_input[index]); + value = (data->temp_input[index] - 64) * 1000; + + return sprintf(buf, "%d\n", value); } static ssize_t temp_fault_show(struct device *dev, @@ -436,13 +441,15 @@ static ssize_t fan_value_show(struct device *dev, { struct fts_data *data = dev_get_drvdata(dev); int index = to_sensor_dev_attr(devattr)->index; - int err; + int value, err; err = fts_update_device(data); if (err < 0) return err; - return sprintf(buf, "%u\n", data->fan_input[index]); + value = data->fan_input[index] * 60; + + return sprintf(buf, "%d\n", value); } static ssize_t fan_source_show(struct device *dev, From patchwork Sat Dec 24 04:18:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13081276 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 410F3C3DA7A for ; Sat, 24 Dec 2022 04:19:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232940AbiLXET0 (ORCPT ); Fri, 23 Dec 2022 23:19:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231203AbiLXETW (ORCPT ); Fri, 23 Dec 2022 23:19:22 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD8A1CB2B; Fri, 23 Dec 2022 20:19:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1671855542; bh=/tRXz9aYe4Pmn1vdD0AQ+oz0FQUg69o7dSHZfY9/rik=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Hv8plgAk0JwpLfsXSOW2NtFXA8z/rYCtd8XN62Eun/tDEltuGP74En0oRNDA1D9Kg 1kMjb4pruo74R1FMNmkLDHjTO5m9UGoZES9CkczB8QPYTrc9dO2zcxHm98vp/LPwjr UVpojsnfL+xAdYPU1JRJ3T/RBt2ywq1d5EU52UfDoUeIj4HTrwxnNDzJvIclcMsyGj Trj/G5trhcejc2xo4ZwI+d+w44XLng2r8/NZUJfulj//7UV3grrMbcE3O6AenakPxh XF1aPZRQa1atylH1yHFUU4JBmtrJmiM6viYwTlapnDAM51VibEBaLbebIyFgBMWi8v p3Rh63QCGyjdw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MryXN-1oUal11PHx-00o0BO; Sat, 24 Dec 2022 05:19:02 +0100 From: Armin Wolf To: jdelvare@suse.com, linux@roeck-us.net Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] hwmon: (ftsteutates) Convert to devm_hwmon_device_register_with_info() Date: Sat, 24 Dec 2022 05:18:54 +0100 Message-Id: <20221224041855.83981-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221224041855.83981-1-W_Armin@gmx.de> References: <20221224041855.83981-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:aO1HGWIBKGYX5ppdudRLihuwS5LJeS2CB60HwmTHFJews99cphG 2HY1X9pLjYgrH/xEfIY9M2bvgpG4FG486fb5aAJKbQXjZp16nsYQy1Dk3rLS5iJl8mc93jr DyFM+9eNxT8o4A00P6sMI0mJ8+6BowNPhC/ttnzq6W0HsYfy7ibI+fJi0lJRoBJ8HVPLQRa En7Of6bx3Y1VrJFhhcBeQ== UI-OutboundReport: notjunk:1;M01:P0:N1vhtfM+GeA=;pDqDe9Nrh45t0cRZkrFwcBHm+yZ 3NM/r+rFREehr85YTNNZWnfGe0ppDriXBStK49ZPqJjtRfEOu+veTj4vrRaK6h7BH01pe5ObE JwPFh9BCJYmq1jmBfuhK3kAPvplsHC6Nd2ZOS2apAfqbdBlhNsf00YK6uatIU8LmjeX0WRU1x SnvAeSc0p6jh2+WwbmruYSsEQCVD6mLeud7IWdF6uZxNg+1X7j7gGxQvp2onDCzdotLb71d/C pegLOMZzGB4GFtvIjpIVJcVNHRpT0sPte0VWG/FUhFb3pzQIm7MUNrz8fx48WBYY1cO/i5m5Y 0yuiUIg5a0sMkNP1h9E4oSxhV/WAI7QZaxHF2mPDe7DBme3mW6ymE4oF8X5b/3Z9R9VBX/yae nESuiZipN5JI+ijyUk6AYzzppwTKvVqTwmqJT+UwNRTtjPEL6Wf/3R4sDBKJJa0sZHZs51NQp GXhiL3Fkray5Q4UY+QSsHrO/+X1ufANcOm5o6oXLWVzDQGrg5mjP8gXMRoKpV3ZasAaV6WSY+ nq1keei0LpmnkmeN++kvDEKHTGYfagY1uC/aCz1YZ6x6MKBW76IMTbve8r2IPHue1Vbi96Apw MqO4hwqJ3uck0tUhFaDVPv3GOWflaniLOkSYay7vnZuYpHvw8bIO18o3sfbl2Amj+t+TXrpQ4 X+QEMheUAjWIyH0tcRY48mrG2PYYq2HRzJDPOMcto69r0ZlsG4Iua+wiIC3s9JN0M9j7zuLsK pP8WrpL/WuB2SW1DN9tqNCHeqHiddE5Twpl6CO/XzyE1ZD9ntVPbPsU+EaWV5cD0ZIm6MA2LJ zMXpgHrLADpq02zmhQwwnpHibtwA9B5mNXOlFgH07UM/XB3NcEmH9hkohsrJYgEDdMJNW2Z8d nzHhiMBXeIlKsGxaqN0LT8P5XrHEe6kf4QP75WQcamrj3oT52SD3jkBnALFEWewmJ4h0t943t +AHfRXeTjvJ2FIbXOA8bSXR8mO0= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Convert driver to use devm_hwmon_device_register_with_info() to reduce module size by 40%. The non-standard fan_source attribute is replaced with the standard pwmX_auto_channels_temp attribute and its special behaviour being documented. Also export fan present status as fanX_fault. Tested on a Fujitsu DS3401-B1. Signed-off-by: Armin Wolf --- Documentation/hwmon/ftsteutates.rst | 5 + drivers/hwmon/ftsteutates.c | 546 ++++++++++------------------ 2 files changed, 207 insertions(+), 344 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 ffa0bb364877..66ff8d69a0de 100644 --- a/drivers/hwmon/ftsteutates.c +++ b/drivers/hwmon/ftsteutates.c @@ -6,9 +6,7 @@ * Thilo Cestonaro */ #include -#include #include -#include #include #include #include @@ -16,8 +14,6 @@ #include #include #include -#include -#include #include #define FTS_DEVICE_ID_REG 0x0000 @@ -340,376 +336,240 @@ static int fts_watchdog_init(struct fts_data *data) return watchdog_register_device(&data->wdd); } -/*****************************************************************************/ -/* SysFS handler functions */ -/*****************************************************************************/ -static ssize_t in_value_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 value, err; - - err = fts_update_device(data); - if (err < 0) - return err; - - value = DIV_ROUND_CLOSEST(data->volt[index] * 3300, 255); - - return sprintf(buf, "%d\n", value); -} - -static ssize_t temp_value_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 value, err; - - err = fts_update_device(data); - if (err < 0) - return err; - - value = (data->temp_input[index] - 64) * 1000; - - return sprintf(buf, "%d\n", value); -} - -static ssize_t temp_fault_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; - - /* 00h Temperature = Sensor Error */ - return sprintf(buf, "%d\n", data->temp_input[index] == 0); -} - -static ssize_t temp_alarm_show(struct device *dev, - struct device_attribute *devattr, char *buf) +static umode_t fts_is_visible(const void *devdata, enum hwmon_sensor_types type, u32 attr, + int channel) { - 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; + switch (type) { + case hwmon_temp: + switch (attr) { + case hwmon_temp_input: + case hwmon_temp_fault: + return 0444; + case hwmon_temp_alarm: + return 0644; + default: + break; + } + break; + case hwmon_fan: + switch (attr) { + case hwmon_fan_input: + case hwmon_fan_fault: + return 0444; + case hwmon_fan_alarm: + return 0644; + default: + break; + } + break; + case hwmon_pwm: + case hwmon_in: + return 0444; + default: + break; + } - return sprintf(buf, "%u\n", !!(data->temp_alarm & BIT(index))); + return 0; } -static ssize_t -temp_alarm_store(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) +static int fts_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, + long *val) { struct fts_data *data = dev_get_drvdata(dev); - int index = to_sensor_dev_attr(devattr)->index; - long ret; + int ret = fts_update_device(data); - ret = fts_update_device(data); if (ret < 0) return ret; - if (kstrtoul(buf, 10, &ret) || ret != 0) - return -EINVAL; - - mutex_lock(&data->update_lock); - ret = fts_read_byte(data->client, FTS_REG_TEMP_CONTROL(index)); - if (ret < 0) - goto error; - - ret = fts_write_byte(data->client, FTS_REG_TEMP_CONTROL(index), - ret | 0x1); - if (ret < 0) - goto error; - - data->valid = false; - ret = count; -error: - mutex_unlock(&data->update_lock); - return ret; -} - -static ssize_t fan_value_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 value, err; - - err = fts_update_device(data); - if (err < 0) - return err; + switch (type) { + case hwmon_temp: + switch (attr) { + case hwmon_temp_input: + *val = (data->temp_input[channel] - 64) * 1000; - value = data->fan_input[index] * 60; + return 0; + case hwmon_temp_alarm: + *val = !!(data->temp_alarm & BIT(channel)); - return sprintf(buf, "%d\n", value); -} + return 0; + case hwmon_temp_fault: + /* 00h Temperature = Sensor Error */; + *val = (data->temp_input[channel] == 0); -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; + return 0; + default: + break; + } + break; + case hwmon_fan: + switch (attr) { + case hwmon_fan_input: + *val = data->fan_input[channel] * 60; - err = fts_update_device(data); - if (err < 0) - return err; + return 0; + case hwmon_fan_alarm: + *val = !!(data->fan_alarm & BIT(channel)); - return sprintf(buf, "%u\n", data->fan_source[index]); -} + return 0; + case hwmon_fan_fault: + *val = !(data->fan_present & BIT(channel)); -static ssize_t fan_alarm_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; + return 0; + default: + break; + } + break; + case hwmon_pwm: + switch (attr) { + case hwmon_pwm_auto_channels_temp: + if (data->fan_source[channel] == 0xff) + *val = 0; + else + *val = BIT(data->fan_source[channel]); + + return 0; + default: + break; + } + break; + case hwmon_in: + switch (attr) { + case hwmon_in_input: + *val = DIV_ROUND_CLOSEST(data->volt[channel] * 3300, 255); - err = fts_update_device(data); - if (err < 0) - return err; + return 0; + default: + break; + } + break; + default: + break; + } - return sprintf(buf, "%d\n", !!(data->fan_alarm & BIT(index))); + return -EOPNOTSUPP; } -static ssize_t -fan_alarm_store(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) +static int fts_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, + long val) { struct fts_data *data = dev_get_drvdata(dev); - int index = to_sensor_dev_attr(devattr)->index; - long ret; + int ret = fts_update_device(data); - ret = fts_update_device(data); if (ret < 0) return ret; - if (kstrtoul(buf, 10, &ret) || ret != 0) - return -EINVAL; - - mutex_lock(&data->update_lock); - ret = fts_read_byte(data->client, FTS_REG_FAN_CONTROL(index)); - if (ret < 0) - goto error; - - ret = fts_write_byte(data->client, FTS_REG_FAN_CONTROL(index), - ret | 0x1); - if (ret < 0) - goto error; + switch (type) { + case hwmon_temp: + switch (attr) { + case hwmon_temp_alarm: + if (val) + return -EINVAL; + + mutex_lock(&data->update_lock); + ret = fts_read_byte(data->client, FTS_REG_TEMP_CONTROL(channel)); + if (ret >= 0) + ret = fts_write_byte(data->client, FTS_REG_TEMP_CONTROL(channel), + ret | 0x1); + if (ret >= 0) + data->valid = false; + + mutex_unlock(&data->update_lock); + if (ret < 0) + return ret; + + return 0; + default: + break; + } + break; + case hwmon_fan: + switch (attr) { + case hwmon_fan_alarm: + if (val) + return -EINVAL; + + mutex_lock(&data->update_lock); + ret = fts_read_byte(data->client, FTS_REG_FAN_CONTROL(channel)); + if (ret >= 0) + ret = fts_write_byte(data->client, FTS_REG_FAN_CONTROL(channel), + ret | 0x1); + if (ret >= 0) + data->valid = false; + + mutex_unlock(&data->update_lock); + if (ret < 0) + return ret; + + return 0; + default: + break; + } + break; + default: + break; + } - data->valid = false; - ret = count; -error: - mutex_unlock(&data->update_lock); - return ret; + return -EOPNOTSUPP; } -/*****************************************************************************/ -/* SysFS structs */ -/*****************************************************************************/ - -/* Temperature sensors */ -static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_value, 0); -static SENSOR_DEVICE_ATTR_RO(temp2_input, temp_value, 1); -static SENSOR_DEVICE_ATTR_RO(temp3_input, temp_value, 2); -static SENSOR_DEVICE_ATTR_RO(temp4_input, temp_value, 3); -static SENSOR_DEVICE_ATTR_RO(temp5_input, temp_value, 4); -static SENSOR_DEVICE_ATTR_RO(temp6_input, temp_value, 5); -static SENSOR_DEVICE_ATTR_RO(temp7_input, temp_value, 6); -static SENSOR_DEVICE_ATTR_RO(temp8_input, temp_value, 7); -static SENSOR_DEVICE_ATTR_RO(temp9_input, temp_value, 8); -static SENSOR_DEVICE_ATTR_RO(temp10_input, temp_value, 9); -static SENSOR_DEVICE_ATTR_RO(temp11_input, temp_value, 10); -static SENSOR_DEVICE_ATTR_RO(temp12_input, temp_value, 11); -static SENSOR_DEVICE_ATTR_RO(temp13_input, temp_value, 12); -static SENSOR_DEVICE_ATTR_RO(temp14_input, temp_value, 13); -static SENSOR_DEVICE_ATTR_RO(temp15_input, temp_value, 14); -static SENSOR_DEVICE_ATTR_RO(temp16_input, temp_value, 15); - -static SENSOR_DEVICE_ATTR_RO(temp1_fault, temp_fault, 0); -static SENSOR_DEVICE_ATTR_RO(temp2_fault, temp_fault, 1); -static SENSOR_DEVICE_ATTR_RO(temp3_fault, temp_fault, 2); -static SENSOR_DEVICE_ATTR_RO(temp4_fault, temp_fault, 3); -static SENSOR_DEVICE_ATTR_RO(temp5_fault, temp_fault, 4); -static SENSOR_DEVICE_ATTR_RO(temp6_fault, temp_fault, 5); -static SENSOR_DEVICE_ATTR_RO(temp7_fault, temp_fault, 6); -static SENSOR_DEVICE_ATTR_RO(temp8_fault, temp_fault, 7); -static SENSOR_DEVICE_ATTR_RO(temp9_fault, temp_fault, 8); -static SENSOR_DEVICE_ATTR_RO(temp10_fault, temp_fault, 9); -static SENSOR_DEVICE_ATTR_RO(temp11_fault, temp_fault, 10); -static SENSOR_DEVICE_ATTR_RO(temp12_fault, temp_fault, 11); -static SENSOR_DEVICE_ATTR_RO(temp13_fault, temp_fault, 12); -static SENSOR_DEVICE_ATTR_RO(temp14_fault, temp_fault, 13); -static SENSOR_DEVICE_ATTR_RO(temp15_fault, temp_fault, 14); -static SENSOR_DEVICE_ATTR_RO(temp16_fault, temp_fault, 15); - -static SENSOR_DEVICE_ATTR_RW(temp1_alarm, temp_alarm, 0); -static SENSOR_DEVICE_ATTR_RW(temp2_alarm, temp_alarm, 1); -static SENSOR_DEVICE_ATTR_RW(temp3_alarm, temp_alarm, 2); -static SENSOR_DEVICE_ATTR_RW(temp4_alarm, temp_alarm, 3); -static SENSOR_DEVICE_ATTR_RW(temp5_alarm, temp_alarm, 4); -static SENSOR_DEVICE_ATTR_RW(temp6_alarm, temp_alarm, 5); -static SENSOR_DEVICE_ATTR_RW(temp7_alarm, temp_alarm, 6); -static SENSOR_DEVICE_ATTR_RW(temp8_alarm, temp_alarm, 7); -static SENSOR_DEVICE_ATTR_RW(temp9_alarm, temp_alarm, 8); -static SENSOR_DEVICE_ATTR_RW(temp10_alarm, temp_alarm, 9); -static SENSOR_DEVICE_ATTR_RW(temp11_alarm, temp_alarm, 10); -static SENSOR_DEVICE_ATTR_RW(temp12_alarm, temp_alarm, 11); -static SENSOR_DEVICE_ATTR_RW(temp13_alarm, temp_alarm, 12); -static SENSOR_DEVICE_ATTR_RW(temp14_alarm, temp_alarm, 13); -static SENSOR_DEVICE_ATTR_RW(temp15_alarm, temp_alarm, 14); -static SENSOR_DEVICE_ATTR_RW(temp16_alarm, temp_alarm, 15); - -static struct attribute *fts_temp_attrs[] = { - &sensor_dev_attr_temp1_input.dev_attr.attr, - &sensor_dev_attr_temp2_input.dev_attr.attr, - &sensor_dev_attr_temp3_input.dev_attr.attr, - &sensor_dev_attr_temp4_input.dev_attr.attr, - &sensor_dev_attr_temp5_input.dev_attr.attr, - &sensor_dev_attr_temp6_input.dev_attr.attr, - &sensor_dev_attr_temp7_input.dev_attr.attr, - &sensor_dev_attr_temp8_input.dev_attr.attr, - &sensor_dev_attr_temp9_input.dev_attr.attr, - &sensor_dev_attr_temp10_input.dev_attr.attr, - &sensor_dev_attr_temp11_input.dev_attr.attr, - &sensor_dev_attr_temp12_input.dev_attr.attr, - &sensor_dev_attr_temp13_input.dev_attr.attr, - &sensor_dev_attr_temp14_input.dev_attr.attr, - &sensor_dev_attr_temp15_input.dev_attr.attr, - &sensor_dev_attr_temp16_input.dev_attr.attr, - - &sensor_dev_attr_temp1_fault.dev_attr.attr, - &sensor_dev_attr_temp2_fault.dev_attr.attr, - &sensor_dev_attr_temp3_fault.dev_attr.attr, - &sensor_dev_attr_temp4_fault.dev_attr.attr, - &sensor_dev_attr_temp5_fault.dev_attr.attr, - &sensor_dev_attr_temp6_fault.dev_attr.attr, - &sensor_dev_attr_temp7_fault.dev_attr.attr, - &sensor_dev_attr_temp8_fault.dev_attr.attr, - &sensor_dev_attr_temp9_fault.dev_attr.attr, - &sensor_dev_attr_temp10_fault.dev_attr.attr, - &sensor_dev_attr_temp11_fault.dev_attr.attr, - &sensor_dev_attr_temp12_fault.dev_attr.attr, - &sensor_dev_attr_temp13_fault.dev_attr.attr, - &sensor_dev_attr_temp14_fault.dev_attr.attr, - &sensor_dev_attr_temp15_fault.dev_attr.attr, - &sensor_dev_attr_temp16_fault.dev_attr.attr, - - &sensor_dev_attr_temp1_alarm.dev_attr.attr, - &sensor_dev_attr_temp2_alarm.dev_attr.attr, - &sensor_dev_attr_temp3_alarm.dev_attr.attr, - &sensor_dev_attr_temp4_alarm.dev_attr.attr, - &sensor_dev_attr_temp5_alarm.dev_attr.attr, - &sensor_dev_attr_temp6_alarm.dev_attr.attr, - &sensor_dev_attr_temp7_alarm.dev_attr.attr, - &sensor_dev_attr_temp8_alarm.dev_attr.attr, - &sensor_dev_attr_temp9_alarm.dev_attr.attr, - &sensor_dev_attr_temp10_alarm.dev_attr.attr, - &sensor_dev_attr_temp11_alarm.dev_attr.attr, - &sensor_dev_attr_temp12_alarm.dev_attr.attr, - &sensor_dev_attr_temp13_alarm.dev_attr.attr, - &sensor_dev_attr_temp14_alarm.dev_attr.attr, - &sensor_dev_attr_temp15_alarm.dev_attr.attr, - &sensor_dev_attr_temp16_alarm.dev_attr.attr, - NULL -}; - -/* Fans */ -static SENSOR_DEVICE_ATTR_RO(fan1_input, fan_value, 0); -static SENSOR_DEVICE_ATTR_RO(fan2_input, fan_value, 1); -static SENSOR_DEVICE_ATTR_RO(fan3_input, fan_value, 2); -static SENSOR_DEVICE_ATTR_RO(fan4_input, fan_value, 3); -static SENSOR_DEVICE_ATTR_RO(fan5_input, fan_value, 4); -static SENSOR_DEVICE_ATTR_RO(fan6_input, fan_value, 5); -static SENSOR_DEVICE_ATTR_RO(fan7_input, fan_value, 6); -static SENSOR_DEVICE_ATTR_RO(fan8_input, fan_value, 7); - -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 SENSOR_DEVICE_ATTR_RW(fan1_alarm, fan_alarm, 0); -static SENSOR_DEVICE_ATTR_RW(fan2_alarm, fan_alarm, 1); -static SENSOR_DEVICE_ATTR_RW(fan3_alarm, fan_alarm, 2); -static SENSOR_DEVICE_ATTR_RW(fan4_alarm, fan_alarm, 3); -static SENSOR_DEVICE_ATTR_RW(fan5_alarm, fan_alarm, 4); -static SENSOR_DEVICE_ATTR_RW(fan6_alarm, fan_alarm, 5); -static SENSOR_DEVICE_ATTR_RW(fan7_alarm, fan_alarm, 6); -static SENSOR_DEVICE_ATTR_RW(fan8_alarm, fan_alarm, 7); - -static struct attribute *fts_fan_attrs[] = { - &sensor_dev_attr_fan1_input.dev_attr.attr, - &sensor_dev_attr_fan2_input.dev_attr.attr, - &sensor_dev_attr_fan3_input.dev_attr.attr, - &sensor_dev_attr_fan4_input.dev_attr.attr, - &sensor_dev_attr_fan5_input.dev_attr.attr, - &sensor_dev_attr_fan6_input.dev_attr.attr, - &sensor_dev_attr_fan7_input.dev_attr.attr, - &sensor_dev_attr_fan8_input.dev_attr.attr, - - &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, - - &sensor_dev_attr_fan1_alarm.dev_attr.attr, - &sensor_dev_attr_fan2_alarm.dev_attr.attr, - &sensor_dev_attr_fan3_alarm.dev_attr.attr, - &sensor_dev_attr_fan4_alarm.dev_attr.attr, - &sensor_dev_attr_fan5_alarm.dev_attr.attr, - &sensor_dev_attr_fan6_alarm.dev_attr.attr, - &sensor_dev_attr_fan7_alarm.dev_attr.attr, - &sensor_dev_attr_fan8_alarm.dev_attr.attr, - NULL +static const struct hwmon_ops fts_ops = { + .is_visible = fts_is_visible, + .read = fts_read, + .write = fts_write, }; -/* Voltages */ -static SENSOR_DEVICE_ATTR_RO(in1_input, in_value, 0); -static SENSOR_DEVICE_ATTR_RO(in2_input, in_value, 1); -static SENSOR_DEVICE_ATTR_RO(in3_input, in_value, 2); -static SENSOR_DEVICE_ATTR_RO(in4_input, in_value, 3); -static struct attribute *fts_voltage_attrs[] = { - &sensor_dev_attr_in1_input.dev_attr.attr, - &sensor_dev_attr_in2_input.dev_attr.attr, - &sensor_dev_attr_in3_input.dev_attr.attr, - &sensor_dev_attr_in4_input.dev_attr.attr, +static const struct hwmon_channel_info *fts_info[] = { + HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), + HWMON_CHANNEL_INFO(temp, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT, + HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT + ), + HWMON_CHANNEL_INFO(fan, + HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT, + HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT, + HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT, + HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT, + HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT, + HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT, + HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT, + HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT + ), + 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, + HWMON_I_INPUT, + HWMON_I_INPUT + ), NULL }; -static const struct attribute_group fts_voltage_attr_group = { - .attrs = fts_voltage_attrs -}; - -static const struct attribute_group fts_temp_attr_group = { - .attrs = fts_temp_attrs -}; - -static const struct attribute_group fts_fan_attr_group = { - .attrs = fts_fan_attrs -}; - -static const struct attribute_group *fts_attr_groups[] = { - &fts_voltage_attr_group, - &fts_temp_attr_group, - &fts_fan_attr_group, - NULL +static const struct hwmon_chip_info fts_chip_info = { + .ops = &fts_ops, + .info = fts_info, }; /*****************************************************************************/ @@ -800,10 +660,8 @@ static int fts_probe(struct i2c_client *client) return err; revision = err; - hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev, - "ftsteutates", - data, - fts_attr_groups); + hwmon_dev = devm_hwmon_device_register_with_info(&client->dev, "ftsteutates", data, + &fts_chip_info, NULL); if (IS_ERR(hwmon_dev)) return PTR_ERR(hwmon_dev); From patchwork Sat Dec 24 04:18:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13081275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BA57C4332F for ; Sat, 24 Dec 2022 04:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233004AbiLXET0 (ORCPT ); Fri, 23 Dec 2022 23:19:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231219AbiLXETX (ORCPT ); Fri, 23 Dec 2022 23:19:23 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C7A71CB2E; Fri, 23 Dec 2022 20:19:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1671855545; bh=C3o0ZLdtTlEJI2pYfk3GoSAVs6STbyj1X4ArX6hGlPs=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=cHzsmviExQDJFCME5rIWjUizcfRy/tU2AJDHU1k+bc2F9fa67IXMOUuMgqRpUHyLI fGOZoW1O89+eFS6AoC0K6FfwfaUo4YCSY0duNO8Cb9NpMotioNsfwxvKfp1h5JHQF8 sqclrRZlr4fM/OfnFt7p/MklUdvTUfGLGP8Dtaq65Z4i7jCjimrXuycqJXbGXriqm5 myV8Km1dPW23+sag1G0hIMNV+s+pMVC/sEf8HQYrwvRxRJeEwYQgGAX+ehYaefzrD7 GqfKZ8bv1cCfW6GXlWwevDhT0NW0HBYaqSgl5hf6lXnFSAEXU1EyafiZgiVznUNhL+ T0vh536NeqVZA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M59C2-1p7pXR2j5g-001BZi; Sat, 24 Dec 2022 05:19:05 +0100 From: Armin Wolf To: jdelvare@suse.com, linux@roeck-us.net Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] hwmon: (ftsteutates) Use devm_watchdog_register_device() Date: Sat, 24 Dec 2022 05:18:55 +0100 Message-Id: <20221224041855.83981-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221224041855.83981-1-W_Armin@gmx.de> References: <20221224041855.83981-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:7nl4MURSq3AU+KB+lIzKjozqIBMe8kzrct014sU7H0mlIb1sBgW jVkbMR3KWEy400YVlz538qrJrp01ieThQsskQ/yjYOBSK/v+cZNbe/OKHDJlNMVaXpzFIh9 ZCkNq1C22MuCLgJbTTjA0VPPRG5MKrBlhUENVofGuTndydiqsmwms0SNgPnphk/gtEy1iB9 WAIsoqtgFwenY5y7G3pDQ== UI-OutboundReport: notjunk:1;M01:P0:S6UXNNAY8rY=;S+0q/L4KlVSl1hCKyPxForzHkCd WzJTR/JjArww35upLCENkuqFOtlQWG3gfAKULKfRKqZsKoxMFGOMesDFcjIlNzhoKNEQa5FxX pUoqiKVtB2mIxgC4EAk12EkT6D/vs2LZ6L7Ydawq4PXNh5HoBLtNJZ7w/YNVzHPw0VNQw0ddE d9Z+r+dCM7YeVuSYg6Yw2RhxXtBzv2WcW5Oe0PCko6Y4WtUxsqLKvsgnGVCBBwb5L4W4F5NwH 8kvQk6vBuJ2b23TKSpx6WsFSg1nVeNQUDS8BdRHDltux0zdVcAJbPMhmQ9gSwhrG5ZijT2yxq LFJ7H0yZLx7A2Oim1gVFRMUzE58IpanVGBLm3nmvtWDxZBRBdbWvf8PMmCsmUCBEqEZe0q2Ya CXKZ4wNA6W8fi+G/hzXF9dxr2dZABGbE5tHeqIo+8/BN5i7+Qzvqsqq0zDsG6o0zJay45cK+a g0neAgjzGYf/KfUCFiAflAts6C+Z/KXCpWVvOvfegJQi7yCqbcDTOMQdG2PBom8pdgu4nmrBN AzITE+MDnn6tUqhXRAX31z6zz3vwhl/geyp23v/NF4jdpfJsq1ZszSP9c1SrOAS7t6OR65155 ReDn6kYydAuYJ1UWMBdVzKAfLu7OMAqfNpYQMZ2rpw27StZdj8DM4ZgNAeK3O/wl8cDnIOXCb Cv3MAQywmsuA4TAAzIxNpkZGzuGYAqVC4wf0VozsUqkf/XUCoBZIcCL7DT/9TGx6rXzjgHTW4 buBzZjLSIIX7NyFFdhW4qsAeCvtszXA4FohYSTC7HRRm3f6jnfJgVHshvnpAPwdxSX3ZuEKyS kRz9F42EnVRQ6VW9dOqRSrrlE34JnZBpLMdkdgL8OhQD6pD/urLJPfFtNnQ9t5YofMGRE0LeL s0VfVif1w1WAitExu5z5/BAsLV2u9qB6p1wG6RdLyME6P+FHIifbtcGcCgDoo96A+zvXpXb+A WmD67kryh0UM6q9saar/QmSIl48= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Use devm_watchdog_register_device() to let devres take care of unregistering the watchdog at device removal. Remove the now pointless fts_remove() function. Tested on a Fujitsu DS3401-B1. Signed-off-by: Armin Wolf --- drivers/hwmon/ftsteutates.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) -- 2.30.2 diff --git a/drivers/hwmon/ftsteutates.c b/drivers/hwmon/ftsteutates.c index 66ff8d69a0de..d8878b8d16bc 100644 --- a/drivers/hwmon/ftsteutates.c +++ b/drivers/hwmon/ftsteutates.c @@ -333,7 +333,7 @@ static int fts_watchdog_init(struct fts_data *data) /* max timeout 255 minutes. */ data->wdd.max_hw_heartbeat_ms = 0xFF * 60 * MSEC_PER_SEC; - return watchdog_register_device(&data->wdd); + return devm_watchdog_register_device(&data->client->dev, &data->wdd); } static umode_t fts_is_visible(const void *devdata, enum hwmon_sensor_types type, u32 attr, @@ -611,13 +611,6 @@ static int fts_detect(struct i2c_client *client, return 0; } -static void fts_remove(struct i2c_client *client) -{ - struct fts_data *data = dev_get_drvdata(&client->dev); - - watchdog_unregister_device(&data->wdd); -} - static int fts_probe(struct i2c_client *client) { u8 revision; @@ -684,7 +677,6 @@ static struct i2c_driver fts_driver = { }, .id_table = fts_id, .probe_new = fts_probe, - .remove = fts_remove, .detect = fts_detect, .address_list = normal_i2c, };