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

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

Also some minor whitespace cleanups.
parent 09a3943b
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,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/version.h> #include <linux/version.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -46,8 +48,6 @@ ...@@ -46,8 +48,6 @@
#include <linux/init.h> #include <linux/init.h>
#include <asm/io.h> #include <asm/io.h>
#define DRV_NAME "i2c-amd756"
/* AMD756 SMBus address offsets */ /* AMD756 SMBus address offsets */
#define SMB_ADDR_OFFSET 0xE0 #define SMB_ADDR_OFFSET 0xE0
#define SMB_IOSIZE 16 #define SMB_IOSIZE 16
...@@ -117,20 +117,20 @@ static void amd756_do_pause(unsigned int amount) ...@@ -117,20 +117,20 @@ static void amd756_do_pause(unsigned int amount)
#define GE_ABORT (1 << 5) #define GE_ABORT (1 << 5)
static int amd756_transaction(void) static int amd756_transaction(struct i2c_adapter *adap)
{ {
int temp; int temp;
int result = 0; int result = 0;
int timeout = 0; int timeout = 0;
pr_debug(DRV_NAME dev_dbg(&adap->dev, ": Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, "
": Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n", "DAT=%04x\n", inw_p(SMB_GLOBAL_STATUS),
inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE), inw_p(SMB_GLOBAL_ENABLE), inw_p(SMB_HOST_ADDRESS),
inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA)); inb_p(SMB_HOST_DATA));
/* Make sure the SMBus host is ready to start transmitting */ /* Make sure the SMBus host is ready to start transmitting */
if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) { if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) {
pr_debug(DRV_NAME ": SMBus busy (%04x). Waiting... \n", temp); dev_dbg(&adap->dev, ": SMBus busy (%04x). Waiting... \n", temp);
do { do {
amd756_do_pause(1); amd756_do_pause(1);
temp = inw_p(SMB_GLOBAL_STATUS); temp = inw_p(SMB_GLOBAL_STATUS);
...@@ -138,7 +138,7 @@ static int amd756_transaction(void) ...@@ -138,7 +138,7 @@ static int amd756_transaction(void)
(timeout++ < MAX_TIMEOUT)); (timeout++ < MAX_TIMEOUT));
/* 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) {
pr_debug(DRV_NAME ": Busy wait timeout (%04x)\n", temp); dev_dbg(&adap->dev, ": Busy wait timeout (%04x)\n", temp);
goto abort; goto abort;
} }
timeout = 0; timeout = 0;
...@@ -155,46 +155,46 @@ static int amd756_transaction(void) ...@@ -155,46 +155,46 @@ static int amd756_transaction(void)
/* 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) {
pr_debug(DRV_NAME ": Completion timeout!\n"); dev_dbg(&adap->dev, ": Completion timeout!\n");
goto abort; goto abort;
} }
if (temp & GS_PRERR_STS) { if (temp & GS_PRERR_STS) {
result = -1; result = -1;
pr_debug(DRV_NAME ": SMBus Protocol error (no response)!\n"); dev_dbg(&adap->dev, ": SMBus Protocol error (no response)!\n");
} }
if (temp & GS_COL_STS) { if (temp & GS_COL_STS) {
result = -1; result = -1;
printk(KERN_WARNING DRV_NAME " SMBus collision!\n"); dev_warn(&adap->dev, " SMBus collision!\n");
} }
if (temp & GS_TO_STS) { if (temp & GS_TO_STS) {
result = -1; result = -1;
pr_debug(DRV_NAME ": SMBus protocol timeout!\n"); dev_dbg(&adap->dev, ": SMBus protocol timeout!\n");
} }
if (temp & GS_HCYC_STS) if (temp & GS_HCYC_STS)
pr_debug(DRV_NAME " SMBus protocol success!\n"); dev_dbg(&adap->dev, " SMBus protocol success!\n");
outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS); outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
#ifdef DEBUG #ifdef DEBUG
if (((temp = inw_p(SMB_GLOBAL_STATUS)) & GS_CLEAR_STS) != 0x00) { if (((temp = inw_p(SMB_GLOBAL_STATUS)) & GS_CLEAR_STS) != 0x00) {
pr_debug(DRV_NAME dev_dbg(&adap->dev,
": Failed reset at end of transaction (%04x)\n", temp); ": Failed reset at end of transaction (%04x)\n", temp);
} }
#endif
pr_debug(DRV_NAME dev_dbg(&adap->dev,
": Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n", ": Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n",
inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE), inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE),
inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA)); inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA));
#endif
return result; return result;
abort: abort:
printk(KERN_WARNING DRV_NAME ": Sending abort.\n"); dev_warn(&adap->dev, ": Sending abort.\n");
outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE); outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE);
amd756_do_pause(100); amd756_do_pause(100);
outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS); outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
...@@ -211,7 +211,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr, ...@@ -211,7 +211,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
/** TODO: Should I supporte the 10-bit transfers? */ /** TODO: Should I supporte the 10-bit transfers? */
switch (size) { switch (size) {
case I2C_SMBUS_PROC_CALL: case I2C_SMBUS_PROC_CALL:
pr_debug(DRV_NAME ": I2C_SMBUS_PROC_CALL not supported!\n"); dev_dbg(&adap->dev, ": I2C_SMBUS_PROC_CALL not supported!\n");
/* TODO: Well... It is supported, I'm just not sure what to do here... */ /* TODO: Well... It is supported, I'm just not sure what to do here... */
return -1; return -1;
case I2C_SMBUS_QUICK: case I2C_SMBUS_QUICK:
...@@ -266,7 +266,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr, ...@@ -266,7 +266,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
/* How about enabling interrupts... */ /* How about enabling interrupts... */
outw_p(size & GE_CYC_TYPE_MASK, SMB_GLOBAL_ENABLE); outw_p(size & GE_CYC_TYPE_MASK, SMB_GLOBAL_ENABLE);
if (amd756_transaction()) /* Error in transaction */ if (amd756_transaction(adap)) /* Error in transaction */
return -1; return -1;
if ((read_write == I2C_SMBUS_WRITE) || (size == AMD756_QUICK)) if ((read_write == I2C_SMBUS_WRITE) || (size == AMD756_QUICK))
...@@ -334,7 +334,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev, ...@@ -334,7 +334,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
u8 temp; u8 temp;
if (amd756_ioport) { if (amd756_ioport) {
printk(KERN_ERR DRV_NAME ": Only one device supported. " dev_err(&pdev->dev, ": Only one device supported. "
"(you have a strange motherboard, btw..)\n"); "(you have a strange motherboard, btw..)\n");
return -ENODEV; return -ENODEV;
} }
...@@ -351,7 +351,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev, ...@@ -351,7 +351,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
pci_read_config_byte(pdev, SMBGCFG, &temp); pci_read_config_byte(pdev, SMBGCFG, &temp);
if ((temp & 128) == 0) { if ((temp & 128) == 0) {
printk(KERN_ERR DRV_NAME dev_err(&pdev->dev,
": Error: SMBus controller I/O not enabled!\n"); ": Error: SMBus controller I/O not enabled!\n");
return -ENODEV; return -ENODEV;
} }
...@@ -364,16 +364,14 @@ static int __devinit amd756_probe(struct pci_dev *pdev, ...@@ -364,16 +364,14 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
} }
if (!request_region(amd756_ioport, SMB_IOSIZE, "amd756-smbus")) { if (!request_region(amd756_ioport, SMB_IOSIZE, "amd756-smbus")) {
printk(KERN_ERR DRV_NAME dev_err(&pdev->dev, ": SMB region 0x%x already in use!\n",
": SMB region 0x%x already in use!\n", amd756_ioport); amd756_ioport);
return -ENODEV; return -ENODEV;
} }
#ifdef DEBUG
pci_read_config_byte(pdev, SMBREV, &temp); pci_read_config_byte(pdev, SMBREV, &temp);
printk(KERN_DEBUG DRV_NAME ": SMBREV = 0x%X\n", temp); dev_dbg(&pdev->dev, ": SMBREV = 0x%X\n", temp);
printk(KERN_DEBUG DRV_NAME ": AMD756_smba = 0x%X\n", amd756_ioport); dev_dbg(&pdev->dev, ": AMD756_smba = 0x%X\n", amd756_ioport);
#endif
/* set up the driverfs linkage to our parent device */ /* set up the driverfs linkage to our parent device */
amd756_adapter.dev.parent = &pdev->dev; amd756_adapter.dev.parent = &pdev->dev;
...@@ -383,7 +381,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev, ...@@ -383,7 +381,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
error = i2c_add_adapter(&amd756_adapter); error = i2c_add_adapter(&amd756_adapter);
if (error) { if (error) {
printk(KERN_ERR DRV_NAME dev_err(&pdev->dev,
": Adapter registration failed, module not inserted.\n"); ": Adapter registration failed, module not inserted.\n");
goto out_err; goto out_err;
} }
......
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