linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: Linux I2C <linux-i2c@vger.kernel.org>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>,
	Christian Fetzer <fetzer.ch@gmail.com>,
	Wolfram Sang <wsa@the-dreams.de>
Subject: [PATCH 3/3] i2c-piix4: Pre-shift the port number
Date: Fri, 29 Jan 2016 10:46:37 +0100	[thread overview]
Message-ID: <20160129104637.582b95ea@endymion.delvare> (raw)
In-Reply-To: <20160129104146.50f06562@endymion.delvare>

Shift the port number at initialization time, so that it is ready to
use at run time. That way we don't have to do it again for every SMBus
transaction.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Christian Fetzer <fetzer.ch@gmail.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/i2c/busses/i2c-piix4.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--- linux-4.5-rc0.orig/drivers/i2c/busses/i2c-piix4.c	2016-01-29 07:57:13.706365999 +0100
+++ linux-4.5-rc0/drivers/i2c/busses/i2c-piix4.c	2016-01-29 10:38:34.720453729 +0100
@@ -158,7 +158,7 @@ struct i2c_piix4_adapdata {
 
 	/* SB800 */
 	bool sb800_main;
-	u8 port;
+	u8 port;		/* Port number, shifted */
 };
 
 static int piix4_setup(struct pci_dev *PIIX4_dev,
@@ -589,8 +589,8 @@ static s32 piix4_access_sb800(struct i2c
 	smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1);
 
 	port = adapdata->port;
-	if ((smba_en_lo & SB800_PIIX4_PORT_IDX_MASK) != (port << 1))
-		outb_p((smba_en_lo & ~SB800_PIIX4_PORT_IDX_MASK) | (port << 1),
+	if ((smba_en_lo & SB800_PIIX4_PORT_IDX_MASK) != port)
+		outb_p((smba_en_lo & ~SB800_PIIX4_PORT_IDX_MASK) | port,
 		       SB800_PIIX4_SMB_IDX + 1);
 
 	retval = piix4_access(adap, addr, flags, read_write,
@@ -676,7 +676,7 @@ static int piix4_add_adapter(struct pci_
 
 	adapdata->smba = smba;
 	adapdata->sb800_main = sb800_main;
-	adapdata->port = port;
+	adapdata->port = port << 1;
 
 	/* set up the sysfs linkage to our parent device */
 	adap->dev.parent = &dev->dev;
@@ -812,7 +812,7 @@ static void piix4_adap_remove(struct i2c
 
 	if (adapdata->smba) {
 		i2c_del_adapter(adap);
-		if (adapdata->port == 0) {
+		if (adapdata->port == (0 << 1)) {
 			release_region(adapdata->smba, SMBIOSIZE);
 			if (adapdata->sb800_main)
 				release_region(SB800_PIIX4_SMB_IDX, 2);

-- 
Jean Delvare
SUSE L3 Support

  parent reply	other threads:[~2016-01-29  9:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-29  9:41 [PATCH 0/3] Improvements to the i2c-piix4 driver Jean Delvare
2016-01-29  9:44 ` [PATCH 1/3] i2c-piix4: Support alternative port selection register Jean Delvare
2016-01-29 10:59   ` Mika Westerberg
2016-01-29 12:04     ` Jean Delvare
2016-02-12 19:27   ` Wolfram Sang
2016-02-13 21:51     ` Jean Delvare
2016-02-14  8:39       ` fetzerch
2016-02-14  9:55         ` Jean Delvare
2016-02-15 17:30       ` Jean Delvare
2016-02-15 17:37         ` Wolfram Sang
2016-02-15 20:52           ` Jean Delvare
2016-01-29  9:45 ` [PATCH 2/3] i2c-piix4: Always use the same type for port Jean Delvare
2016-01-29 10:59   ` Mika Westerberg
2016-02-24 10:40   ` Wolfram Sang
2016-01-29  9:46 ` Jean Delvare [this message]
2016-01-29 11:02   ` [PATCH 3/3] i2c-piix4: Pre-shift the port number Mika Westerberg
2016-01-29 11:09     ` Jean Delvare
2016-02-24 10:42   ` Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160129104637.582b95ea@endymion.delvare \
    --to=jdelvare@suse.de \
    --cc=fetzer.ch@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).