From ca11e0c45956a5fb81d3127e461dd9fbcf83a901 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mathieu=20B=C3=A9rard?= Date: Sat, 9 Sep 2006 22:50:59 +0000 Subject: [PATCH] * Remove autoconf.h include uneeded * Fix code for compilation with old kernel Module now compile cleanly against a 2.6.9 --- acpi.c | 1 + compal.c | 11 +------- compat.h | 73 ++++++++++++++++++++++-------------------------------- ec.c | 10 +------- init.c | 55 +++++++++++++++++++++++++++++++++++++--- nbsmi.c | 11 +------- omnibook.h | 1 - 7 files changed, 85 insertions(+), 77 deletions(-) diff --git a/acpi.c b/acpi.c index c1b3ce3..f8caf23 100644 --- a/acpi.c +++ b/acpi.c @@ -130,6 +130,7 @@ static int omnibook_acpi_get_wireless(const struct omnibook_operation *io_op, un if ((retval = omnibook_acpi_execute(GET_WIRELESS_METHOD,0,&raw_state))) return retval; + dprintk("get_wireless raw_state: %x\n", raw_state); *state = ( raw_state & WLEX_MASK ) ? WIFI_EX : 0; *state |= ( raw_state & WLAT_MASK ) ? WIFI_STA : 0; diff --git a/compal.c b/compal.c index 985feaf..6ca36fc 100644 --- a/compal.c +++ b/compal.c @@ -23,18 +23,9 @@ #include #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) -#include -#define DEFINE_MUTEX(lock) DECLARE_MUTEX(lock) -#define mutex_lock(lock) down(lock) -#define mutex_lock_interruptible(lock) down_interruptible(lock) -#define mutex_unlock(lock) up(lock) -#else -#include -#endif - #include #include "ec.h" +#include "compat.h" /* * ATI's IXP PCI-LPC bridge diff --git a/compat.h b/compat.h index 29ba628..ea06159 100644 --- a/compat.h +++ b/compat.h @@ -1,5 +1,5 @@ /* - * compat.h -- Older kernel (=> 2.6.8) support + * compat.h -- Older kernel (=> 2.6.9) support * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -14,60 +14,30 @@ * Written by Mathieu Bérard , 2006 */ -/* - * For compatibility with kernel older than 2.6.11 - */ - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)) -typedef u32 pm_message_t; -#endif - -static int __init omnibook_probe(struct platform_device *dev); -static int __exit omnibook_remove(struct platform_device *dev); -static int omnibook_suspend(struct platform_device *dev, pm_message_t state); -static int omnibook_resume(struct platform_device *dev); +#include /* - * For compatibility with kernel older than 2.6.15 + * For compatibility with kernel older than 2.6.16 + * Mutex to Semaphore fallback */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) - -#define to_platform_device(x) container_of((x), struct platform_device, dev) - -static int __init compat_omnibook_probe(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - return omnibook_probe(pdev); -} - -static int __exit compat_omnibook_remove(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - return omnibook_remove(pdev); -} - -static int compat_omnibook_suspend(struct device *dev, pm_message_t state, u32 level) -{ - struct platform_device *pdev = to_platform_device(dev); - return omnibook_suspend(pdev, state); -} - -static int compat_omnibook_resume(struct device *dev, u32 level) -{ - struct platform_device *pdev = to_platform_device(dev); - return omnibook_resume(pdev); -} +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) +#include +#define DEFINE_MUTEX(lock) DECLARE_MUTEX(lock) +#define mutex_lock(lock) down(lock) +#define mutex_lock_interruptible(lock) down_interruptible(lock) +#define mutex_unlock(lock) up(lock) +#else +#include #endif - /* * For compatibility with kernel older than 2.6.14 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) -void inline *kzalloc(size_t size, int flags) +static void inline *kzalloc(size_t size, int flags) { void *ret = kmalloc(size, flags); if (ret) @@ -76,6 +46,23 @@ void inline *kzalloc(size_t size, int flags) } #endif +/* + * For compatibility with kernel older than 2.6.11 + */ + +#ifndef DEFINE_SPINLOCK +#define DEFINE_SPINLOCK(s) spinlock_t s = SPIN_LOCK_UNLOCKED +#endif + +/* + * Those kernel don't have ICH7 southbridge pcids + */ + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)) +#define PCI_DEVICE_ID_INTEL_ICH7_0 0x27b8 +#define PCI_DEVICE_ID_INTEL_ICH7_1 0x27b9 +#define PCI_DEVICE_ID_INTEL_ICH7_31 0x27bd +#endif diff --git a/ec.c b/ec.c index 7402398..2f10ff1 100644 --- a/ec.c +++ b/ec.c @@ -26,15 +26,7 @@ #include #include "ec.h" - -/* - * For compatibility with kernel older than 2.6.11 - */ - -#ifndef DEFINE_SPINLOCK -#define DEFINE_SPINLOCK(s) spinlock_t s = SPIN_LOCK_UNLOCKED -#endif - +#include "compat.h" /* * Interrupt control diff --git a/init.c b/init.c index 0e76110..ba08eb1 100644 --- a/init.c +++ b/init.c @@ -22,15 +22,63 @@ #include #include +#include "ec.h" +#include "laptop.h" +#include "compat.h" + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)) #include #else #include #endif -#include "ec.h" -#include "laptop.h" -#include "compat.h" +/* + * For compatibility with kernel older than 2.6.11 + */ + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)) +typedef u32 pm_message_t; +#endif + +static int __init omnibook_probe(struct platform_device *dev); +static int __exit omnibook_remove(struct platform_device *dev); +static int omnibook_suspend(struct platform_device *dev, pm_message_t state); +static int omnibook_resume(struct platform_device *dev); + +/* + * For compatibility with kernel older than 2.6.15 + */ + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)) + +#define to_platform_device(x) container_of((x), struct platform_device, dev) + +static int __init compat_omnibook_probe(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + return omnibook_probe(pdev); +} + +static int __exit compat_omnibook_remove(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + return omnibook_remove(pdev); +} + +static int compat_omnibook_suspend(struct device *dev, pm_message_t state, u32 level) +{ + struct platform_device *pdev = to_platform_device(dev); + return omnibook_suspend(pdev, state); +} + +static int compat_omnibook_resume(struct device *dev, u32 level) +{ + struct platform_device *pdev = to_platform_device(dev); + return omnibook_resume(pdev); +} + +#endif + static struct proc_dir_entry *omnibook_proc_root = NULL; @@ -43,7 +91,6 @@ static int omnibook_userset = 0; /* * The platform_driver interface was added in linux 2.6.15 */ - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)) static struct platform_device *omnibook_device; diff --git a/nbsmi.c b/nbsmi.c index e6f1c56..aabc251 100644 --- a/nbsmi.c +++ b/nbsmi.c @@ -22,22 +22,13 @@ #include "omnibook.h" -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)) -#include -#define DEFINE_MUTEX(lock) DECLARE_MUTEX(lock) -#define mutex_lock(lock) down(lock) -#define mutex_lock_interruptible(lock) down_interruptible(lock) -#define mutex_unlock(lock) up(lock) -#else -#include -#endif - #include #include #include #include #include #include "ec.h" +#include "compat.h" /* * ATI's IXP PCI-LPC bridge diff --git a/omnibook.h b/omnibook.h index da1b4c4..7a91e8d 100644 --- a/omnibook.h +++ b/omnibook.h @@ -18,7 +18,6 @@ #include #include -#include #include /* -- 2.43.5