From patchwork Sun Aug 7 23:32:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9266593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 663CF60754 for ; Sun, 7 Aug 2016 23:32:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57D98279B3 for ; Sun, 7 Aug 2016 23:32:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4849A27BE5; Sun, 7 Aug 2016 23:32:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E26E02624C for ; Sun, 7 Aug 2016 23:32:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752070AbcHGXcZ (ORCPT ); Sun, 7 Aug 2016 19:32:25 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:55753 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751579AbcHGXcY (ORCPT ); Sun, 7 Aug 2016 19:32:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From; bh=S7jUrY7P9FOTpHU+9RxPWYQG0ftN2xGPKQdju0ScMHs=; b=jUiwX+YtZkazbY JwJ+5fglsVeh3YJlZDvmrIk2tdHp0vvuU7U96A6cLnu2vZvJFSKH5C768XJHDKvOvvqFyza0pD9Ua mikzRXFgOqebHIrEVjZz3ZagIUxTW2dH7idlxr9uBF3svi9td4bK4UVN+ni36L0mwdHRpkz1Kwhhy gXh1HKE2MOuFg1ImYWCYDT3J2tNq6M7DRXwFWR5MNw0Mhw6BhG5c65d1kY9n+hiV/4KDd/2+lE1Ie y9oTA2TFIB9XZLn5II99nKyN1Sa2MaNsfyJMI5RkJ9LHhmIxY+B8lpyRQjrkTxg5OBbFAL3OkKkBs 2SxAem5q/lUOaQXPhghQ==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:42020 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1bWXYC-003c1U-Q3; Sun, 07 Aug 2016 23:32:13 +0000 From: Guenter Roeck To: Jean Delvare Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 6/6] hwmon: (lm95241) Use more accurate limits Date: Sun, 7 Aug 2016 16:32:00 -0700 Message-Id: <1470612720-30165-6-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1470612720-30165-1-git-send-email-linux@roeck-us.net> References: <1470612720-30165-1-git-send-email-linux@roeck-us.net> X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The lower temperature limit is -128 degrees C. The supported upper limits are 127.875 or 255.875 degrees C. Also, don't fail if a value outside the supported range is provided when setting a temperature limit. Instead, clamp the provided value to the available value range. Signed-off-by: Guenter Roeck --- drivers/hwmon/lm95241.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c index df94f486b21c..3d96c3fcba9b 100644 --- a/drivers/hwmon/lm95241.c +++ b/drivers/hwmon/lm95241.c @@ -205,7 +205,7 @@ static ssize_t show_min(struct device *dev, struct device_attribute *attr, return snprintf(buf, PAGE_SIZE - 1, data->config & to_sensor_dev_attr(attr)->index ? - "-127000\n" : "0\n"); + "-128000\n" : "0\n"); } static ssize_t set_min(struct device *dev, struct device_attribute *attr, @@ -216,8 +216,6 @@ static ssize_t set_min(struct device *dev, struct device_attribute *attr, if (kstrtol(buf, 10, &val) < 0) return -EINVAL; - if (val < -128000) - return -EINVAL; mutex_lock(&data->update_lock); @@ -242,7 +240,7 @@ static ssize_t show_max(struct device *dev, struct device_attribute *attr, return snprintf(buf, PAGE_SIZE - 1, data->config & to_sensor_dev_attr(attr)->index ? - "127000\n" : "255000\n"); + "127875\n" : "255875\n"); } static ssize_t set_max(struct device *dev, struct device_attribute *attr, @@ -253,8 +251,6 @@ static ssize_t set_max(struct device *dev, struct device_attribute *attr, if (kstrtol(buf, 10, &val) < 0) return -EINVAL; - if (val >= 256000) - return -EINVAL; mutex_lock(&data->update_lock);