Skip to content

Commit 33f5ccc

Browse files
jdelvareWolfram Sang
authored andcommitted
i2c: piix4: Pre-shift the port number
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 <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 62194e8 commit 33f5ccc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/i2c/busses/i2c-piix4.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ struct i2c_piix4_adapdata {
159159

160160
/* SB800 */
161161
bool sb800_main;
162-
u8 port;
162+
u8 port; /* Port number, shifted */
163163
};
164164

165165
static int piix4_setup(struct pci_dev *PIIX4_dev,
@@ -595,8 +595,8 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
595595
smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1);
596596

597597
port = adapdata->port;
598-
if ((smba_en_lo & SB800_PIIX4_PORT_IDX_MASK) != (port << 1))
599-
outb_p((smba_en_lo & ~SB800_PIIX4_PORT_IDX_MASK) | (port << 1),
598+
if ((smba_en_lo & SB800_PIIX4_PORT_IDX_MASK) != port)
599+
outb_p((smba_en_lo & ~SB800_PIIX4_PORT_IDX_MASK) | port,
600600
SB800_PIIX4_SMB_IDX + 1);
601601

602602
retval = piix4_access(adap, addr, flags, read_write,
@@ -682,7 +682,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
682682

683683
adapdata->smba = smba;
684684
adapdata->sb800_main = sb800_main;
685-
adapdata->port = port;
685+
adapdata->port = port << 1;
686686

687687
/* set up the sysfs linkage to our parent device */
688688
adap->dev.parent = &dev->dev;
@@ -818,7 +818,7 @@ static void piix4_adap_remove(struct i2c_adapter *adap)
818818

819819
if (adapdata->smba) {
820820
i2c_del_adapter(adap);
821-
if (adapdata->port == 0) {
821+
if (adapdata->port == (0 << 1)) {
822822
release_region(adapdata->smba, SMBIOSIZE);
823823
if (adapdata->sb800_main)
824824
release_region(SB800_PIIX4_SMB_IDX, 2);

0 commit comments

Comments
 (0)