From patchwork Tue Jan 19 17:09:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 59994 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2727416lbb; Tue, 19 Jan 2016 10:10:23 -0800 (PST) X-Received: by 10.98.69.143 with SMTP id n15mr46657732pfi.104.1453227023511; Tue, 19 Jan 2016 10:10:23 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13si48990938pfi.234.2016.01.19.10.10.23; Tue, 19 Jan 2016 10:10:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932974AbcASSKJ (ORCPT + 1 other); Tue, 19 Jan 2016 13:10:09 -0500 Received: from vms173017pub.verizon.net ([206.46.173.17]:61026 "EHLO vms173017pub.verizon.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932952AbcASSKH (ORCPT ); Tue, 19 Jan 2016 13:10:07 -0500 X-Greylist: delayed 3603 seconds by postgrey-1.27 at vger.kernel.org; Tue, 19 Jan 2016 13:10:07 EST Received: from serve.minyard.net ([173.57.176.17]) by vms173017.mailsrvcs.net (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014)) with ESMTPA id <0O1700L7JMC4MP70@vms173017.mailsrvcs.net> for linux-i2c@vger.kernel.org; Tue, 19 Jan 2016 11:09:45 -0600 (CST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=MtGvkDue c=1 sm=1 tr=0 a=bXmWQgKa9n63w7XTPFb8JQ==:117 a=N54-gffFAAAA:8 a=HL3alpDKAAAA:8 a=oR5dmqMzAAAA:8 a=7aQ_Q-yQQ-AA:10 a=fk1lIlRQAAAA:8 a=lEo0tYseRQYpYd4nq5gA:9 Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 2062A21AD; Tue, 19 Jan 2016 11:09:40 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 1E80330076D; Tue, 19 Jan 2016 11:09:39 -0600 (CST) From: minyard@acm.org To: Jean Delvare , linux-i2c@vger.kernel.org Cc: Corey Minyard Subject: [PATCH 2/5] i2c-i801: Move hostcfg set/reset to i801_access() Date: Tue, 19 Jan 2016 11:09:34 -0600 Message-id: <1453223377-20608-3-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.5.0 In-reply-to: <1453223377-20608-1-git-send-email-minyard@acm.org> References: <1453223377-20608-1-git-send-email-minyard@acm.org> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Corey Minyard The HSTCFG register save/restore was done in i2c_block_transaction, but all the checks were already done in i801_access, so move it into those checks. Signed-off-by: Corey Minyard --- drivers/i2c/busses/i2c-i801.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 62cf1e5..9143fcf 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -652,20 +652,6 @@ static int i801_block_transaction(struct i801_priv *priv, int command, int hwpec) { int result = 0; - unsigned char hostc; - - if (command == I2C_SMBUS_I2C_BLOCK_DATA) { - if (read_write == I2C_SMBUS_WRITE) { - /* set I2C_EN bit in configuration register */ - pci_read_config_byte(priv->pci_dev, SMBHSTCFG, &hostc); - pci_write_config_byte(priv->pci_dev, SMBHSTCFG, - hostc | SMBHSTCFG_I2C_EN); - } else if (!(priv->features & FEATURE_I2C_BLOCK_READ)) { - dev_err(&priv->pci_dev->dev, - "I2C block read is unsupported!\n"); - return -EOPNOTSUPP; - } - } if (read_write == I2C_SMBUS_WRITE || command == I2C_SMBUS_I2C_BLOCK_DATA) { @@ -692,11 +678,6 @@ static int i801_block_transaction(struct i801_priv *priv, read_write, command); - if (command == I2C_SMBUS_I2C_BLOCK_DATA - && read_write == I2C_SMBUS_WRITE) { - /* restore saved configuration register value */ - pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc); - } return result; } @@ -710,6 +691,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, int ret, xact = 0; struct i801_priv *priv = i2c_get_adapdata(adap); int result; + int hostc = -1; hwpec = (priv->features & FEATURE_SMBUS_PEC) && (flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK @@ -757,9 +739,19 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, * bit should be cleared here, even when reading */ outb_p((addr & 0x7f) << 1, SMBHSTADD(priv)); if (read_write == I2C_SMBUS_READ) { + unsigned char thostc; /* NB: page 240 of ICH5 datasheet also shows * that DATA1 is the cmd field when reading */ outb_p(command, SMBHSTDAT1(priv)); + /* set I2C_EN bit in configuration register */ + pci_read_config_byte(priv->pci_dev, SMBHSTCFG, &thostc); + pci_write_config_byte(priv->pci_dev, SMBHSTCFG, + thostc | SMBHSTCFG_I2C_EN); + hostc = thostc; + } else if (!(priv->features & FEATURE_I2C_BLOCK_READ)) { + dev_err(&priv->pci_dev->dev, + "I2C block read is unsupported!\n"); + return -EOPNOTSUPP; } else outb_p(command, SMBHSTCMD(priv)); block = 1; @@ -795,6 +787,9 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, outb_p(inb_p(SMBAUXCTL(priv)) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), SMBAUXCTL(priv)); + if (hostc >= 0) + pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc); + if (block) return ret; if (ret)