From patchwork Thu Jun 30 06:45:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9206721 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 165B8607D6 for ; Thu, 30 Jun 2016 06:48:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06B66284BC for ; Thu, 30 Jun 2016 06:48:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF74C284D0; Thu, 30 Jun 2016 06:48:31 +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 A5D41284BC for ; Thu, 30 Jun 2016 06:48:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751846AbcF3Gpj (ORCPT ); Thu, 30 Jun 2016 02:45:39 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:34288 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751203AbcF3Gph (ORCPT ); Thu, 30 Jun 2016 02:45:37 -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=U2OwSvV83XTXJxGZo4G+8C+KWTBHpozAOYxmxFlYvzk=; b=uJK9NO1hYoMkJZ wIF1TwaVWUOvH5rnk8fXVUjD6KyzGSaCwcCMVHa58fDW0kgA6xql5qyxbiBXICylyVCpxVR8PBuFa 8rbL5GVKZ4QDTBtc4nIG2TfuGhFGbrIhMOqRUNNQMWe3Wvov9n5eHQMWKiPrjvw95phiVB1lKbzyp WDIuJ4eR5clKsx510eDBiyvVcXHJSsur/2MMPjxLNaJpY9O6CFeBIaNK+wHmlbNnTyNXnOj1Sc06x U0r0C5mZz31gUQZrP1UJt7DiyUCBPlaA38T3PQKb/WKA5Bi2OodCP14vvUL5jPCKvFnhT+LNvU/0T FVxQBU3UrW5+zzMscNTg==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:54120 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1bIVj7-004F8L-UJ; Thu, 30 Jun 2016 06:45:30 +0000 From: Guenter Roeck To: Jean Delvare Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH v3 3/4] hwmon: (lm75) Add update_interval attribute Date: Wed, 29 Jun 2016 23:45:27 -0700 Message-Id: <1467269128-7448-3-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1467269128-7448-1-git-send-email-linux@roeck-us.net> References: <1467269128-7448-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 Since we know the chip's update interval, let's make it available to the user. Signed-off-by: Guenter Roeck --- v2, v3: No change drivers/hwmon/lm75.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 7b18cbd4a5ec..fe83f70ba62a 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -159,16 +159,29 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, return count; } +static ssize_t show_update_interval(struct device *dev, + struct device_attribute *da, char *buf) +{ + struct lm75_data *data = lm75_update_device(dev); + + if (IS_ERR(data)) + return PTR_ERR(data); + + return sprintf(buf, "%u\n", jiffies_to_msecs(data->sample_time)); +} + static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, set_temp, 1); static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, show_temp, set_temp, 2); static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); +static DEVICE_ATTR(update_interval, S_IRUGO, show_update_interval, NULL); static struct attribute *lm75_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_max.dev_attr.attr, &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, + &dev_attr_update_interval.attr, NULL };