From 5ffe4834e5c3347878080bb8f6f1590d4405fed8 Mon Sep 17 00:00:00 2001 From: Frodo Looijaard Date: Sun, 2 May 1999 21:00:24 +0000 Subject: [PATCH] Made i2c-hydra.o 2.0.x kernel compatible git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@442 7894878c-1315-0410-8ee3-d5d059ff63e0 --- kernel/busses/i2c-hydra.c | 26 ++++++++++++++++++++++++-- kernel/include/compat.h | 7 +++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/kernel/busses/i2c-hydra.c b/kernel/busses/i2c-hydra.c index 98957495..be8ae5a6 100644 --- a/kernel/busses/i2c-hydra.c +++ b/kernel/busses/i2c-hydra.c @@ -33,6 +33,12 @@ #include "i2c.h" #include "algo-bit.h" +#include "compat.h" + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,54)) +#include +#endif + /* PCI device */ #define VENDOR PCI_VENDOR_ID_APPLE @@ -128,19 +134,35 @@ struct bit_adapter bit_hydra_ops = { static int find_hydra(void) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,54)) struct pci_dev *dev; +#else + unsigned char bus, devfn; + int res; +#endif + unsigned int base_addr; if (!pci_present()) return -ENODEV; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,54)) dev = pci_find_device(VENDOR, DEVICE, NULL); - if (!dev) { +#else + res = pcibios_find_device(VENDOR,DEVICE,0,&bus, &devfn); + if (res) { +#endif printk("Hydra not found\n"); return -ENODEV; } - hydra_base = (unsigned long)ioremap(dev->base_address[0], 0x100); + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,54)) + base_addr = dev->base_address[0]; +#else + pcibios_read_config_dword(bus, devfn,PCI_BASE_ADDRESS_0,&base_addr); +#endif + hydra_base = (unsigned long)ioremap(base_addr, 0x100); return 0; } diff --git a/kernel/include/compat.h b/kernel/include/compat.h index 1ac33670..a5ba748d 100644 --- a/kernel/include/compat.h +++ b/kernel/include/compat.h @@ -81,5 +81,12 @@ pci_write_config_byte(device,com,res) #endif +/* I hope this is always correct, even for the PPC, but I really think so. + And yes, the kernel version is exactly correct */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)) +#include +#define ioremap vremap +#define iounmap vfree +#endif #endif /* SENSORS_COMPAT_H */