From patchwork Tue Dec 27 23:28:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9489921 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 71EBF602A7 for ; Tue, 27 Dec 2016 23:28:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 538E81FF1D for ; Tue, 27 Dec 2016 23:28:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4503F2094F; Tue, 27 Dec 2016 23:28: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 E2C981FF1D for ; Tue, 27 Dec 2016 23:28:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755461AbcL0X2j (ORCPT ); Tue, 27 Dec 2016 18:28:39 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:55730 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755115AbcL0X2j (ORCPT ); Tue, 27 Dec 2016 18:28:39 -0500 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=zyjs5XYTXIZFEZp8nQtV5YDseVXmzuS/vs/blaq7mxk=; b=ny2YPPLod3DYqE sNU+Fwj+YIwVZUWbNZ2xQOMNhfD9Q2aviysrLZ9Ckanh32578kngi/dA8A9c0FjJtBx/5+rBBHKSr xBvjFrMItz7qA78WDfZtWMqGp3bSwhwcLCqtbqZV2HN22epHsX7GfctVGspJQ7UkcMt3xuLqg5kCo 5gDgBnGQff4SqViP9JnHmGJbcKFQH4yNFSPqyXiFpqQsMTlIJ0KBYdNyvC8w8qAAzrNhqtwZFD+6E H7xIJy5GaS6p4XJt+2f7PUQ1Sp/h9yyazop+fAMIhb0gStj24yUL7XBISgctxk+xd5mQPIDKQeL7+ kidHFgXPQyUK4DInHybw==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:51576 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1cM1Ac-004488-91; Tue, 27 Dec 2016 23:28:38 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 05/10] hwmon: (f75375s) Replace function macro with explicit code Date: Tue, 27 Dec 2016 15:28:23 -0800 Message-Id: <1482881308-13550-6-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482881308-13550-1-git-send-email-linux@roeck-us.net> References: <1482881308-13550-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 Replace function macro with explicit code to to reduce code obfuscation and to enable auto-conversion to SENSOR_DEVICE_ATTR_{RO,RW}. Signed-off-by: Guenter Roeck --- drivers/hwmon/f75375s.c | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c index 80c42bea90ed..652ca4b34137 100644 --- a/drivers/hwmon/f75375s.c +++ b/drivers/hwmon/f75375s.c @@ -655,19 +655,41 @@ static ssize_t set_temp_max_hyst(struct device *dev, return count; } -#define show_fan(thing) \ -static ssize_t show_##thing(struct device *dev, struct device_attribute *attr, \ - char *buf)\ -{\ - int nr = to_sensor_dev_attr(attr)->index;\ - struct f75375_data *data = f75375_update_device(dev); \ - return sprintf(buf, "%d\n", rpm_from_reg(data->thing[nr])); \ -} - -show_fan(fan); -show_fan(fan_min); -show_fan(fan_max); -show_fan(fan_target); +static ssize_t show_fan(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int nr = to_sensor_dev_attr(attr)->index; + struct f75375_data *data = f75375_update_device(dev); + + return sprintf(buf, "%d\n", rpm_from_reg(data->fan[nr])); +} + +static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int nr = to_sensor_dev_attr(attr)->index; + struct f75375_data *data = f75375_update_device(dev); + + return sprintf(buf, "%d\n", rpm_from_reg(data->fan_min[nr])); +} + +static ssize_t show_fan_max(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int nr = to_sensor_dev_attr(attr)->index; + struct f75375_data *data = f75375_update_device(dev); + + return sprintf(buf, "%d\n", rpm_from_reg(data->fan_max[nr])); +} + +static ssize_t show_fan_target(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int nr = to_sensor_dev_attr(attr)->index; + struct f75375_data *data = f75375_update_device(dev); + + return sprintf(buf, "%d\n", rpm_from_reg(data->fan_target[nr])); +} static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in, NULL, 0); static SENSOR_DEVICE_ATTR(in0_max, S_IRUGO|S_IWUSR,