diff -u -p -r -b ipw2200-1.0.1-0/Makefile ipw2200-1.0.1-3/Makefile --- ipw2200-1.0.1-0/Makefile 2005-02-09 13:17:26.000000000 +0100 +++ ipw2200-1.0.1-3/Makefile 2005-03-21 09:46:19.000000000 +0100 @@ -190,6 +190,8 @@ modules: endif # End 2.4 / 2.6 specific +ifeq ($(OLDMAKE),) + install: modules install -d $(KMISC) install -m 644 -c $(addsuffix .ko,$(list-m)) $(KMISC) @@ -203,6 +205,22 @@ uninstall: rm -rf $(addprefix $(KMISC),$(addsuffix .ko,$(list-m))) /sbin/depmod -a +else + +install: modules + install -d $(KMISC) + install -m 644 -c $(addsuffix .o,$(list-m)) $(KMISC) + /sbin/depmod -a + @echo "Don't forget to copy firmware to /usr/lib/hotplug/firmware/ and have the " + @echo "hotplug tools in place." + @echo "See INSTALL for more information." + +uninstall: + rm -rf $(addprefix $(KMISC),$(addsuffix .o,$(list-m))) + /sbin/depmod -a + +endif + endif # End of internal build .PHONY: TAGS tags diff -u -p -r -b ipw2200-1.0.1-0/ieee80211.h ipw2200-1.0.1-3/ieee80211.h --- ipw2200-1.0.1-0/ieee80211.h 2005-02-08 23:24:04.000000000 +0100 +++ ipw2200-1.0.1-3/ieee80211.h 2005-03-21 09:53:29.000000000 +0100 @@ -22,6 +22,7 @@ #define IEEE80211_H #include /* ETH_ALEN */ #include /* ARRAY_SIZE */ +#include #if WIRELESS_EXT < 17 #define IW_QUAL_QUAL_INVALID 0x10 @@ -740,6 +741,9 @@ struct ieee80211_device { #define IEEE_G BIT(2) #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) +#ifndef HAVE_NETDEV_PRIV +static inline void *netdev_priv(struct net_device *dev) { return dev->priv; } +#endif extern inline void *ieee80211_priv(struct net_device *dev) { return ((struct ieee80211_device *)netdev_priv(dev))->priv; diff -u -p -r -b ipw2200-1.0.1-0/ieee80211_crypt.c ipw2200-1.0.1-3/ieee80211_crypt.c --- ipw2200-1.0.1-0/ieee80211_crypt.c 2005-02-08 23:24:04.000000000 +0100 +++ ipw2200-1.0.1-3/ieee80211_crypt.c 2005-03-21 09:46:19.000000000 +0100 @@ -55,7 +55,11 @@ void ieee80211_crypt_deinit_entries(stru if (entry->ops) { entry->ops->deinit(entry->priv); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + if (entry->ops->owner) __MOD_DEC_USE_COUNT(entry->ops->owner); +#else module_put(entry->ops->owner); +#endif } kfree(entry); } diff -u -p -r -b ipw2200-1.0.1-0/ieee80211_module.c ipw2200-1.0.1-3/ieee80211_module.c --- ipw2200-1.0.1-0/ieee80211_module.c 2005-02-08 23:24:04.000000000 +0100 +++ ipw2200-1.0.1-3/ieee80211_module.c 2005-03-21 09:46:19.000000000 +0100 @@ -176,7 +176,11 @@ void free_ieee80211(struct net_device *d if (crypt) { if (crypt->ops) { crypt->ops->deinit(crypt->priv); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + if (crypt->ops->owner) __MOD_DEC_USE_COUNT(crypt->ops->owner); +#else module_put(crypt->ops->owner); +#endif } kfree(crypt); ieee->crypt[i] = NULL; @@ -261,8 +265,13 @@ static void __exit ieee80211_exit(void) } } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +MODULE_PARM(debug, "i"); +#else #include module_param(debug, int, 0444); +#endif + MODULE_PARM_DESC(debug, "debug output mask"); diff -u -p -r -b ipw2200-1.0.1-0/ieee80211_wx.c ipw2200-1.0.1-3/ieee80211_wx.c --- ipw2200-1.0.1-0/ieee80211_wx.c 2005-02-08 23:24:04.000000000 +0100 +++ ipw2200-1.0.1-3/ieee80211_wx.c 2005-03-21 09:46:19.000000000 +0100 @@ -378,7 +378,11 @@ int ieee80211_wx_set_encode(struct ieee8 new_crypt->ops = ieee80211_get_crypto_ops("WEP"); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + if (new_crypt->ops && new_crypt->ops->owner && __MOD_INC_USE_COUNT(new_crypt->ops->owner)) +#else if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) +#endif new_crypt->priv = new_crypt->ops->init(key); if (!new_crypt->ops || !new_crypt->priv) { diff -u -p -r -b ipw2200-1.0.1-0/ipw2200.c ipw2200-1.0.1-3/ipw2200.c --- ipw2200-1.0.1-0/ipw2200.c 2005-02-08 23:24:04.000000000 +0100 +++ ipw2200-1.0.1-3/ipw2200.c 2005-03-21 09:50:26.000000000 +0100 @@ -33,13 +33,19 @@ #include "ipw2200.h" #include "ieee80211.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +#define IPW2200_VERSION "1.0.1-3" +#else #define IPW2200_VERSION "1.0.1" +#endif #define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver" #define DRV_COPYRIGHT "Copyright(c) 2003-2004 Intel Corporation" #define DRV_VERSION IPW2200_VERSION MODULE_DESCRIPTION(DRV_DESCRIPTION); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) MODULE_VERSION(DRV_VERSION); +#endif MODULE_AUTHOR(DRV_COPYRIGHT); MODULE_LICENSE("GPL"); @@ -647,13 +653,35 @@ static void ipw_init_ordinals(struct ipw * * See the level definitions in ipw for details. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_debug_level(char *buf, char **start, off_t offset, + int count, int *eof, void *data) +{ + *eof = 1; +#else static ssize_t show_debug_level(struct device_driver *d, char *buf) { +#endif return sprintf(buf, "0x%08X\n", ipw_debug_level); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_set_debug_level(struct file *file, const char *user_buffer, + unsigned long count, void *data) +{ + char buf[] = "0x00000000"; + unsigned long len = + (sizeof(buf) -1) > count ? count : sizeof(buf) - 1; + + if (copy_from_user(buf, user_buffer, len)) { + IPW_DEBUG_INFO("can't copy data from userspace\n"); + return count; + } + buf[len] = 0; +#else static ssize_t store_debug_level(struct device_driver *d, const char *buf, size_t count) { +#endif char *p = (char *)buf; u32 val; @@ -670,29 +698,69 @@ static ssize_t store_debug_level(struct else ipw_debug_level = val; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + return count; +#else return strnlen(buf, count); +#endif } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, show_debug_level, store_debug_level); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_status(char *buf, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *device = data; + struct ipw_priv *p = ieee80211_priv(device); + *eof = 1; +#else static ssize_t show_status(struct device *d, char *buf) { struct ipw_priv *p = (struct ipw_priv *)d->driver_data; +#endif return sprintf(buf, "0x%08x\n", (int)p->status); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_cfg(char *buf, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *device = data; + struct ipw_priv *p = ieee80211_priv(device); + *eof = 1; +#else static ssize_t show_cfg(struct device *d, char *buf) { struct ipw_priv *p = (struct ipw_priv *)d->driver_data; +#endif return sprintf(buf, "0x%08x\n", (int)p->config); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(cfg, S_IRUGO, show_cfg, NULL); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_nic_type(char *buf, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *device = data; + struct ipw_priv *p = ieee80211_priv(device); + *eof = 1; +#else static ssize_t show_nic_type(struct device *d, char *buf) { struct ipw_priv *p = (struct ipw_priv *)d->driver_data; +#endif u8 type = p->eeprom[EEPROM_NIC_TYPE]; switch (type) { @@ -710,123 +778,314 @@ static ssize_t show_nic_type(struct devi return sprintf(buf, "UNKNOWN\n"); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(nic_type, S_IRUGO, show_nic_type, NULL); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int dump_error_log(struct file *file, const char *user_buffer, + unsigned long count, void *data) +{ + struct net_device *device = data; + char buf[] = "0"; + unsigned long len = + (sizeof(buf) - 1) > count ? count : sizeof(buf) - 1; + + if (copy_from_user(buf, user_buffer, len)) { + IPW_DEBUG_INFO("can't copy data from userspace\n"); + return count; + } + buf[len] = 0; +#else static ssize_t dump_error_log(struct device *d, const char *buf, size_t count) { +#endif char *p = (char *)buf; if (p[0] == '1') +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + ipw_dump_nic_error_log((struct ipw_priv*)netdev_priv(device)); + + return count; +#else ipw_dump_nic_error_log((struct ipw_priv*)d->driver_data); return strnlen(buf, count); +#endif } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, dump_error_log); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int dump_event_log(struct file *file, const char *user_buffer, + unsigned long count, void *data) +{ + struct net_device *device = data; + char buf[] = "0"; + unsigned long len = + (sizeof(buf) - 1) > count ? count : sizeof(buf) - 1; + + if (copy_from_user(buf, user_buffer, len)) { + IPW_DEBUG_INFO("can't copy data from userspace\n"); + return count; + } + buf[len] = 0; +#else static ssize_t dump_event_log(struct device *d, const char *buf, size_t count) { +#endif char *p = (char *)buf; if (p[0] == '1') +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + ipw_dump_nic_event_log((struct ipw_priv*)netdev_priv(device)); + + return count; +#else ipw_dump_nic_event_log((struct ipw_priv*)d->driver_data); return strnlen(buf, count); +#endif } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(dump_events, S_IWUSR, NULL, dump_event_log); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_ucode_version(char *buf, char **start, + off_t offset, int count, + int *eof, void *data) +{ + u32 len = sizeof(u32), tmp = 0; + struct net_device *device = data; + struct ipw_priv *p = ieee80211_priv(device); + *eof = 1; +#else static ssize_t show_ucode_version(struct device *d, char *buf) { u32 len = sizeof(u32), tmp = 0; struct ipw_priv *p = (struct ipw_priv*)d->driver_data; +#endif if(ipw_get_ordinal(p, IPW_ORD_STAT_UCODE_VERSION, &tmp, &len)) return 0; return sprintf(buf, "0x%08x\n", tmp); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(ucode_version, S_IWUSR|S_IRUGO, show_ucode_version, NULL); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_rtc(char *buf, char **start, + off_t offset, int count, + int *eof, void *data) +{ + u32 len = sizeof(u32), tmp = 0; + struct net_device *device = data; + struct ipw_priv *p = ieee80211_priv(device); + *eof = 1; +#else static ssize_t show_rtc(struct device *d, char *buf) { u32 len = sizeof(u32), tmp = 0; struct ipw_priv *p = (struct ipw_priv*)d->driver_data; +#endif if(ipw_get_ordinal(p, IPW_ORD_STAT_RTC, &tmp, &len)) return 0; return sprintf(buf, "0x%08x\n", tmp); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(rtc, S_IWUSR|S_IRUGO, show_rtc, NULL); +#endif /* * Add a device attribute to view/control the delay between eeprom * operations. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_eeprom_delay(char *buf, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *device = data; + struct ipw_priv *p = ieee80211_priv(device); + int n = p->eeprom_delay; + *eof = 1; +#else static ssize_t show_eeprom_delay(struct device *d, char *buf) { int n = ((struct ipw_priv*)d->driver_data)->eeprom_delay; +#endif return sprintf(buf, "%i\n", n); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_set_eeprom_delay(struct file *file, const char *user_buffer, + unsigned long count, void *data) +{ + struct net_device *device = data; + struct ipw_priv *p = ieee80211_priv(device); + char buf[] = "00000"; + unsigned long len = + (sizeof(buf) - 1) > count ? count : sizeof(buf) - 1; + + if (copy_from_user(buf, user_buffer, len)) { + IPW_DEBUG_INFO("can't copy data from userspace\n"); + return count; + } + buf[len] = 0; +#else static ssize_t store_eeprom_delay(struct device *d, const char *buf, size_t count) { struct ipw_priv *p = (struct ipw_priv*)d->driver_data; +#endif sscanf(buf, "%i", &p->eeprom_delay); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + return count; +#else return strnlen(buf, count); +#endif } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(eeprom_delay, S_IWUSR|S_IRUGO, show_eeprom_delay,store_eeprom_delay); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_command_event_reg(char *buf, char **start, + off_t offset, int count, + int *eof, void *data) +{ + u32 reg = 0; + struct net_device *device = data; + struct ipw_priv *p = ieee80211_priv(device); + *eof = 1; +#else static ssize_t show_command_event_reg(struct device *d, char *buf) { u32 reg = 0; struct ipw_priv *p = (struct ipw_priv *)d->driver_data; +#endif reg = ipw_read_reg32(p, CX2_INTERNAL_CMD_EVENT); return sprintf(buf, "0x%08x\n", reg); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_set_command_event_reg(struct file *file, const char *user_buffer, + unsigned long count, void *data) +{ + u32 reg; + struct net_device *device = data; + struct ipw_priv *p = ieee80211_priv(device); + char buf[] = "00000"; + unsigned long len = + (sizeof(buf) - 1) > count ? count : sizeof(buf) - 1; + + if (copy_from_user(buf, user_buffer, len)) { + IPW_DEBUG_INFO("can't copy data from userspace\n"); + return count; + } + buf[len] = 0; +#else static ssize_t store_command_event_reg(struct device *d, const char *buf, size_t count) { u32 reg; struct ipw_priv *p = (struct ipw_priv *)d->driver_data; +#endif sscanf(buf, "%x", ®); ipw_write_reg32(p, CX2_INTERNAL_CMD_EVENT, reg); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + return count; +#else return strnlen(buf, count); +#endif } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(command_event_reg, S_IWUSR|S_IRUGO, show_command_event_reg,store_command_event_reg); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_mem_gpio_reg(char *buf, char **start, + off_t offset, int count, + int *eof, void *data) +{ + u32 reg = 0; + struct net_device *device = data; + struct ipw_priv *p = ieee80211_priv(device); + *eof = 1; +#else static ssize_t show_mem_gpio_reg(struct device *d, char *buf) { u32 reg = 0; struct ipw_priv *p = (struct ipw_priv *)d->driver_data; +#endif reg = ipw_read_reg32(p, 0x301100); return sprintf(buf, "0x%08x\n", reg); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_set_mem_gpio_reg(struct file *file, const char *user_buffer, + unsigned long count, void *data) +{ + u32 reg; + struct net_device *device = data; + struct ipw_priv *p = ieee80211_priv(device); + char buf[] = "00000"; + unsigned long len = + (sizeof(buf) - 1) > count ? count : sizeof(buf) - 1; + + if (copy_from_user(buf, user_buffer, len)) { + IPW_DEBUG_INFO("can't copy data from userspace\n"); + return count; + } + buf[len] = 0; +#else static ssize_t store_mem_gpio_reg(struct device *d, const char *buf, size_t count) { u32 reg; struct ipw_priv *p = (struct ipw_priv *)d->driver_data; +#endif sscanf(buf, "%x", ®); ipw_write_reg32(p, 0x301100, reg); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + return count; +#else return strnlen(buf, count); +#endif } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(mem_gpio_reg, S_IWUSR|S_IRUGO, show_mem_gpio_reg,store_mem_gpio_reg); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_indirect_dword(char *buf, char **start, + off_t offset, int count, + int *eof, void *data) +{ + u32 reg = 0; + struct net_device *device = data; + struct ipw_priv *priv = ieee80211_priv(device); + *eof = 1; +#else static ssize_t show_indirect_dword(struct device *d, char *buf) { u32 reg = 0; struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; +#endif if (priv->status & STATUS_INDIRECT_DWORD) reg = ipw_read_reg32(priv, priv->indirect_dword); else @@ -834,23 +1093,57 @@ static ssize_t show_indirect_dword(struc return sprintf(buf, "0x%08x\n", reg); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_set_indirect_dword(struct file *file, const char *user_buffer, + unsigned long count, void *data) +{ + struct net_device *device = data; + struct ipw_priv *priv = ieee80211_priv(device); + char buf[] = "00000"; + unsigned long len = + (sizeof(buf) - 1) > count ? count : sizeof(buf) - 1; + + if (copy_from_user(buf, user_buffer, len)) { + IPW_DEBUG_INFO("can't copy data from userspace\n"); + return count; + } + buf[len] = 0; +#else static ssize_t store_indirect_dword(struct device *d, const char *buf, size_t count) { struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; +#endif sscanf(buf, "%x", &priv->indirect_dword); priv->status |= STATUS_INDIRECT_DWORD; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + return count; +#else return strnlen(buf, count); +#endif } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(indirect_dword, S_IWUSR|S_IRUGO, show_indirect_dword,store_indirect_dword); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_indirect_byte(char *buf, char **start, + off_t offset, int count, + int *eof, void *data) +{ + u8 reg = 0; + struct net_device *device = data; + struct ipw_priv *priv = ieee80211_priv(device); + *eof = 1; +#else static ssize_t show_indirect_byte(struct device *d, char *buf) { u8 reg = 0; struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; +#endif if (priv->status & STATUS_INDIRECT_BYTE) reg = ipw_read_reg8(priv, priv->indirect_byte); else @@ -858,23 +1151,53 @@ static ssize_t show_indirect_byte(struct return sprintf(buf, "0x%02x\n", reg); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_set_indirect_byte(struct file *file, const char *user_buffer, + unsigned long count, void *data) +{ + struct net_device *device = data; + struct ipw_priv *priv = ieee80211_priv(device); + char buf[] = "00000"; + unsigned long len = + (sizeof(buf) - 1) > count ? count : sizeof(buf) - 1; + + if (copy_from_user(buf, user_buffer, len)) { + IPW_DEBUG_INFO("can't copy data from userspace\n"); + return count; + } + buf[len] = 0; +#else static ssize_t store_indirect_byte(struct device *d, const char *buf, size_t count) { struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; +#endif sscanf(buf, "%x", &priv->indirect_byte); priv->status |= STATUS_INDIRECT_BYTE; return strnlen(buf, count); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(indirect_byte, S_IWUSR|S_IRUGO, show_indirect_byte, store_indirect_byte); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_direct_dword(char *buf, char **start, + off_t offset, int count, + int *eof, void *data) +{ + u32 reg = 0; + struct net_device *device = data; + struct ipw_priv *priv = ieee80211_priv(device); + *eof = 1; +#else static ssize_t show_direct_dword(struct device *d, char *buf) { u32 reg = 0; struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; +#endif if (priv->status & STATUS_DIRECT_DWORD) reg = ipw_read32(priv, priv->direct_dword); @@ -883,18 +1206,41 @@ static ssize_t show_direct_dword(struct return sprintf(buf, "0x%08x\n", reg); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_set_direct_dword(struct file *file, const char *user_buffer, + unsigned long count, void *data) +{ + struct net_device *device = data; + struct ipw_priv *priv = ieee80211_priv(device); + char buf[] = "00000"; + unsigned long len = + (sizeof(buf) - 1) > count ? count : sizeof(buf) - 1; + + if (copy_from_user(buf, user_buffer, len)) { + IPW_DEBUG_INFO("can't copy data from userspace\n"); + return count; + } + buf[len] = 0; +#else static ssize_t store_direct_dword(struct device *d, const char *buf, size_t count) { struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; +#endif sscanf(buf, "%x", &priv->direct_dword); priv->status |= STATUS_DIRECT_DWORD; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + return count; +#else return strnlen(buf, count); +#endif } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(direct_dword, S_IWUSR|S_IRUGO, show_direct_dword,store_direct_dword); +#endif static inline int rf_kill_active(struct ipw_priv *priv) @@ -907,6 +1253,15 @@ static inline int rf_kill_active(struct return (priv->status & STATUS_RF_KILL_HW) ? 1 : 0; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_get_rf_kill(char *buf, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *device = data; + struct ipw_priv *priv = ieee80211_priv(device); + *eof = 1; +#else static ssize_t show_rf_kill(struct device *d, char *buf) { /* 0 - RF kill not enabled @@ -914,6 +1269,7 @@ static ssize_t show_rf_kill(struct devic 2 - HW based RF kill active 3 - Both HW and SW baed RF kill active */ struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; +#endif int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) | (rf_kill_active(priv) ? 0x2 : 0x0); return sprintf(buf, "%i\n", val); @@ -931,9 +1287,11 @@ static int ipw_radio_kill_sw(struct ipw_ if (disable_radio) { priv->status |= STATUS_RF_KILL_SW; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) if (priv->workqueue) { cancel_delayed_work(&priv->request_scan); } +#endif wake_up_interruptible(&priv->wait_command_queue); queue_work(priv->workqueue, &priv->down); } else { @@ -942,9 +1300,15 @@ static int ipw_radio_kill_sw(struct ipw_ IPW_DEBUG_RF_KILL("Can not turn radio back on - " "disabled by HW switch\n"); /* Make sure the RF_KILL check timer is running */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + del_timer_sync(&priv->rf_kill_timer); + priv->rf_kill_timer.expires = jiffies + 2 * HZ; + add_timer(&priv->rf_kill_timer); +#else cancel_delayed_work(&priv->rf_kill); queue_delayed_work(priv->workqueue, &priv->rf_kill, 2 * HZ); +#endif } else queue_work(priv->workqueue, &priv->up); } @@ -952,15 +1316,33 @@ static int ipw_radio_kill_sw(struct ipw_ return 1; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static int proc_set_rf_kill(struct file *file, const char *user_buffer, + unsigned long count, void *data) +{ + struct net_device *device = data; + struct ipw_priv *priv = ieee80211_priv(device); + char buf[] = "0"; + unsigned long len = + (sizeof(buf) - 1) > count ? count : sizeof(buf) - 1; + + if (copy_from_user(buf, user_buffer, len)) { + IPW_DEBUG_INFO("can't copy data from userspace\n"); + return count; + } +#else static ssize_t store_rf_kill(struct device *d, const char *buf, size_t count) { struct ipw_priv *priv = (struct ipw_priv *)d->driver_data; +#endif ipw_radio_kill_sw(priv, buf[0] == '1'); return count; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) static DEVICE_ATTR(rf_kill, S_IWUSR|S_IRUGO, show_rf_kill, store_rf_kill); +#endif static void notify_wx_assoc_event(struct ipw_priv *priv) { @@ -1060,8 +1442,13 @@ static void ipw_irq_tasklet(struct ipw_p netif_stop_queue(priv->net_dev); priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING); notify_wx_assoc_event(priv); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + priv->rf_kill_timer.expires = jiffies + 2 * HZ; + add_timer(&priv->rf_kill_timer); +#else cancel_delayed_work(&priv->request_scan); queue_delayed_work(priv->workqueue, &priv->rf_kill, 2 * HZ); +#endif handled |= CX2_INTA_BIT_RF_KILL_DONE; } @@ -1174,9 +1561,15 @@ static int ipw_send_cmd(struct ipw_priv if (rc) return rc; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + rc = interruptible_sleep_on_timeout( + &priv->wait_command_queue, + HOST_COMPLETE_TIMEOUT); +#else rc = wait_event_interruptible_timeout( priv->wait_command_queue, !(priv->status & STATUS_HCMD_ACTIVE), HOST_COMPLETE_TIMEOUT); +#endif if (rc == 0) { IPW_DEBUG_INFO("Command completion failed out after %dms.\n", 1000 * (HOST_COMPLETE_TIMEOUT / HZ)); @@ -1298,9 +1691,15 @@ static void ipw_adapter_restart(void *ad #define IPW_SCAN_CHECK_WATCHDOG (5 * HZ) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static void ipw_scan_check(unsigned long arg) +{ + struct ipw_priv *priv = (struct ipw_priv *)arg; +#else static void ipw_scan_check(void *data) { struct ipw_priv *priv = data; +#endif if (priv->status & (STATUS_SCANNING | STATUS_SCAN_ABORTING)) { IPW_DEBUG_SCAN("Scan completion watchdog resetting " "adapter (%dms).\n", @@ -1328,8 +1727,13 @@ static int ipw_send_scan_request_ext(str return -1; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + priv->scan_check_timer.expires = jiffies + IPW_SCAN_CHECK_WATCHDOG; + add_timer(&priv->scan_check_timer); +#else queue_delayed_work(priv->workqueue, &priv->scan_check, IPW_SCAN_CHECK_WATCHDOG); +#endif return 0; } @@ -2351,7 +2755,11 @@ static int ipw_get_fw(struct ipw_priv *p int rc; /* ask firmware_class module to get the boot firmware off disk */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + rc = request_firmware(fw, name, pci_name(priv->pci_dev)); +#else rc = request_firmware(fw, name, &priv->pci_dev->dev); +#endif if (rc < 0) { IPW_ERROR("%s load failed: Reason %d\n", name, rc); return rc; @@ -3115,8 +3523,14 @@ static u32 ipw_get_current_rate(struct i #define PERFECT_RSSI (-20) #define WORST_RSSI (-85) #define IPW_STATS_INTERVAL (2 * HZ) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static void ipw_gather_stats(unsigned long arg) +{ + struct ipw_priv *priv = (struct ipw_priv *)arg; +#else static void ipw_gather_stats(struct ipw_priv *priv) { +#endif u32 rx_err, rx_err_delta, rx_packets_delta; u32 tx_failures, tx_failures_delta, tx_packets_delta; u32 missed_beacons_percent, missed_beacons_delta; @@ -3251,8 +3665,12 @@ static void ipw_gather_stats(struct ipw_ priv->quality = quality; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + mod_timer(&priv->gather_stats_timer, jiffies + IPW_STATS_INTERVAL); +#else queue_delayed_work(priv->workqueue, &priv->gather_stats, IPW_STATS_INTERVAL); +#endif } static inline void ipw_handle_missed_beacon(struct ipw_priv *priv, @@ -3351,9 +3769,14 @@ static inline void ipw_rx_notification(s priv->num_stations = 0; IPW_DEBUG_ASSOC("queueing adhoc check\n"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + priv->adhoc_check_timer.expires = jiffies + priv->assoc_request.beacon_interval; + add_timer(&priv->adhoc_check_timer); +#else queue_delayed_work(priv->workqueue, &priv->adhoc_check, priv->assoc_request.beacon_interval); +#endif break; } @@ -3372,7 +3795,12 @@ static inline void ipw_rx_notification(s ipw_reset_stats(priv); /* Ensure the rate is updated immediately */ priv->last_rate = ipw_get_current_rate(priv); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + priv->gather_stats_timer.expires = jiffies; + add_timer(&priv->gather_stats_timer); +#else schedule_work(&priv->gather_stats); +#endif notify_wx_assoc_event(priv); /* queue_delayed_work(priv->workqueue, @@ -3439,14 +3867,22 @@ static inline void ipw_rx_notification(s notify_wx_assoc_event(priv); /* Cancel any queued work ... */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + del_timer_sync(&priv->adhoc_check_timer); +#else cancel_delayed_work(&priv->request_scan); cancel_delayed_work(&priv->adhoc_check); +#endif /* Queue up another scan... */ queue_work(priv->workqueue, &priv->request_scan); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + del_timer_sync(&priv->gather_stats_timer); +#else cancel_delayed_work(&priv->gather_stats); +#endif } else { priv->status |= STATUS_ROAMING; queue_work(priv->workqueue, @@ -3580,7 +4016,11 @@ static inline void ipw_rx_notification(s priv->status &= ~(STATUS_SCANNING | STATUS_SCAN_ABORTING); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + del_timer_sync(&priv->scan_check_timer); +#else cancel_delayed_work(&priv->scan_check); +#endif if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING | @@ -4514,9 +4954,15 @@ static void ipw_send_wep_keys(struct ipw } } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static void ipw_adhoc_check(unsigned long arg) +{ + struct ipw_priv *priv = (struct ipw_priv *)arg; +#else static void ipw_adhoc_check(void *data) { struct ipw_priv *priv = data; +#endif if (priv->missed_adhoc_beacons++ > priv->missed_beacon_threshold && !(priv->config & CFG_ADHOC_PERSIST)) { @@ -4526,8 +4972,12 @@ static void ipw_adhoc_check(void *data) return; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + mod_timer(&priv->adhoc_check_timer, jiffies + priv->assoc_request.beacon_interval); +#else queue_delayed_work(priv->workqueue, &priv->adhoc_check, priv->assoc_request.beacon_interval); +#endif } #ifdef CONFIG_IPW_DEBUG @@ -4652,6 +5102,14 @@ static int ipw_request_scan(struct ipw_p int channel_index = 0; int i, err, scan_type; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + if (priv->status & (STATUS_ASSOCIATING | + STATUS_AUTH | + STATUS_ASSOCIATED)) { + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(SCAN_INTERVAL); + } +#endif if (priv->status & STATUS_EXIT_PENDING) { IPW_DEBUG_SCAN("Aborting scan due to device shutdown\n"); priv->status |= STATUS_SCAN_PENDING; @@ -5102,7 +5560,11 @@ static int ipw_wpa_set_encryption(struct } memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); new_crypt->ops = ops; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + if (new_crypt->ops && new_crypt->ops->owner && __MOD_INC_USE_COUNT(new_crypt->ops->owner)) +#else if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) +#endif new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx); @@ -5495,8 +5957,12 @@ static void ipw_associate(void *data) if (!network) { ipw_debug_config(priv); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + queue_work(priv->workqueue, &priv->request_scan); +#else queue_delayed_work(priv->workqueue, &priv->request_scan, SCAN_INTERVAL); +#endif return; } @@ -7310,9 +7776,15 @@ static irqreturn_t ipw_isr(int irq, void return IRQ_NONE; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static void ipw_rf_kill(unsigned long arg) +{ + struct ipw_priv *priv = (struct ipw_priv *)arg; +#else static void ipw_rf_kill(void *adapter) { struct ipw_priv *priv = adapter; +#endif unsigned long flags; spin_lock_irqsave(&priv->lock, flags); @@ -7320,8 +7792,12 @@ static void ipw_rf_kill(void *adapter) if (rf_kill_active(priv)) { IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n"); if (priv->workqueue) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + mod_timer(&priv->rf_kill_timer, jiffies + 2 * HZ); +#else queue_delayed_work(priv->workqueue, &priv->rf_kill, 2 * HZ); +#endif goto exit_unlock; } @@ -7345,28 +7821,56 @@ static int ipw_setup_deferred_work(struc { int ret = 0; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + priv->workqueue = (void *)1; +#else #ifdef CONFIG_SOFTWARE_SUSPEND2 priv->workqueue = create_workqueue(DRV_NAME, 0); #else priv->workqueue = create_workqueue(DRV_NAME); #endif +#endif init_waitqueue_head(&priv->wait_command_queue); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + init_timer(&priv->adhoc_check_timer); + priv->adhoc_check_timer.data = (unsigned long)priv; + priv->adhoc_check_timer.function = ipw_adhoc_check; +#else INIT_WORK(&priv->adhoc_check, ipw_adhoc_check, priv); +#endif INIT_WORK(&priv->associate, ipw_associate, priv); INIT_WORK(&priv->disassociate, ipw_disassociate, priv); INIT_WORK(&priv->rx_replenish, ipw_rx_queue_replenish, priv); INIT_WORK(&priv->adapter_restart, ipw_adapter_restart, priv); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + init_timer(&priv->rf_kill_timer); + priv->rf_kill_timer.data = (unsigned long)priv; + priv->rf_kill_timer.function = ipw_rf_kill; +#else INIT_WORK(&priv->rf_kill, ipw_rf_kill, priv); +#endif INIT_WORK(&priv->up, (void (*)(void *))ipw_up, priv); INIT_WORK(&priv->down, (void (*)(void *))ipw_down, priv); INIT_WORK(&priv->request_scan, (void (*)(void *))ipw_request_scan, priv); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + init_timer(&priv->gather_stats_timer); + priv->gather_stats_timer.data = (unsigned long)priv; + priv->gather_stats_timer.function = ipw_gather_stats; +#else INIT_WORK(&priv->gather_stats, (void (*)(void *))ipw_gather_stats, priv); +#endif INIT_WORK(&priv->abort_scan, (void (*)(void *))ipw_abort_scan, priv); INIT_WORK(&priv->roam, ipw_roam, priv); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + init_timer(&priv->scan_check_timer); + priv->scan_check_timer.data = (unsigned long)priv; + priv->scan_check_timer.function = ipw_scan_check; +#else INIT_WORK(&priv->scan_check, ipw_scan_check, priv); +#endif tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) ipw_irq_tasklet, (unsigned long)priv); @@ -7645,7 +8149,12 @@ static int ipw_net_init(struct net_devic IPW_WARNING("Radio Frequency Kill Switch is On:\n" "Kill switch must be turned off for " "wireless networking to work.\n"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + priv->rf_kill_timer.expires = jiffies + 2 * HZ; + add_timer(&priv->rf_kill_timer); +#else queue_delayed_work(priv->workqueue, &priv->rf_kill, 2 * HZ); +#endif return 0; } @@ -7686,6 +8195,7 @@ static struct pci_device_id card_ids[] = MODULE_DEVICE_TABLE(pci, card_ids); +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) static struct attribute *ipw_sysfs_entries[] = { &dev_attr_rf_kill.attr, &dev_attr_direct_dword.attr, @@ -7708,6 +8218,7 @@ static struct attribute_group ipw_attrib .name = NULL, /* put in device directory */ .attrs = ipw_sysfs_entries, }; +#endif static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) @@ -7743,8 +8254,10 @@ static int ipw_pci_probe(struct pci_dev #define PCI_DMA_32BIT 0x00000000ffffffffULL err = pci_set_dma_mask(pdev, PCI_DMA_32BIT); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) if (!err) err = pci_set_consistent_dma_mask(pdev, PCI_DMA_32BIT); +#endif if (err) { printk(KERN_WARNING DRV_NAME ": No suitable DMA available.\n"); goto out_pci_disable_device; @@ -7871,7 +8384,9 @@ static int ipw_pci_probe(struct pci_dev } SET_MODULE_OWNER(net_dev); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) SET_NETDEV_DEV(net_dev, &pdev->dev); +#endif priv->ieee->hard_start_xmit = ipw_net_hard_start_xmit; priv->ieee->set_security = shim__set_security; @@ -7891,7 +8406,9 @@ static int ipw_pci_probe(struct pci_dev net_dev->mem_start = pci_resource_start(pdev, 0); net_dev->mem_end = net_dev->mem_start + pci_resource_len(pdev, 0) - 1; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) err = sysfs_create_group(&pdev->dev.kobj, &ipw_attribute_group); +#endif if (err) { IPW_ERROR("failed to create sysfs device attributes\n"); goto out_release_irq; @@ -7902,15 +8419,30 @@ static int ipw_pci_probe(struct pci_dev IPW_ERROR("failed to register network device\n"); goto out_remove_group; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + err = ipw2200_proc_dev_init(priv); + if (err) { + printk(KERN_ERR + "%s: Failed to create /proc node\n", net_dev->name); + } +#endif return 0; out_remove_group: +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + ipw2200_proc_dev_cleanup(priv); +#else sysfs_remove_group(&pdev->dev.kobj, &ipw_attribute_group); +#endif out_release_irq: free_irq(pdev->irq, priv); out_destroy_workqueue: +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + flush_scheduled_work(); +#else destroy_workqueue(priv->workqueue); +#endif priv->workqueue = NULL; out_iounmap: iounmap(priv->hw_base); @@ -7933,7 +8465,11 @@ static void ipw_pci_remove(struct pci_de priv->status |= STATUS_EXIT_PENDING; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + ipw2200_proc_dev_cleanup(priv); +#else sysfs_remove_group(&pdev->dev.kobj, &ipw_attribute_group); +#endif ipw_down(priv); @@ -7948,12 +8484,20 @@ static void ipw_pci_remove(struct pci_de /* ipw_down will ensure that there is no more pending work * in the workqueue's, so we can safely remove them now. */ if (priv->workqueue) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + del_timer_sync(&priv->adhoc_check_timer); + del_timer_sync(&priv->gather_stats_timer); + del_timer_sync(&priv->rf_kill_timer); + del_timer_sync(&priv->scan_check_timer); + flush_scheduled_work(); +#else cancel_delayed_work(&priv->adhoc_check); cancel_delayed_work(&priv->gather_stats); cancel_delayed_work(&priv->request_scan); cancel_delayed_work(&priv->rf_kill); cancel_delayed_work(&priv->scan_check); destroy_workqueue(priv->workqueue); +#endif priv->workqueue = NULL; } @@ -8068,6 +8612,14 @@ static int __init ipw_init(void) printk(KERN_INFO DRV_NAME ": " DRV_DESCRIPTION ", " DRV_VERSION "\n"); printk(KERN_INFO DRV_NAME ": " DRV_COPYRIGHT "\n"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + ret = ipw2200_proc_init(); + if (!ret) { + ret = pci_module_init(&ipw_driver); + if (ret) + ipw2200_proc_cleanup(); + } +#else ret = pci_module_init(&ipw_driver); if (ret) { IPW_ERROR("Unable to initialize PCI module\n"); @@ -8081,38 +8633,354 @@ static int __init ipw_init(void) pci_unregister_driver(&ipw_driver); return ret; } +#endif return ret; } static void __exit ipw_exit(void) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) driver_remove_file(&ipw_driver.driver, &driver_attr_debug_level); +#endif pci_unregister_driver(&ipw_driver); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + ipw2200_proc_cleanup(); +#endif } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +MODULE_PARM(disable,"i"); +#else module_param(disable, int, 0444); +#endif MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +MODULE_PARM(associate,"i"); +#else module_param(associate, int, 0444); +#endif MODULE_PARM_DESC(associate, "auto associate when scanning (default on)"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +MODULE_PARM(auto_create,"i"); +#else module_param(auto_create, int, 0444); +#endif MODULE_PARM_DESC(auto_create, "auto create adhoc network (default on)"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +MODULE_PARM(debug,"i"); +#else module_param(debug, int, 0444); +#endif MODULE_PARM_DESC(debug, "debug output mask"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +MODULE_PARM(channel,"i"); +#else module_param(channel, int, 0444); +#endif MODULE_PARM_DESC(channel, "channel to limit associate to (default 0 [ANY])"); #ifdef CONFIG_IPW_MONITOR +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +MODULE_PARM(mode,"i"); +#else module_param(mode, int, 0444); +#endif MODULE_PARM_DESC(mode, "network mode (0=BSS,1=IBSS,2=Monitor)"); #else +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +MODULE_PARM(mode,"i"); +#else module_param(mode, int, 0444); +#endif MODULE_PARM_DESC(mode, "network mode (0=BSS,1=IBSS)"); #endif module_exit(ipw_exit); module_init(ipw_init); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +int ipw2200_proc_dev_init(struct ipw_priv *priv) +{ + struct proc_dir_entry *e; + + IPW_DEBUG_INFO("enter %s\n", priv->net_dev->name); + + priv->dir_dev = create_proc_entry(priv->net_dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, + ipw2200_proc); + if (!priv->dir_dev) { + printk(KERN_ERR + "Unable to initialize /proc/net/ipw2200/%s\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_entry("rf_kill", S_IFREG | S_IRUGO | S_IWUSR, + priv->dir_dev); + if (e) { + e->read_proc = proc_get_rf_kill; + e->write_proc = proc_set_rf_kill; + e->data = priv->net_dev; + } else { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/rf_kill\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_entry("direct_dword", S_IFREG | S_IRUGO | S_IWUSR, + priv->dir_dev); + if (e) { + e->read_proc = proc_get_direct_dword; + e->write_proc = proc_set_direct_dword; + e->data = priv->net_dev; + } else { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/direct_dword\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_entry("indirect_byte", S_IFREG | S_IRUGO | S_IWUSR, + priv->dir_dev); + if (e) { + e->read_proc = proc_get_indirect_byte; + e->write_proc = proc_set_indirect_byte; + e->data = priv->net_dev; + } else { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/indirect_byte\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_entry("indirect_dword", S_IFREG | S_IRUGO | S_IWUSR, + priv->dir_dev); + if (e) { + e->read_proc = proc_get_indirect_dword; + e->write_proc = proc_set_indirect_dword; + e->data = priv->net_dev; + } else { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/indirect_dword\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_entry("mem_gpio_reg", S_IFREG | S_IRUGO | S_IWUSR, + priv->dir_dev); + if (e) { + e->read_proc = proc_get_mem_gpio_reg; + e->write_proc = proc_set_mem_gpio_reg; + e->data = priv->net_dev; + } else { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/mem_gpio_reg\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_entry("command_event_reg", S_IFREG | S_IRUGO | S_IWUSR, + priv->dir_dev); + if (e) { + e->read_proc = proc_get_command_event_reg; + e->write_proc = proc_set_command_event_reg; + e->data = priv->net_dev; + } else { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/command_event_reg\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_read_entry("nic_type", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_nic_type, priv->net_dev); + if (!e) { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/nic_type\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_read_entry("status", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_status, priv->net_dev); + if (!e) { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/status\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_read_entry("cfg", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_cfg, priv->net_dev); + if (!e) { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/cfg\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_entry("dump_errors", S_IFREG | S_IWUSR, + priv->dir_dev); + if (e) { + e->read_proc = NULL; + e->write_proc = dump_error_log; + e->data = priv->net_dev; + } else { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/error_log\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_entry("dump_events", S_IFREG | S_IWUSR, + priv->dir_dev); + if (e) { + e->read_proc = NULL; + e->write_proc = dump_event_log; + e->data = priv->net_dev; + } else { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/event_log\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_entry("eeprom_delay", S_IFREG | S_IRUGO | S_IWUSR, + priv->dir_dev); + if (e) { + e->read_proc = proc_get_eeprom_delay; + e->write_proc = proc_set_eeprom_delay; + e->data = priv->net_dev; + } else { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/eeprom_delay\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_read_entry("ucode_version", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_ucode_version, priv->net_dev); + if (!e) { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/ucode_version\n", + priv->net_dev->name); + goto fail; + } + + e = create_proc_read_entry("rtc", S_IFREG | S_IRUGO, + priv->dir_dev, proc_get_rtc, priv->net_dev); + if (!e) { + printk(KERN_ERR + "Unable to initialize " + "/proc/net/ipw2200/%s/rtc\n", + priv->net_dev->name); + goto fail; + } + + IPW_DEBUG_INFO("exit %s\n", priv->net_dev->name); + + return 0; + + fail: + ipw2200_proc_dev_cleanup(priv); + IPW_DEBUG_INFO("exit on fail %s\n", priv->net_dev->name); + + return -ENOMEM; +} + +void ipw2200_proc_dev_cleanup(struct ipw_priv *priv) +{ + IPW_DEBUG_INFO("enter %s\n", priv->net_dev->name); + + if (priv->dir_dev) { + remove_proc_entry("rf_kill", priv->dir_dev); + remove_proc_entry("direct_dword", priv->dir_dev); + remove_proc_entry("indirect_byte", priv->dir_dev); + remove_proc_entry("indirect_dword", priv->dir_dev); + remove_proc_entry("mem_gpio_reg", priv->dir_dev); + remove_proc_entry("command_event_reg", priv->dir_dev); + remove_proc_entry("nic_type", priv->dir_dev); + remove_proc_entry("status", priv->dir_dev); + remove_proc_entry("cfg", priv->dir_dev); + remove_proc_entry("dump_errors", priv->dir_dev); + remove_proc_entry("dump_events", priv->dir_dev); + remove_proc_entry("eeprom_delay", priv->dir_dev); + remove_proc_entry("ucode_version", priv->dir_dev); + remove_proc_entry("rtc", priv->dir_dev); + remove_proc_entry(priv->net_dev->name, ipw2200_proc); + priv->dir_dev = NULL; + } + + IPW_DEBUG_INFO("exit %s\n", priv->net_dev->name); +} + +static int ipw2200_proc_init(void) +{ + struct proc_dir_entry *e; + + IPW_DEBUG_INFO("enter\n"); + + ipw2200_proc = create_proc_entry(DRV_NAME, S_IFDIR, proc_net); + if (ipw2200_proc == NULL) + goto fail_ipw2200; + +#ifdef CONFIG_IPW_DEBUG + e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR, + ipw2200_proc); + if (e == NULL) + goto fail_debug; + e->read_proc = proc_get_debug_level; + e->write_proc = proc_set_debug_level; + e->data = NULL; + + IPW_DEBUG_INFO("exit\n"); + return 0; + +fail_debug: + printk(KERN_ERR DRV_NAME ": Unable to initialize " + "/proc/net/" DRV_NAME "/debug_level\n"); + remove_proc_entry(DRV_NAME, proc_net); + ipw2200_proc = NULL; + goto fail; +#endif + +fail_ipw2200: + printk(KERN_ERR DRV_NAME ": Unable to initialize " + "/proc/net/" DRV_NAME "\n"); + +fail: + IPW_DEBUG_INFO("exit on fail\n"); + return -ENOMEM; +} + +static void ipw2200_proc_cleanup(void) +{ + IPW_DEBUG_INFO("enter\n"); + +#ifdef CONFIG_IPW_DEBUG + if (ipw2200_proc) + remove_proc_entry("debug_level", ipw2200_proc); +#endif + remove_proc_entry(DRV_NAME, proc_net); + IPW_DEBUG_INFO("exit\n"); +} +#endif diff -u -p -r -b ipw2200-1.0.1-0/ipw2200.h ipw2200-1.0.1-3/ipw2200.h --- ipw2200-1.0.1-0/ipw2200.h 2005-02-08 23:24:04.000000000 +0100 +++ ipw2200-1.0.1-3/ipw2200.h 2005-03-21 09:46:19.000000000 +0100 @@ -30,7 +30,9 @@ #define WEXT_USECHANNELS 1 #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) #include +#endif #include #include @@ -51,7 +53,18 @@ #define DRV_NAME "ipw2200" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +#include +#include +#define get_seconds() CURRENT_TIME +#include +#define work_struct tq_struct +#define INIT_WORK INIT_TQUEUE +#define queue_work(x,y) schedule_task(y) +#define flush_scheduled_work() flush_scheduled_tasks() +#else #include +#endif #ifndef IRQ_NONE typedef void irqreturn_t; @@ -1007,6 +1020,10 @@ struct ipw_priv { struct pci_dev *pci_dev; struct net_device *net_dev; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + struct proc_dir_entry *dir_dev; +#endif + /* pci hardware address support */ void __iomem *hw_base; unsigned long hw_len; @@ -1102,19 +1119,35 @@ struct ipw_priv { struct workqueue_struct *workqueue; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + struct timer_list adhoc_check_timer; +#else struct work_struct adhoc_check; +#endif struct work_struct associate; struct work_struct disassociate; struct work_struct rx_replenish; struct work_struct request_scan; struct work_struct adapter_restart; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + struct timer_list rf_kill_timer; +#else struct work_struct rf_kill; +#endif struct work_struct up; struct work_struct down; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + struct timer_list gather_stats_timer; +#else struct work_struct gather_stats; +#endif struct work_struct abort_scan; struct work_struct roam; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) + struct timer_list scan_check_timer; +#else struct work_struct scan_check; +#endif struct tasklet_struct irq_tasklet; @@ -1777,4 +1810,12 @@ static inline u32 frame_hdr_len(struct i return retval; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +static struct proc_dir_entry *ipw2200_proc = NULL; +static int ipw2200_proc_init(void); +static void ipw2200_proc_cleanup(void); +static int ipw2200_proc_dev_init(struct ipw_priv *priv); +static void ipw2200_proc_dev_cleanup(struct ipw_priv *priv); +#endif + #endif /* __ipw2200_h__ */