From patchwork Thu Jun 30 06:45:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9206725 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 0B2076089D for ; Thu, 30 Jun 2016 06:48:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF259284C6 for ; Thu, 30 Jun 2016 06:48:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3E3F285C7; Thu, 30 Jun 2016 06:48:35 +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=unavailable 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 83556284D0 for ; Thu, 30 Jun 2016 06:48:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751858AbcF3Gsc (ORCPT ); Thu, 30 Jun 2016 02:48:32 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:34144 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751831AbcF3Gpb (ORCPT ); Thu, 30 Jun 2016 02:45:31 -0400 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=AGnkxKsP30cO4t05HsvzCv/jsUrxb2QQsrUKAU23jxw=; b=wdWKZJSAIrImVO qpV2qnzpC+OhkntuvZg5s11YQCK75NkZClYtA2YfXy27pxkSZbClLTiLj1zmdEJvk9s56nkhjFifJ qhMBrgUuMH0ubHhmAGCcEFjy0JzdMuGhE8ZtjP1UwaBFWDAB7HGzul8loHecf/Qi6Rqh2CViUMP+9 Ja2BrdeQ5lbBkOcDqZJii4SfY0rhvqBVvn0ex6slOZMlYG/RW8ZveFls7zbY96nsIjmHdrQ5z12Wi X6hy3MS983Jhd+Ax4icym2ALI3RXtEMmj0LdmnPBaTrVBH4R+jFgEAcHp3a3Xj1xMJ7TeTjaNgZxi xbl4ln6JbGvWDvQDfu4g==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:54118 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1bIVj6-004F1i-Qz; Thu, 30 Jun 2016 06:45:29 +0000 From: Guenter Roeck To: Jean Delvare Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH v3 2/4] hwmon: (lm75) Drop lm75_read_value and lm75_write_value Date: Wed, 29 Jun 2016 23:45:26 -0700 Message-Id: <1467269128-7448-2-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1467269128-7448-1-git-send-email-linux@roeck-us.net> References: <1467269128-7448-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 lm75_read_value and lm75_write_value don't really add any value. Replace with direct smbus access functions. Signed-off-by: Guenter Roeck --- v2, v3: No change drivers/hwmon/lm75.c | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 0df745501a1f..7b18cbd4a5ec 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -89,8 +89,6 @@ struct lm75_data { 2 = hyst */ }; -static int lm75_read_value(struct i2c_client *client, u8 reg); -static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value); static struct lm75_data *lm75_update_device(struct device *dev); @@ -156,7 +154,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, temp = clamp_val(temp, LM75_TEMP_MIN, LM75_TEMP_MAX); data->temp[nr] = DIV_ROUND_CLOSEST(temp << (resolution - 8), 1000) << (16 - resolution); - lm75_write_value(client, LM75_REG_TEMP[nr], data->temp[nr]); + i2c_smbus_write_word_swapped(client, LM75_REG_TEMP[nr], data->temp[nr]); mutex_unlock(&data->update_lock); return count; } @@ -296,7 +294,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) } /* configure as specified */ - status = lm75_read_value(client, LM75_REG_CONF); + status = i2c_smbus_read_byte_data(client, LM75_REG_CONF); if (status < 0) { dev_dbg(dev, "Can't read config? %d\n", status); return status; @@ -305,7 +303,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) new = status & ~clr_mask; new |= set_mask; if (status != new) - lm75_write_value(client, LM75_REG_CONF, new); + i2c_smbus_write_byte_data(client, LM75_REG_CONF, new); devm_add_action(dev, lm75_remove, data); @@ -450,13 +448,13 @@ static int lm75_suspend(struct device *dev) { int status; struct i2c_client *client = to_i2c_client(dev); - status = lm75_read_value(client, LM75_REG_CONF); + status = i2c_smbus_read_byte_data(client, LM75_REG_CONF); if (status < 0) { dev_dbg(&client->dev, "Can't read config? %d\n", status); return status; } status = status | LM75_SHUTDOWN; - lm75_write_value(client, LM75_REG_CONF, status); + i2c_smbus_write_byte_data(client, LM75_REG_CONF, status); return 0; } @@ -464,13 +462,13 @@ static int lm75_resume(struct device *dev) { int status; struct i2c_client *client = to_i2c_client(dev); - status = lm75_read_value(client, LM75_REG_CONF); + status = i2c_smbus_read_byte_data(client, LM75_REG_CONF); if (status < 0) { dev_dbg(&client->dev, "Can't read config? %d\n", status); return status; } status = status & ~LM75_SHUTDOWN; - lm75_write_value(client, LM75_REG_CONF, status); + i2c_smbus_write_byte_data(client, LM75_REG_CONF, status); return 0; } @@ -497,29 +495,6 @@ static struct i2c_driver lm75_driver = { /*-----------------------------------------------------------------------*/ -/* register access */ - -/* - * All registers are word-sized, except for the configuration register. - * LM75 uses a high-byte first convention, which is exactly opposite to - * the SMBus standard. - */ -static int lm75_read_value(struct i2c_client *client, u8 reg) -{ - if (reg == LM75_REG_CONF) - return i2c_smbus_read_byte_data(client, reg); - else - return i2c_smbus_read_word_swapped(client, reg); -} - -static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) -{ - if (reg == LM75_REG_CONF) - return i2c_smbus_write_byte_data(client, reg, value); - else - return i2c_smbus_write_word_swapped(client, reg, value); -} - static struct lm75_data *lm75_update_device(struct device *dev) { struct lm75_data *data = dev_get_drvdata(dev); @@ -536,7 +511,8 @@ static struct lm75_data *lm75_update_device(struct device *dev) for (i = 0; i < ARRAY_SIZE(data->temp); i++) { int status; - status = lm75_read_value(client, LM75_REG_TEMP[i]); + status = i2c_smbus_read_word_swapped(client, + LM75_REG_TEMP[i]); if (unlikely(status < 0)) { dev_dbg(dev, "LM75: Failed to read value: reg %d, error %d\n",