fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / i2c / busses / i2c-amd8111.c
index 7ad6f7e..0fbc718 100644 (file)
@@ -8,7 +8,6 @@
  * the Free Software Foundation version 2.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/kernel.h>
@@ -31,6 +30,8 @@ struct amd_smbus {
        int size;
 };
 
+static struct pci_driver amd8111_driver;
+
 /*
  * AMD PCI control registers definitions.
  */
@@ -67,7 +68,7 @@ struct amd_smbus {
  * ACPI 2.0 chapter 13 access of registers of the EC
  */
 
-unsigned int amd_ec_wait_write(struct amd_smbus *smbus)
+static unsigned int amd_ec_wait_write(struct amd_smbus *smbus)
 {
        int timeout = 500;
 
@@ -82,7 +83,7 @@ unsigned int amd_ec_wait_write(struct amd_smbus *smbus)
        return 0;
 }
 
-unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
+static unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
 {
        int timeout = 500;
 
@@ -97,7 +98,7 @@ unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
        return 0;
 }
 
-unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address, unsigned char *data)
+static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address, unsigned char *data)
 {
        if (amd_ec_wait_write(smbus))
                return -1;
@@ -114,7 +115,7 @@ unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address, unsigne
        return 0;
 }
 
-unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address, unsigned char data)
+static unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address, unsigned char data)
 {
        if (amd_ec_wait_write(smbus))
                return -1;
@@ -174,7 +175,7 @@ unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address, unsign
 #define AMD_SMB_PRTCL_PEC              0x80
 
 
-s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
+static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
                char read_write, u8 command, int size, union i2c_smbus_data * data)
 {
        struct amd_smbus *smbus = adap->algo_data;
@@ -243,7 +244,6 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
                        break;
 
                case I2C_SMBUS_BLOCK_PROC_CALL:
-                       protocol |= pec;
                        len = min_t(u8, data->block[0], 31);
                        amd_ec_write(smbus, AMD_SMB_CMD, command);
                        amd_ec_write(smbus, AMD_SMB_BCNT, len);
@@ -253,13 +253,6 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
                        read_write = I2C_SMBUS_READ;
                        break;
 
-               case I2C_SMBUS_WORD_DATA_PEC:
-               case I2C_SMBUS_BLOCK_DATA_PEC:
-               case I2C_SMBUS_PROC_CALL_PEC:
-               case I2C_SMBUS_BLOCK_PROC_CALL_PEC:
-                       dev_warn(&adap->dev, "Unexpected software PEC transaction %d\n.", size);
-                       return -1;
-
                default:
                        dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
                        return -1;
@@ -276,7 +269,7 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
        }
 
        if (~temp[0] & AMD_SMB_STS_DONE) {
-               i2c_delay(HZ/100);
+               msleep(1);
                amd_ec_read(smbus, AMD_SMB_STS, temp + 0);
        }
 
@@ -315,7 +308,7 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags,
 }
 
 
-u32 amd8111_func(struct i2c_adapter *adapter)
+static u32 amd8111_func(struct i2c_adapter *adapter)
 {
        return  I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA |
                I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA |
@@ -323,19 +316,19 @@ u32 amd8111_func(struct i2c_adapter *adapter)
                I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_HWPEC_CALC;
 }
 
-static struct i2c_algorithm smbus_algorithm = {
-       .name = "Non-I2C SMBus 2.0 adapter",
-       .id = I2C_ALGO_SMBUS,
+static const struct i2c_algorithm smbus_algorithm = {
        .smbus_xfer = amd8111_access,
        .functionality = amd8111_func,
 };
 
 
 static struct pci_device_id amd8111_ids[] = {
-       { 0x1022, 0x746a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS2) },
        { 0, }
 };
 
+MODULE_DEVICE_TABLE (pci, amd8111_ids);
+
 static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
        struct amd_smbus *smbus;
@@ -344,22 +337,21 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
        if (~pci_resource_flags(dev, 0) & IORESOURCE_IO)
                return -ENODEV;
 
-       smbus = kmalloc(sizeof(struct amd_smbus), GFP_KERNEL);
+       smbus = kzalloc(sizeof(struct amd_smbus), GFP_KERNEL);
        if (!smbus)
                return -ENOMEM;
-       memset(smbus, 0, sizeof(struct amd_smbus));
 
        smbus->dev = dev;
        smbus->base = pci_resource_start(dev, 0);
        smbus->size = pci_resource_len(dev, 0);
 
-       if (!request_region(smbus->base, smbus->size, "amd8111 SMBus 2.0"))
+       if (!request_region(smbus->base, smbus->size, amd8111_driver.name))
                goto out_kfree;
 
        smbus->adapter.owner = THIS_MODULE;
        snprintf(smbus->adapter.name, I2C_NAME_SIZE,
                "SMBus2 AMD8111 adapter at %04x", smbus->base);
-       smbus->adapter.class = I2C_ADAP_CLASS_SMBUS;
+       smbus->adapter.class = I2C_CLASS_HWMON;
        smbus->adapter.algo = &smbus_algorithm;
        smbus->adapter.algo_data = smbus;
 
@@ -392,7 +384,7 @@ static void __devexit amd8111_remove(struct pci_dev *dev)
 }
 
 static struct pci_driver amd8111_driver = {
-       .name           = "amd8111 smbus 2",
+       .name           = "amd8111_smbus2",
        .id_table       = amd8111_ids,
        .probe          = amd8111_probe,
        .remove         = __devexit_p(amd8111_remove),
@@ -400,7 +392,7 @@ static struct pci_driver amd8111_driver = {
 
 static int __init i2c_amd8111_init(void)
 {
-       return pci_module_init(&amd8111_driver);
+       return pci_register_driver(&amd8111_driver);
 }