From: Daniel Matyas <daniel.matyas@analog.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Daniel Matyas <daniel.matyas@analog.com>,
Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Jonathan Corbet <corbet@lwn.net>, <linux-hwmon@vger.kernel.org>,
<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v6 4/5] hwmon: max31827: Return closest value in update_interval
Date: Tue, 31 Oct 2023 20:21:56 +0200 [thread overview]
Message-ID: <20231031182158.124608-4-daniel.matyas@analog.com> (raw)
In-Reply-To: <20231031182158.124608-1-daniel.matyas@analog.com>
When user writes a value to update_interval which does not match the
possible values, instead of returning invalid error, return the closest
value.
Signed-off-by: Daniel Matyas <daniel.matyas@analog.com>
---
v6: Added patch.
drivers/hwmon/max31827.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/max31827.c b/drivers/hwmon/max31827.c
index 41e4f716605a..13ebe691475a 100644
--- a/drivers/hwmon/max31827.c
+++ b/drivers/hwmon/max31827.c
@@ -360,9 +360,8 @@ static int max31827_write(struct device *dev, enum hwmon_sensor_types type,
val < max31827_conversions[res])
res++;
- if (res == ARRAY_SIZE(max31827_conversions) ||
- val != max31827_conversions[res])
- return -EINVAL;
+ if (res == ARRAY_SIZE(max31827_conversions))
+ res = ARRAY_SIZE(max31827_conversions) - 1;
res = FIELD_PREP(MAX31827_CONFIGURATION_CNV_RATE_MASK,
res);
--
2.34.1
next prev parent reply other threads:[~2023-10-31 22:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-31 18:21 [PATCH v6 1/5] hwmon: max31827: Handle new properties from the devicetree Daniel Matyas
2023-10-31 18:21 ` [PATCH v6 2/5] hwmon: max31827: Add support for max31828 and max31829 Daniel Matyas
2023-10-31 18:21 ` [PATCH v6 3/5] hwmon: max31827: Update bits with shutdown_write() Daniel Matyas
2023-10-31 18:21 ` Daniel Matyas [this message]
2023-10-31 18:21 ` [PATCH v6 5/5] hwmon: max31827: Add custom attribute for resolution Daniel Matyas
2023-12-11 14:15 ` 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=20231031182158.124608-4-daniel.matyas@analog.com \
--to=daniel.matyas@analog.com \
--cc=corbet@lwn.net \
--cc=jdelvare@suse.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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