From patchwork Fri Sep 9 05:19:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Scott X-Patchwork-Id: 9322397 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 6153360231 for ; Fri, 9 Sep 2016 05:19:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F8F929BB5 for ; Fri, 9 Sep 2016 05:19:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F75B29BBA; Fri, 9 Sep 2016 05:19:47 +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 0EED829BB5 for ; Fri, 9 Sep 2016 05:19:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750714AbcIIFTp (ORCPT ); Fri, 9 Sep 2016 01:19:45 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:50416 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750756AbcIIFTo (ORCPT ); Fri, 9 Sep 2016 01:19:44 -0400 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id CE554800E6; Fri, 9 Sep 2016 17:19:40 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1473398380; bh=BL3Dk/+wDY6NdAa5lm3X18e+VAXcg1YgrOO3/d0WZGE=; h=From:To:Cc:Subject:Date; b=BL35XYI53fnZ6t4bDFEd6G43f7OpRAELvTZ2FJSFQOhHT0pX0KQ+KLnEQkR+uXtWt NbfyO5DGrxr1LnwE1uowvzuuUmI/7mdQt3oUgKZruPlzLFtYyo5fC3OOP3BVKo2+fV 85pgMbQjTbNJgRsKm/h3csS/ZBXe4cDfhURJoTf0= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 3, 6, 7949) id ; Fri, 09 Sep 2016 17:19:40 +1200 Received: from joshuas-dl.ws.atlnz.lc (joshuas-dl.ws.atlnz.lc [10.33.13.25]) by smtp (Postfix) with ESMTP id 27F8A13EF09; Fri, 9 Sep 2016 17:19:39 +1200 (NZST) Received: by joshuas-dl.ws.atlnz.lc (Postfix, from userid 1634) id 534B61A03CA; Fri, 9 Sep 2016 17:19:40 +1200 (NZST) From: Joshua Scott To: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org Cc: Joshua Scott , Chris Packham Subject: [PATCH 1/2] hwmon: adt7470: Add write support to alarm_mask Date: Fri, 9 Sep 2016 17:19:25 +1200 Message-Id: <20160909051926.4253-1-joshua.scott@alliedtelesis.co.nz> X-Mailer: git-send-email 2.9.0 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 Add write support for the alarm_mask. A base of 0 is provided so that either hex or decimal can be used. The hex format when reading alarm_mask is unchanged. Signed-off-by: Joshua Scott --- drivers/hwmon/adt7470.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c index 94550d7..dbd758b 100644 --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c @@ -545,6 +545,28 @@ static ssize_t show_alarm_mask(struct device *dev, return sprintf(buf, "%x\n", data->alarms_mask); } +static ssize_t set_alarm_mask(struct device *dev, + struct device_attribute *devattr, + const char *buf, + size_t count) +{ + struct adt7470_data *data = dev_get_drvdata(dev); + long mask; + + if (kstrtoul(buf, 0, &mask)) + return -EINVAL; + + if (mask & ~0xffff) + return -EINVAL; + + mutex_lock(&data->lock); + data->alarms_mask = mask; + adt7470_write_word_data(data->client, ADT7470_REG_ALARM1_MASK, mask); + mutex_unlock(&data->lock); + + return count; +} + static ssize_t show_fan_max(struct device *dev, struct device_attribute *devattr, char *buf) @@ -989,7 +1011,8 @@ static ssize_t show_alarm(struct device *dev, return sprintf(buf, "0\n"); } -static DEVICE_ATTR(alarm_mask, S_IRUGO, show_alarm_mask, NULL); +static DEVICE_ATTR(alarm_mask, S_IWUSR | S_IRUGO, show_alarm_mask, + set_alarm_mask); static DEVICE_ATTR(num_temp_sensors, S_IWUSR | S_IRUGO, show_num_temp_sensors, set_num_temp_sensors); static DEVICE_ATTR(auto_update_interval, S_IWUSR | S_IRUGO,