TODAY = $(shell date +%Y%m%d)
KERNEL = $(shell uname -r | cut -c 1-3)
-CC = gcc
-LD = ld
DEPMOD = depmod -a
RMMOD = modprobe -r
INSMOD = modprobe
#include <linux/config.h>
#include <linux/spinlock.h>
#include <linux/acpi.h>
+#include <linux/version.h>
#include <asm/io.h>
-
#include "ec.h"
+/*
+ * For (dumb) compatibility with kernel older than 2.6.9
+ */
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
+#define ioread8(addr) readb(addr)
+#define iowrite8(val,addr) writeb(val,addr)
+#endif
+
+/*
+ * For compatibility with kernel older than 2.6.11
+ */
+
+#ifndef DEFINE_SPINLOCK
+#define DEFINE_SPINLOCK(s) spinlock_t s = SPIN_LOCK_UNLOCKED
+#endif
+
+
/*
* Interrupt control
*/
+
+
static DEFINE_SPINLOCK(omnibook_ec_lock);
#endif
#include <linux/dmi.h>
+#include <linux/version.h>
static int omnibook_version_read(char *buffer)
{
len +=
sprintf(buffer + len, "Version: %s\n",
dmi_get_system_info(DMI_PRODUCT_VERSION));
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
len +=
sprintf(buffer + len, "Serial Number: %s\n",
dmi_get_system_info(DMI_PRODUCT_SERIAL));
+#endif
len +=
sprintf(buffer + len, "Board Vendor: %s\n",
dmi_get_system_info(DMI_BOARD_VENDOR));
#include <linux/proc_fs.h>
#include <linux/dmi.h>
#include <linux/version.h>
-#include <linux/platform_device.h>
#include <asm/uaccess.h>
-#include "init.h"
-#include "ec.h"
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
+#include <linux/platform_device.h>
+#else
+#include <linux/device.h>
+#endif
+#include "ec.h"
+#include "init.h"
+
static struct proc_dir_entry *omnibook_proc_root = NULL;
int omnibook_ectype = NONE;
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;
static struct platform_driver omnibook_driver = {
},
};
+#else /* 2.6.15 */
+
+static struct device_driver omnibook_driver = {
+ .name = OMNIBOOK_MODULE_NAME,
+ .bus = &platform_bus_type,
+ .probe = compat_omnibook_probe,
+ .remove = compat_omnibook_remove,
+#ifdef CONFIG_PM
+ .suspend = compat_omnibook_suspend,
+ .resume = compat_omnibook_resume,
+#endif
+};
+
+static struct platform_device omnibook_device = {
+ .name = OMNIBOOK_MODULE_NAME,
+};
+
+#endif /* 2.6.15 */
+
+
/* Linked list of all enabled features */
static struct omnibook_feature *omnibook_available_feature;
return -ENOENT;
}
+/*
+ * The platform_driver interface was added in linux 2.6.15
+ */
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
+
retval = platform_driver_register(&omnibook_driver);
- if (retval < 0)
- return retval;
+ if (retval < 0) return retval;
omnibook_device = platform_device_alloc(OMNIBOOK_MODULE_NAME, -1);
if (!omnibook_device) {
platform_driver_unregister(&omnibook_driver);
return -ENOMEM;
}
+
retval = platform_device_add(omnibook_device);
if (retval) {
platform_device_put(omnibook_device);
return retval;
}
+#else /* 2.6.15 */
+
+ retval = driver_register(&omnibook_driver);
+ if (retval < 0) return retval;
+
+ retval = platform_device_register(&omnibook_device);
+
+ if (retval) {
+ driver_unregister(&omnibook_driver);
+ return retval;
+ }
+
+#endif
return 0;
}
static void __exit omnibook_module_cleanup(void)
{
+
+/*
+ * The platform_driver interface was added in linux 2.6.15
+ */
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
platform_device_unregister(omnibook_device);
platform_driver_unregister(&omnibook_driver);
+#else
+ platform_device_unregister(&omnibook_device);
+ driver_unregister(&omnibook_driver);
+#endif
if (omnibook_proc_root)
remove_proc_entry("omnibook", NULL);
* Written by Soós Péter <sp@osb.hu>, 2002-2004
*/
+/*
+ * For compatibility with kernel older than 2.6.11
+ */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
+typedef u32 pm_message_t;
+#endif
-struct omnibook_feature;
-
-static int __init omnibook_init(struct omnibook_feature *feature);
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
+
+
+/*
+ * 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)
+{
+ void *ret = kmalloc(size, flags);
+ if (ret)
+ memset(ret, 0, size);
+ return ret;
+}
+#endif
+
+struct omnibook_feature;
+
+static int __init omnibook_init(struct omnibook_feature *feature);
+
extern struct omnibook_feature ac_feature;
extern struct omnibook_feature apmemu_feature;
extern struct omnibook_feature battery_feature;
extern int omnibook_get_battery_status(int num, struct omnibook_battery_state *battstat);
extern int set_omnibook_param(const char *val, struct kernel_param *kp);
-/* Configuration for standalone compilation */
+/*
+ * Configuration for standalone compilation:
+ * -Register as backlight depends on kernel config
+ * -APM emulation is disabled by default
+ */
#ifdef OMNIBOOK_STANDALONE
#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE