From patchwork Tue Sep 6 22:25:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Scott X-Patchwork-Id: 9318005 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 EB44060760 for ; Tue, 6 Sep 2016 22:25:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C573328F07 for ; Tue, 6 Sep 2016 22:25:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9C8328F09; Tue, 6 Sep 2016 22:25:30 +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 7E33628F07 for ; Tue, 6 Sep 2016 22:25:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934061AbcIFWZ3 (ORCPT ); Tue, 6 Sep 2016 18:25:29 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:43034 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933062AbcIFWZ2 (ORCPT ); Tue, 6 Sep 2016 18:25:28 -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 98442800E6; Wed, 7 Sep 2016 10:25:24 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1473200724; bh=2Pr1S8nPKAKDbS5p38VhDp0NwhPEteon5s9xC3QOAKU=; h=From:To:Cc:Subject:Date; b=F0vcTTKxYDiyufUoefb3PYT++tf3DBJLSbHjTLmr6Kg+X8YDpirnvDJNGkSONFDrw ZVnKlMw+kDSwt+x4F4X+qrllZ8/++zQnnjzbHKlJ2g9QSVsBnyiY9vGx9c4cSX1aWv 3pMNQufESkg4qA1HA1TN92fIcGYJ3MBgEKZ6UUug= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 3, 6, 7949) id ; Wed, 07 Sep 2016 10:25:24 +1200 Received: from joshuas-dl.ws.atlnz.lc (joshuas-dl.ws.atlnz.lc [10.33.13.25]) by smtp (Postfix) with ESMTP id F333813EC2D; Wed, 7 Sep 2016 10:25:22 +1200 (NZST) Received: by joshuas-dl.ws.atlnz.lc (Postfix, from userid 1634) id E94041A02F1; Wed, 7 Sep 2016 10:25:23 +1200 (NZST) From: Joshua Scott To: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org Cc: Joshua Scott , Chris Packham Subject: [PATCH] hwmon: adt7470: Add write support to alarm_mask Date: Wed, 7 Sep 2016 10:25:19 +1200 Message-Id: <20160906222519.30842-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 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c index 94550d7..7d185a9 100644 --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c @@ -545,6 +545,27 @@ 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 (kstrtol(buf, 0, &mask)) + return -EINVAL; + + mask &= 0xffff; + + 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 +1010,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,