Commit aeb7a16a authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] i2c i2c-piix4: remove #ifdefs and fix all printk() to use dev_*().

parent ee565939
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
Note: we assume there can only be one device, with one SMBus interface. Note: we assume there can only be one device, with one SMBus interface.
*/ */
/* #define DEBUG 1 */
#include <linux/module.h> #include <linux/module.h>
#include <linux/config.h> #include <linux/config.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -102,6 +104,7 @@ static int piix4_transaction(void); ...@@ -102,6 +104,7 @@ static int piix4_transaction(void);
static unsigned short piix4_smba = 0; static unsigned short piix4_smba = 0;
static struct i2c_adapter piix4_adapter;
/* /*
* Get DMI information. * Get DMI information.
...@@ -125,15 +128,14 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id ...@@ -125,15 +128,14 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id
if (PCI_FUNC(PIIX4_dev->devfn) != id->driver_data) if (PCI_FUNC(PIIX4_dev->devfn) != id->driver_data)
return -ENODEV; return -ENODEV;
printk(KERN_INFO "i2c-piix4.o: Found %s device\n", PIIX4_dev->dev.name); dev_info(&PIIX4_dev->dev, "Found %s device\n", PIIX4_dev->dev.name);
if(ibm_dmi_probe()) { if(ibm_dmi_probe()) {
printk dev_err(&PIIX4_dev->dev, "IBM Laptop detected; this module "
(KERN_ERR "i2c-piix4.o: IBM Laptop detected; this module may corrupt\n"); "may corrupt your serial eeprom! Refusing to load "
printk "module!\n");
(KERN_ERR " your serial eeprom! Refusing to load module!\n"); error_return = -EPERM;
error_return = -EPERM; goto END;
goto END;
} }
/* Determine the address of the SMBus areas */ /* Determine the address of the SMBus areas */
...@@ -144,15 +146,16 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id ...@@ -144,15 +146,16 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id
pci_read_config_word(PIIX4_dev, SMBBA, &piix4_smba); pci_read_config_word(PIIX4_dev, SMBBA, &piix4_smba);
piix4_smba &= 0xfff0; piix4_smba &= 0xfff0;
if(piix4_smba == 0) { if(piix4_smba == 0) {
printk(KERN_ERR "i2c-piix4.o: SMB base address uninitialized - upgrade BIOS or use force_addr=0xaddr\n"); dev_err(&PIIX4_dev->dev, "SMB base address "
"uninitialized - upgrade BIOS or use "
"force_addr=0xaddr\n");
return -ENODEV; return -ENODEV;
} }
} }
if (!request_region(piix4_smba, 8, "piix4-smbus")) { if (!request_region(piix4_smba, 8, "piix4-smbus")) {
printk dev_err(&PIIX4_dev->dev, "SMB region 0x%x already in use!\n",
(KERN_ERR "i2c-piix4.o: SMB region 0x%x already in use!\n", piix4_smba);
piix4_smba);
error_return = -ENODEV; error_return = -ENODEV;
goto END; goto END;
} }
...@@ -164,9 +167,8 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id ...@@ -164,9 +167,8 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id
pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp & 0xfe); pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp & 0xfe);
pci_write_config_word(PIIX4_dev, SMBBA, piix4_smba); pci_write_config_word(PIIX4_dev, SMBBA, piix4_smba);
pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp | 0x01); pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp | 0x01);
printk dev_info(&PIIX4_dev->dev, "WARNING: SMBus interface set to "
(KERN_INFO "i2c-piix4.o: WARNING: SMBus interface set to new " "new address %04x!\n", piix4_smba);
"address %04x!\n", piix4_smba);
} else if ((temp & 1) == 0) { } else if ((temp & 1) == 0) {
if (force) { if (force) {
/* This should never need to be done, but has been noted that /* This should never need to be done, but has been noted that
...@@ -177,33 +179,28 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id ...@@ -177,33 +179,28 @@ static int piix4_setup(struct pci_dev *PIIX4_dev, const struct pci_device_id *id
resorting to this. */ resorting to this. */
pci_write_config_byte(PIIX4_dev, SMBHSTCFG, pci_write_config_byte(PIIX4_dev, SMBHSTCFG,
temp | 1); temp | 1);
printk dev_printk(KERN_NOTICE, &PIIX4_dev->dev,
(KERN_NOTICE "i2c-piix4.o: WARNING: SMBus interface has been FORCEFULLY " "WARNING: SMBus interface has been "
"ENABLED!\n"); "FORCEFULLY ENABLED!\n");
} else { } else {
printk dev_err(&PIIX4_dev->dev,
(KERN_ERR "i2c-piix4.o: Host SMBus controller not enabled!\n"); "Host SMBus controller not enabled!\n");
error_return = -ENODEV; error_return = -ENODEV;
goto END; goto END;
} }
} }
#ifdef DEBUG
if ((temp & 0x0E) == 8) if ((temp & 0x0E) == 8)
printk dev_dbg(&PIIX4_dev->dev, "Using Interrupt 9 for SMBus.\n");
(KERN_DEBUG "i2c-piix4.o: Using Interrupt 9 for SMBus.\n");
else if ((temp & 0x0E) == 0) else if ((temp & 0x0E) == 0)
printk dev_dbg(&PIIX4_dev->dev, "Using Interrupt SMI# for SMBus.\n");
(KERN_DEBUG "i2c-piix4.o: Using Interrupt SMI# for SMBus.\n");
else else
printk dev_err(&PIIX4_dev->dev, "Illegal Interrupt configuration "
(KERN_ERR "i2c-piix4.o: Illegal Interrupt configuration (or code out " "(or code out of date)!\n");
"of date)!\n");
pci_read_config_byte(PIIX4_dev, SMBREV, &temp); pci_read_config_byte(PIIX4_dev, SMBREV, &temp);
printk(KERN_DEBUG "i2c-piix4.o: SMBREV = 0x%X\n", temp); dev_dbg(&PIIX4_dev->dev, "SMBREV = 0x%X\n", temp);
printk(KERN_DEBUG "i2c-piix4.o: SMBA = 0x%X\n", piix4_smba); dev_dbg(&PIIX4_dev->dev, "SMBA = 0x%X\n", piix4_smba);
#endif /* DEBUG */
END: END:
return error_return; return error_return;
...@@ -224,29 +221,21 @@ static int piix4_transaction(void) ...@@ -224,29 +221,21 @@ static int piix4_transaction(void)
int result = 0; int result = 0;
int timeout = 0; int timeout = 0;
#ifdef DEBUG dev_dbg(&piix4_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, "
printk "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
(KERN_DEBUG "i2c-piix4.o: Transaction (pre): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, " inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
"DAT1=%02x\n", inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTDAT1));
inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1));
#endif
/* Make sure the SMBus host is ready to start transmitting */ /* Make sure the SMBus host is ready to start transmitting */
if ((temp = inb_p(SMBHSTSTS)) != 0x00) { if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
#ifdef DEBUG dev_dbg(&piix4_adapter.dev, "SMBus busy (%02x). "
printk(KERN_DEBUG "i2c-piix4.o: SMBus busy (%02x). Resetting... \n", "Resetting... \n", temp);
temp);
#endif
outb_p(temp, SMBHSTSTS); outb_p(temp, SMBHSTSTS);
if ((temp = inb_p(SMBHSTSTS)) != 0x00) { if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
#ifdef DEBUG dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp);
printk(KERN_ERR "i2c-piix4.o: Failed! (%02x)\n", temp);
#endif
return -1; return -1;
} else { } else {
#ifdef DEBUG dev_dbg(&piix4_adapter.dev, "Successfull!\n");
printk(KERN_DEBUG "i2c-piix4.o: Successfull!\n");
#endif
} }
} }
...@@ -259,50 +248,40 @@ static int piix4_transaction(void) ...@@ -259,50 +248,40 @@ static int piix4_transaction(void)
temp = inb_p(SMBHSTSTS); temp = inb_p(SMBHSTSTS);
} while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT)); } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
#ifdef DEBUG
/* If the SMBus is still busy, we give up */ /* If the SMBus is still busy, we give up */
if (timeout >= MAX_TIMEOUT) { if (timeout >= MAX_TIMEOUT) {
printk(KERN_ERR "i2c-piix4.o: SMBus Timeout!\n"); dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
result = -1; result = -1;
} }
#endif
if (temp & 0x10) { if (temp & 0x10) {
result = -1; result = -1;
#ifdef DEBUG dev_err(&piix4_adapter.dev, "Error: Failed bus transaction\n");
printk(KERN_ERR "i2c-piix4.o: Error: Failed bus transaction\n");
#endif
} }
if (temp & 0x08) { if (temp & 0x08) {
result = -1; result = -1;
printk dev_dbg(&piix4_adapter.dev, "Bus collision! SMBus may be "
(KERN_ERR "i2c-piix4.o: Bus collision! SMBus may be locked until next hard\n" "locked until next hard reset. (sorry!)\n");
"reset. (sorry!)\n");
/* Clock stops and slave is stuck in mid-transmission */ /* Clock stops and slave is stuck in mid-transmission */
} }
if (temp & 0x04) { if (temp & 0x04) {
result = -1; result = -1;
#ifdef DEBUG dev_err(&piix4_adapter.dev, "Error: no response!\n");
printk(KERN_ERR "i2c-piix4.o: Error: no response!\n");
#endif
} }
if (inb_p(SMBHSTSTS) != 0x00) if (inb_p(SMBHSTSTS) != 0x00)
outb_p(inb(SMBHSTSTS), SMBHSTSTS); outb_p(inb(SMBHSTSTS), SMBHSTSTS);
#ifdef DEBUG
if ((temp = inb_p(SMBHSTSTS)) != 0x00) { if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
printk dev_err(&piix4_adapter.dev, "Failed reset at end of "
(KERN_ERR "i2c-piix4.o: Failed reset at end of transaction (%02x)\n", "transaction (%02x)\n", temp);
temp);
} }
printk dev_dbg(&piix4_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, "
(KERN_DEBUG "i2c-piix4.o: Transaction (post): CNT=%02x, CMD=%02x, ADD=%02x, " "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
"DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1)); inb_p(SMBHSTDAT1));
#endif
return result; return result;
} }
...@@ -315,8 +294,7 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr, ...@@ -315,8 +294,7 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
switch (size) { switch (size) {
case I2C_SMBUS_PROC_CALL: case I2C_SMBUS_PROC_CALL:
printk dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
(KERN_ERR "i2c-piix4.o: I2C_SMBUS_PROC_CALL not supported!\n");
return -1; return -1;
case I2C_SMBUS_QUICK: case I2C_SMBUS_QUICK:
outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
...@@ -496,7 +474,7 @@ static struct pci_driver piix4_driver = { ...@@ -496,7 +474,7 @@ static struct pci_driver piix4_driver = {
static int __init i2c_piix4_init(void) static int __init i2c_piix4_init(void)
{ {
printk("i2c-piix4.o version %s (%s)\n", I2C_VERSION, I2C_DATE); printk(KERN_INFO "i2c-piix4 version %s (%s)\n", I2C_VERSION, I2C_DATE);
return pci_module_init(&piix4_driver); return pci_module_init(&piix4_driver);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment