Skip to content

Commit aca9fa0

Browse files
committed
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c bugfixes from Wolfram Sang: "Two bugfixes (proper IO mapping and use of mutex) for a driver feature we introduced in this cycle" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: piix4: Request the SMBUS semaphore inside the mutex i2c: piix4: Fix request_region size
2 parents fc6f41b + bbb27fc commit aca9fa0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/i2c/busses/i2c-piix4.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#define SMBSLVDAT (0xC + piix4_smba)
5959

6060
/* count for request_region */
61-
#define SMBIOSIZE 8
61+
#define SMBIOSIZE 9
6262

6363
/* PCI Address Constants */
6464
#define SMBBA 0x090
@@ -592,6 +592,8 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
592592
u8 port;
593593
int retval;
594594

595+
mutex_lock(&piix4_mutex_sb800);
596+
595597
/* Request the SMBUS semaphore, avoid conflicts with the IMC */
596598
smbslvcnt = inb_p(SMBSLVCNT);
597599
do {
@@ -605,10 +607,10 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
605607
usleep_range(1000, 2000);
606608
} while (--retries);
607609
/* SMBus is still owned by the IMC, we give up */
608-
if (!retries)
610+
if (!retries) {
611+
mutex_unlock(&piix4_mutex_sb800);
609612
return -EBUSY;
610-
611-
mutex_lock(&piix4_mutex_sb800);
613+
}
612614

613615
outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX);
614616
smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1);
@@ -623,11 +625,11 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
623625

624626
outb_p(smba_en_lo, SB800_PIIX4_SMB_IDX + 1);
625627

626-
mutex_unlock(&piix4_mutex_sb800);
627-
628628
/* Release the semaphore */
629629
outb_p(smbslvcnt | 0x20, SMBSLVCNT);
630630

631+
mutex_unlock(&piix4_mutex_sb800);
632+
631633
return retval;
632634
}
633635

0 commit comments

Comments
 (0)