* the Free Software Foundation version 2.
*/
-#include <linux/config.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/kernel.h>
int size;
};
+static struct pci_driver amd8111_driver;
+
/*
* AMD PCI control registers definitions.
*/
* 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;
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;
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;
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;
#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;
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);
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;
}
-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 |
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;
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;
}
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),
static int __init i2c_amd8111_init(void)
{
- return pci_module_init(&amd8111_driver);
+ return pci_register_driver(&amd8111_driver);
}