mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-12-04 21:58:18 +00:00
compile fixes for i2c-amd8111.c, and add support in mkpatch.
Patch from
Vojtech Pavlik <vojtech@suse.cz>
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1658 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
01e6b327ed
commit
3467ff5106
4 files changed
+105
-14
No files matched your search
@@ -40,12 +40,9 @@ endif
|
||||
ifneq ($(shell if grep -q '^CONFIG_I2C_AMD756=y' $(LINUX)/.config; then echo 1; fi),1)
|
||||
KERNELBUSSESTARGETS += $(MODULE_DIR)/i2c-amd756.o
|
||||
endif
|
||||
# Should also work for CONFIG_X86 but this is the easiest way to prevent compilation in 2.2 kernels...
|
||||
ifeq ($(shell if grep -q '^CONFIG_X86_64=' $(LINUX)/.config; then echo 1; fi),1)
|
||||
ifneq ($(shell if grep -q '^CONFIG_I2C_AMD8111=y' $(LINUX)/.config; then echo 1; fi),1)
|
||||
KERNELBUSSESTARGETS += $(MODULE_DIR)/i2c-amd8111.o
|
||||
endif
|
||||
endif
|
||||
ifneq ($(shell if grep -q '^CONFIG_I2C_HYDRA=y' $(LINUX)/.config; then echo 1; fi),1)
|
||||
KERNELBUSSESTARGETS += $(MODULE_DIR)/i2c-hydra.o
|
||||
endif
|
||||
|
||||
@@ -25,7 +25,31 @@
|
||||
#error Your i2c is too old - i2c-2.7.0 or greater required!
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
|
||||
#define min_t(t, x, y) (((x)<(y))?(x):(y))
|
||||
#define __devinit
|
||||
#define __devexit
|
||||
#define __devinitdata
|
||||
struct pci_device_id {
|
||||
unsigned int vendor, device;
|
||||
unsigned int subvendor, subdevice;
|
||||
unsigned int class, class_mask;
|
||||
unsigned long driver_data;
|
||||
};
|
||||
struct pci_driver {
|
||||
struct list_head node;
|
||||
char *name;
|
||||
const struct pci_device_id *id_table;
|
||||
int (*probe)(struct pci_dev *dev, const struct pci_device_id *id);
|
||||
void (*remove)(struct pci_dev *dev);
|
||||
};
|
||||
#define PCI_ANY_ID 0xffff
|
||||
#define IORESOURCE_IO 0x00000100
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_LICENSE
|
||||
MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
MODULE_AUTHOR ("Vojtech Pavlik <vojtech@suse.cz>");
|
||||
MODULE_DESCRIPTION("AMD8111 SMBus 2.0 driver");
|
||||
|
||||
@@ -359,7 +383,7 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
|
||||
if (~pci_resource_flags(dev, 0) & IORESOURCE_IO)
|
||||
return -1;
|
||||
|
||||
if (!(smbus = kmalloc(sizeof(struct amd_smbus), GFP_KERNEL)))
|
||||
if (!(smbus = (void*)kmalloc(sizeof(struct amd_smbus), GFP_KERNEL)))
|
||||
return -1;
|
||||
memset(smbus, 0, sizeof(struct amd_smbus));
|
||||
|
||||
@@ -368,10 +392,18 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
|
||||
smbus->base = pci_resource_start(dev, 0);
|
||||
smbus->size = pci_resource_len(dev, 0);
|
||||
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,14)
|
||||
if (!request_region(smbus->base, smbus->size, "amd8111 SMBus 2.0")) {
|
||||
kfree(smbus);
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (check_region(smbus->base, smbus->size) < 0) {
|
||||
kfree(smbus);
|
||||
return -1;
|
||||
}
|
||||
request_region(smbus->base, smbus->size, "amd8111 SMBus 2.0");
|
||||
#endif
|
||||
|
||||
sprintf(smbus->adapter.name, "SMBus2 AMD8111 adapter at %04x", smbus->base);
|
||||
smbus->adapter.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD8111;
|
||||
@@ -389,13 +421,17 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
|
||||
|
||||
pci_write_config_dword(smbus->dev, AMD_PCI_MISC, 0);
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
|
||||
printk(KERN_INFO "i2c-amd8111.c: AMD8111 SMBus 2.0 adapter at %#x\n", smbus->base);
|
||||
#else
|
||||
printk(KERN_INFO "i2c-amd8111.c: AMD8111 SMBus 2.0 adapter at pci%s\n", dev->slot_name);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __devexit amd8111_remove(struct pci_dev *dev)
|
||||
{
|
||||
struct amd_smbus *smbus = pci_get_drvdata(dev);
|
||||
struct amd_smbus *smbus = (void*) pci_get_drvdata(dev);
|
||||
if (i2c_del_adapter(&smbus->adapter)) {
|
||||
printk(KERN_WARNING "i2c-amd8111.c: Failed to unregister adapter.\n");
|
||||
return;
|
||||
@@ -408,6 +444,43 @@ static struct pci_device_id amd8111_id_table[] __devinitdata =
|
||||
{{ 0x1022, 0x746a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
|
||||
{ 0 }};
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
|
||||
|
||||
static struct pci_dev *amd8111_devs[8] = { NULL, /* ... */ };
|
||||
static int amd8111_devcnt = 0;
|
||||
|
||||
int i2c_amd_8111_init(void)
|
||||
{
|
||||
struct pci_dev *pci;
|
||||
struct pci_device_id *id;
|
||||
int found = 0;
|
||||
|
||||
for (id = amd8111_id_table; id->vendor; id++) {
|
||||
pci = NULL;
|
||||
while ((pci = pci_find_device(id->vendor, id->device, pci)))
|
||||
if (amd8111_devcnt < 8 && !amd8111_probe(pci, id))
|
||||
amd8111_devs[amd8111_devcnt++] = pci;
|
||||
}
|
||||
|
||||
return found ? 0 : -ENODEV;
|
||||
}
|
||||
|
||||
#ifdef MODULE
|
||||
int init_module(void)
|
||||
{
|
||||
return i2c_amd8111_init();
|
||||
}
|
||||
|
||||
int cleanup_module(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < amd8111_devcnt; i++)
|
||||
amd8111_remove(amd8111_devs[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
static struct pci_driver amd8111_driver = {
|
||||
.name = "amd8111 smbus 2.0",
|
||||
.id_table = amd8111_id_table,
|
||||
@@ -427,3 +500,5 @@ void __exit amd8111_exit(void)
|
||||
|
||||
module_init(amd8111_init);
|
||||
module_exit(amd8111_exit);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user