From patchwork Thu Jul 12 01:04:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: IKEGAMI Tokunori X-Patchwork-Id: 10520765 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 F0AB8602C8 for ; Thu, 12 Jul 2018 01:05:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB2BE2966E for ; Thu, 12 Jul 2018 01:05:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF5BF29858; Thu, 12 Jul 2018 01:05:42 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 5E11F2966E for ; Thu, 12 Jul 2018 01:05:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389255AbeGLBMj (ORCPT ); Wed, 11 Jul 2018 21:12:39 -0400 Received: from mail1.bemta24.messagelabs.com ([67.219.250.3]:8773 "EHLO mail1.bemta24.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387724AbeGLBMj (ORCPT ); Wed, 11 Jul 2018 21:12:39 -0400 Received: from [67.219.250.100] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-3.bemta.az-a.us-west-2.aws.symcld.net id E3/7F-01617-469A64B5; Thu, 12 Jul 2018 01:05:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupikeJIrShJLcpLzFFi42KZFv5DRDdlpVu 0wYvpGhbtr7cyOjB6fN4kF8AYxZqZl5RfkcCa0fZkC3vBKuWKY59uszUwbpTrYuTiEBKYyyhx evtcJgjnF6PEw84J7F2MnBxsAqYS018tZASxRQRUJLasW8MMUsQs0Moo8X/BOrCEsICbxLKZR 1i7GDk4WARUJR5fVwMJ8wo4Slx7eQtsjoSAvMThN02sIDangJPEuQn7wOJCQDWzz0PEhQQ0JZ 73fGeEqA+W+PC7iWUCI+8CRoZVjBZJRZnpGSW5iZk5uoYGBrqGhka6hsYGukbGFnqJVbqJeqX FuuWpxSW6RnqJ5cV6xZW5yTkpenmpJZsYgeHCAAQ7GNsPpxxilORgUhLllbJyjRbiS8pPqcxI LM6ILyrNSS0+xCjDwaEkwbtruVu0kGBRanpqRVpmDjBwYdISHDxKIrwFIGne4oLE3OLMdIjUK UZdjj/vp05iFmLJy89LlRLnZV4BVCQAUpRRmgc3AhZFlxhlpYR5GYGOEuIpSC3KzSxBlX/FKM 7BqCTM2wSyiiczrwRu0yugI5iAjohLATuiJBEhJdXAmH7C6cb017Lansfyc9fvtzgbuoe90FN QZtv8g2VyP48/XHdNs8E95tNtqRVmn++7t32KODbTOE5k4Wvz1Li9bHVx7caTVX6Khh2fFZGq q7aW6enviRs+ze92OJPnMPtrZU187s6Hr03qJz79wfgjrehjT5P118wHZl5rvC/uT6k7aL/Nv OHRXCWW4oxEQy3mouJEADrPcrOdAgAA X-Env-Sender: ikegami@allied-telesis.co.jp X-Msg-Ref: server-24.tower-324.messagelabs.com!1531357539!1562331!1 X-Originating-IP: [150.87.248.20] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.9.15; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19744 invoked from network); 12 Jul 2018 01:05:40 -0000 Received: from abricot-inet.allied-telesis.co.jp (HELO TKY-DS01.at.lc) (150.87.248.20) by server-24.tower-324.messagelabs.com with SMTP; 12 Jul 2018 01:05:40 -0000 Received: from swim-manx.rd.allied-telesis.co.jp ([150.87.21.50]) by TKY-DS01.at.lc with Microsoft SMTPSVC(8.0.9200.16384); Thu, 12 Jul 2018 10:05:39 +0900 Received: from ikegami-pc.rd.allied-telesis.co.jp by swim-manx.rd.allied-telesis.co.jp (AlliedTelesis SMTPRS 1.3 pl 1 ++E6B86F8C687C6288D9B5559052954DC9) with ESMTP id ; Thu, 12 Jul 2018 10:05:38 +0900 From: Tokunori Ikegami To: Jean Delvare Cc: Tokunori Ikegami , Chris Packham , linux-hwmon@vger.kernel.org Subject: [PATCH 4/5] hwmon: adt7475: Change to use adt7475_write macro Date: Thu, 12 Jul 2018 10:04:49 +0900 Message-Id: <20180712010450.10586-5-ikegami@allied-telesis.co.jp> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180712010450.10586-1-ikegami@allied-telesis.co.jp> References: <20180712010450.10586-1-ikegami@allied-telesis.co.jp> X-OriginalArrivalTime: 12 Jul 2018 01:05:39.0383 (UTC) FILETIME=[72D5A470:01D4197C] 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 As same with adt7475_read it is better to use adt7475_write macro. So change to use it instead of i2c_smbus_write_byte_data. Signed-off-by: Tokunori Ikegami Cc: Chris Packham Cc: linux-hwmon@vger.kernel.org --- drivers/hwmon/adt7475.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index bad250729e99..31a12ac405ef 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -133,6 +133,10 @@ #define adt7475_read(reg) i2c_smbus_read_byte_data(client, (reg)) +/* Macro to write the registers */ + +#define adt7475_write(reg, val) i2c_smbus_write_byte_data(client, (reg), (val)) + /* Macros to easily index the registers */ #define TACH_REG(idx) (REG_TACH_BASE + ((idx) * 2)) @@ -322,11 +326,11 @@ static int adt7475_write_word(struct i2c_client *client, int reg, u16 val) { int ret; - ret = i2c_smbus_write_byte_data(client, reg + 1, val >> 8); + ret = adt7475_write(reg + 1, val >> 8); if (ret < 0) return ret; - ret = i2c_smbus_write_byte_data(client, reg, val & 0xFF); + ret = adt7475_write(reg, val & 0xFF); if (ret < 0) return ret; @@ -381,7 +385,7 @@ static ssize_t set_voltage(struct device *dev, struct device_attribute *attr, reg = REG_VTT_MAX; } - i2c_smbus_write_byte_data(client, reg, + adt7475_write(reg, data->voltage[sattr->nr][sattr->index] >> 2); mutex_unlock(&data->lock); @@ -534,7 +538,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *attr, break; } - i2c_smbus_write_byte_data(client, reg, out); + adt7475_write(reg, out); mutex_unlock(&data->lock); return count; @@ -615,7 +619,7 @@ static ssize_t set_temp_st(struct device *dev, struct device_attribute *attr, data->enh_acoustics[idx] &= ~(0xf << shift); data->enh_acoustics[idx] |= (val << shift); - i2c_smbus_write_byte_data(client, reg, data->enh_acoustics[idx]); + adt7475_write(reg, data->enh_acoustics[idx]); mutex_unlock(&data->lock); @@ -683,7 +687,7 @@ static ssize_t set_point2(struct device *dev, struct device_attribute *attr, data->range[sattr->index] &= ~0xF0; data->range[sattr->index] |= val << 4; - i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index), + adt7475_write(TEMP_TRANGE_REG(sattr->index), data->range[sattr->index]); mutex_unlock(&data->lock); @@ -798,7 +802,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, } data->pwm[sattr->nr][sattr->index] = clamp_val(val, 0, 0xFF); - i2c_smbus_write_byte_data(client, reg, + adt7475_write(reg, data->pwm[sattr->nr][sattr->index]); mutex_unlock(&data->lock); @@ -835,7 +839,7 @@ static ssize_t set_stall_disable(struct device *dev, if (val) data->enh_acoustics[0] |= mask; - i2c_smbus_write_byte_data(client, REG_ENHANCE_ACOUSTICS1, + adt7475_write(REG_ENHANCE_ACOUSTICS1, data->enh_acoustics[0]); mutex_unlock(&data->lock); @@ -894,7 +898,7 @@ static int hw_set_pwm(struct i2c_client *client, int index, data->pwm[CONTROL][index] &= ~0xE0; data->pwm[CONTROL][index] |= (val & 7) << 5; - i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(index), + adt7475_write(PWM_CONFIG_REG(index), data->pwm[CONTROL][index]); return 0; @@ -983,7 +987,7 @@ static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr, data->range[sattr->index] &= ~0xf; data->range[sattr->index] |= out; - i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index), + adt7475_write(TEMP_TRANGE_REG(sattr->index), data->range[sattr->index]); mutex_unlock(&data->lock); @@ -1017,7 +1021,7 @@ static ssize_t pwm_use_point2_pwm_at_crit_store(struct device *dev, data->config4 |= CONFIG4_MAXDUTY; else data->config4 &= ~CONFIG4_MAXDUTY; - i2c_smbus_write_byte_data(client, REG_CONFIG4, data->config4); + adt7475_write(REG_CONFIG4, data->config4); mutex_unlock(&data->lock); return count; @@ -1642,10 +1646,10 @@ static void adt7475_read_pwm(struct i2c_client *client, int index) data->pwm[CONTROL][index] &= ~0xE0; data->pwm[CONTROL][index] |= (7 << 5); - i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(index), + adt7475_write(PWM_CONFIG_REG(index), data->pwm[INPUT][index]); - i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(index), + adt7475_write(PWM_CONFIG_REG(index), data->pwm[CONTROL][index]); data->pwmctl[index] = 1;