From d5ede7daf09b9cdf9c2d637675c861823099c3bc Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sat, 28 Jan 2006 17:36:15 +0000 Subject: [PATCH] Added some more compatibility wrappers for 2.4 kernels. --- include/linux/kernel.h | 34 ++++++++++++ include/linux/mod_devicetable.h | 40 ++++++++++++++ include/linux/pnp.h | 98 +++++++++++++++++++++++++++++++++ include/linux/usb.h | 7 ++- 4 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 include/linux/kernel.h create mode 100644 include/linux/mod_devicetable.h create mode 100644 include/linux/pnp.h diff --git a/include/linux/kernel.h b/include/linux/kernel.h new file mode 100644 index 00000000..e13f5f85 --- /dev/null +++ b/include/linux/kernel.h @@ -0,0 +1,34 @@ +/* + Kernel compatibility header file + + 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 Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef _KERNEL_COMPAT_H +#define _KERNEL_COMPAT_H + +#include_next +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + +#endif + +#endif // _KERNEL_COMPAT_H diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h new file mode 100644 index 00000000..0c4965f8 --- /dev/null +++ b/include/linux/mod_devicetable.h @@ -0,0 +1,40 @@ +/* + Kernel compatibility header file + + 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 Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef _MOD_DEVICETABLE_COMPAT_H +#define _MOD_DEVICETABLE_COMPAT_H + +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + +#define PNP_ID_LEN 8 + +typedef unsigned long kernel_ulong_t; + +struct pnp_device_id { + __u8 id[PNP_ID_LEN]; + kernel_ulong_t driver_data; +}; + +#else +#include_next +#endif + +#endif // _MOD_DEVICETABLE_COMPAT_H diff --git a/include/linux/pnp.h b/include/linux/pnp.h new file mode 100644 index 00000000..d805f0b6 --- /dev/null +++ b/include/linux/pnp.h @@ -0,0 +1,98 @@ +/* + Kernel compatibility header file + + portions of this file were copied from the Linux kernel source file + include/linux/pnp.h (copyright by Adam Belay ). + + 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 Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef _PNP_COMPAT_H +#define _PNP_COMPAT_H + +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + +#include +#include + +struct pnp_protocol; +struct pnp_dev; +struct pnp_card; +struct pnp_irq; +struct pnp_dma; +struct pnp_port; +struct pnp_mem; +struct pnp_resource_table; +struct pnp_id; +struct pnp_card_link; +struct pnp_card_driver; +struct pnp_driver { + char * name; + const struct pnp_device_id *id_table; + unsigned int flags; + int (*probe) (struct pnp_dev *dev, const struct pnp_device_id *dev_id); + void (*remove) (struct pnp_dev *dev); + struct device_driver driver; +}; + +/* device management */ +static inline int pnp_register_protocol(struct pnp_protocol *protocol) { return -ENODEV; } +static inline void pnp_unregister_protocol(struct pnp_protocol *protocol) { } +static inline int pnp_init_device(struct pnp_dev *dev) { return -ENODEV; } +static inline int pnp_add_device(struct pnp_dev *dev) { return -ENODEV; } +static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; } +static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { ; } + +/* multidevice card support */ +static inline int pnp_add_card(struct pnp_card *card) { return -ENODEV; } +static inline void pnp_remove_card(struct pnp_card *card) { ; } +static inline int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) { return -ENODEV; } +static inline void pnp_remove_card_device(struct pnp_dev *dev) { ; } +static inline int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card) { return -ENODEV; } +static inline struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char * id, struct pnp_dev * from) { return NULL; } +static inline void pnp_release_card_device(struct pnp_dev * dev) { ; } +static inline int pnp_register_card_driver(struct pnp_card_driver * drv) { return -ENODEV; } +static inline void pnp_unregister_card_driver(struct pnp_card_driver * drv) { ; } + +/* resource management */ +static inline struct pnp_option * pnp_register_independent_option(struct pnp_dev *dev) { return NULL; } +static inline struct pnp_option * pnp_register_dependent_option(struct pnp_dev *dev, int priority) { return NULL; } +static inline int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data) { return -ENODEV; } +static inline int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) { return -ENODEV; } +static inline int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) { return -ENODEV; } +static inline int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data) { return -ENODEV; } +static inline void pnp_init_resource_table(struct pnp_resource_table *table) { } +static inline int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode) { return -ENODEV; } +static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; } +static inline int pnp_validate_config(struct pnp_dev *dev) { return -ENODEV; } +static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; } +static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; } +static inline void pnp_resource_change(struct resource *resource, unsigned long start, unsigned long size) { } + +/* protocol helpers */ +static inline int pnp_is_active(struct pnp_dev * dev) { return 0; } +static inline int compare_pnp_id(struct pnp_id * pos, const char * id) { return -ENODEV; } +static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; } +static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; } +static inline void pnp_unregister_driver(struct pnp_driver *drv) { ; } + +#else +#include_next +#endif + +#endif // _PNP_COMPAT_H diff --git a/include/linux/usb.h b/include/linux/usb.h index 18f65756..0bfced20 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -27,14 +27,19 @@ #include #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +#include + #define USB_ALLOC_URB(x) usb_alloc_urb(x) #define USB_SUBMIT_URB(x) usb_submit_urb(x) #define URB_ISO_ASAP USB_ISO_ASAP #define PROBE_ERR_RETURN(x) NULL +#define usb_get_dev(x) (x) +#define usb_put_dev(x) +#define interface_to_usbdev(intf) NULL #else #define USB_ALLOC_URB(x) usb_alloc_urb(x,GFP_KERNEL) #define USB_SUBMIT_URB(x) usb_submit_urb(x,GFP_ATOMIC) -#define PROBE_ERR_RETURN(x) x +#define PROBE_ERR_RETURN(x) (x) #endif -- 2.26.2