From patchwork Thu Jul 12 01:04:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: IKEGAMI Tokunori X-Patchwork-Id: 10520761 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 8F1DC603D7 for ; Thu, 12 Jul 2018 01:05:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A1122966E for ; Thu, 12 Jul 2018 01:05:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DA4829858; Thu, 12 Jul 2018 01:05:39 +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 195892966E for ; Thu, 12 Jul 2018 01:05:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388260AbeGLBMg (ORCPT ); Wed, 11 Jul 2018 21:12:36 -0400 Received: from mail1.bemta23.messagelabs.com ([67.219.246.211]:52483 "EHLO mail1.bemta23.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387724AbeGLBMg (ORCPT ); Wed, 11 Jul 2018 21:12:36 -0400 Received: from [67.219.247.52] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-4.bemta.az-d.us-east-1.aws.symcld.net id C1/ED-01620-169A64B5; Thu, 12 Jul 2018 01:05:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnkeJIrShJLcpLzFFi42KZFv5DRDdxpVu 0wa4OFov211sZHRg9Pm+SC2CMYs3MS8qvSGDN+Purg7lgG2/F7qlpDYwbubsYuTiEBOYyShza vJMVwvnFKLH58Sogh5ODTcBUYvqrhYwgtoiAisSWdWuYQYqYBVoZJf4vWAeWEBYIkZj44QVQg oODRUBVonm6AUiYV8BR4kbDabA5EgLyEoffNIHZnAJOEucm7GMHsYWAamafh4gLCWhKPO/5zg hRHyzxZfU61gmMvAsYGVYxmiUVZaZnlOQmZuboGhoY6BoaGgFpXXMjvcQq3RS90mLd1MTiEl1 DvcTyYr3iytzknBS9vNSSTYzAQGEAgh2M63+kHGKU5GBSEuWVsnKNFuJLyk+pzEgszogvKs1J LT7EKMPBoSTB+3W5W7SQYFFqempFWmYOMGRh0hIcPEoivAUgad7igsTc4sx0iNQpRl2OP++nT mIWYsnLz0uVEudlXgFUJABSlFGaBzcCFj+XGGWlhHkZgY4S4ilILcrNLEGVf8UozsGoJMxrDz KFJzOvBG7TK6AjmICOiEsBO6IkESEl1cDoqvBlT/GTfTaFq15oK+ln77Ln1eBhXs0tzH3G2OD dsehgB/WOqkcrjU5U3l2hEC4odU/4/Y5dwoa/73fMfNI0y1vyhabMqm2OTkUz/038auRoWKMT t5RN2/vMw10nQt+q3kgVD40pl2+UW8ORsqkuoP9oyONZJ5rDxPma35QJzU7esdhL+7gSS3FGo qEWc1FxIgAXd2YamgIAAA== X-Env-Sender: ikegami@allied-telesis.co.jp X-Msg-Ref: server-23.tower-424.messagelabs.com!1531357536!277129!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 9640 invoked from network); 12 Jul 2018 01:05:36 -0000 Received: from abricot-inet.allied-telesis.co.jp (HELO TKY-DS01.at.lc) (150.87.248.20) by server-23.tower-424.messagelabs.com with SMTP; 12 Jul 2018 01:05:36 -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:35 +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:35 +0900 From: Tokunori Ikegami To: Jean Delvare Cc: Tokunori Ikegami , Chris Packham , linux-hwmon@vger.kernel.org Subject: [PATCH 2/5] hwmon: adt7475: Change read and write functions to return error Date: Thu, 12 Jul 2018 10:04:47 +0900 Message-Id: <20180712010450.10586-3-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:35.0776 (UTC) FILETIME=[70AF4200: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 Currently adt7475_read_word and adt7475_write_word do not return error. So change both functions to return error codes correctly. Signed-off-by: Tokunori Ikegami Cc: Chris Packham Cc: linux-hwmon@vger.kernel.org --- drivers/hwmon/adt7475.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index 234f725213f9..a40eb62ee6b1 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -303,20 +303,34 @@ static inline u16 volt2reg(int channel, long volt, u8 bypass_attn) return clamp_val(reg, 0, 1023) & (0xff << 2); } -static u16 adt7475_read_word(struct i2c_client *client, int reg) +static int adt7475_read_word(struct i2c_client *client, int reg) { - u16 val; + int val, val2; - val = i2c_smbus_read_byte_data(client, reg); - val |= (i2c_smbus_read_byte_data(client, reg + 1) << 8); + val = adt7475_read(reg); + if (val < 0) + return val; - return val; + val2 = adt7475_read(reg + 1); + if (val2 < 0) + return val2; + + return val | (val2 << 8); } -static void adt7475_write_word(struct i2c_client *client, int reg, u16 val) +static int adt7475_write_word(struct i2c_client *client, int reg, u16 val) { - i2c_smbus_write_byte_data(client, reg + 1, val >> 8); - i2c_smbus_write_byte_data(client, reg, val & 0xFF); + int ret; + + ret = i2c_smbus_write_byte_data(client, reg + 1, val >> 8); + if (ret < 0) + return ret; + + ret = i2c_smbus_write_byte_data(client, reg, val & 0xFF); + if (ret < 0) + return ret; + + return 0; } static ssize_t show_voltage(struct device *dev, struct device_attribute *attr,