From patchwork Fri Jun 24 00:49:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9196259 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 9B6B46077D for ; Fri, 24 Jun 2016 00:50:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B4E72844E for ; Fri, 24 Jun 2016 00:50:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 805EF2847F; Fri, 24 Jun 2016 00:50:15 +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 188CD2842E for ; Fri, 24 Jun 2016 00:50:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751384AbcFXAuO (ORCPT ); Thu, 23 Jun 2016 20:50:14 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:53757 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751010AbcFXAuO (ORCPT ); Thu, 23 Jun 2016 20:50:14 -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=gP3C7gTJKxni70gl+w6BTb5Mf+2ByAhW0NfDk1pyi5E=; b=qzfrAp7Lop6tN/ 7QDkxoIZ70Y7AfAL8CFiEkYst/SEMke0ak/MmPN73hu9XAr8IFJaVXYN8doFiwfmjG3WpKvIdLHKX xLEJqt0i5fxnzHIsfZy5ufmUb/f2s4ruS9R74Xl1yOqMARco7+ctqppc6g69susi3pdbUZgtHwQpS vZsD85/adKRZCMGa3/BIPg8ncF3zmgb8Keb0KNrfJTPnAOTJhjxaiSnHRSaaEgT/0r/swAhE8g+yx i6E5ZQG4xelGxyR1BKfE9eBe9QObFZ0dy3Hf8jMApJsl7BWJqabwpNm4v2ULzjXe0aHkqcdHdaauw zgimhGpjRwKXzuca97Sg==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:56430 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1bGFJu-004GuO-14; Fri, 24 Jun 2016 00:50:06 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 2/4] hwmon: (lm75) Drop lm75_read_value and lm75_write_value Date: Thu, 23 Jun 2016 17:49:59 -0700 Message-Id: <1466729401-27567-2-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1466729401-27567-1-git-send-email-linux@roeck-us.net> References: <1466729401-27567-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 --- 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",