From e73ec1e4437ea655ba2c05017bbb3d5135b8c73b Mon Sep 17 00:00:00 2001 From: Guido Guenther Date: Mon, 8 Jan 2007 22:51:28 +0100 Subject: remove support for kernels <= 2.6.18 --- at76c503.c | 227 +------------------------------------------------------------ 1 file changed, 1 insertion(+), 226 deletions(-) diff --git a/at76c503.c b/at76c503.c index 2a8c40b..cc9d013 100644 --- a/at76c503.c +++ b/at76c503.c @@ -80,21 +80,7 @@ #define PUT_DEV(udev) usb_put_dev((udev)) #define SET_NETDEV_OWNER(ndev,owner) /* not needed anymore ??? */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14) -#define gfp_t int -#endif - -/* Backwards compatibility for usb_kill_urb() */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 10) -# define usb_kill_urb usb_unlink_urb -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 9) -# define eth_hdr(s) (s)->mac.ethernet -# define set_eth_hdr(s,p) (s)->mac.ethernet=(p) -#else -# define set_eth_hdr(s,p) (s)->mac.raw=(unsigned char *)(p) -#endif +#define set_eth_hdr(s,p) (s)->mac.raw=(unsigned char *)(p) /* wireless extension level this source currently supports */ #define WIRELESS_EXT_SUPPORTED 16 @@ -767,190 +753,6 @@ static void scan_hook(int blink) } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8) - -/* == PROC analyze_usb_config == - This procedure analyzes the configuration after the - USB device got reset and find the start of the interface and the - two endpoint descriptors. - Returns < 0 if the descriptors seems to be wrong. */ -static int analyze_usb_config(u8 *cfgd, int cfgd_len, - int *intf_idx, int *ep0_idx, int *ep1_idx) -{ - u8 *cfgd_start = cfgd; - u8 *cfgd_end = cfgd + cfgd_len; /* first byte after config descriptor */ - int nr_intf=0, nr_ep=0; /* number of interface, number of endpoint descr. - found */ - - assert(cfgd_len >= 2); - if (cfgd_len < 2) - return -1; - - if (*(cfgd+1) != USB_DT_CONFIG) { - err("not a config descriptor"); - return -2; - } - - if (*cfgd != USB_DT_CONFIG_SIZE) { - err("invalid length for config descriptor: %d", *cfgd); - return -3; - } - - /* scan the config descr */ - while ((cfgd+1) < cfgd_end) { - - switch (*(cfgd+1)) { - - case USB_DT_INTERFACE: - nr_intf++; - if (nr_intf == 1) - *intf_idx = cfgd - cfgd_start; - break; - - case USB_DT_ENDPOINT: - nr_ep++; - if (nr_ep == 1) - *ep0_idx = cfgd - cfgd_start; - else - if (nr_ep == 2) - *ep1_idx = cfgd - cfgd_start; - break; - default: - ; - } - cfgd += *cfgd; - } /* while ((cfgd+1) < cfgd_end) */ - - if (nr_ep != 2 || nr_intf != 1) { - err("unexpected nr of intf (%d) or endpoints (%d)", - nr_intf, nr_ep); - return -4; - } - - return 0; -} /* end of analyze_usb_config */ - - - -/* == PROC update_usb_intf_descr == - currently (2.6.0-test2) usb_reset_device() does not recognize that - the interface descr. are changed. - This procedure reads the configuration and does a limited parsing of - the interface and endpoint descriptors. - This is IMHO needed until usb_reset_device() is changed inside the - kernel's USB subsystem. - Copied from usb/core/config.c:usb_get_configuration() - - THIS IS VERY UGLY CODE - DO NOT COPY IT ! */ - -#define AT76C503A_USB_CONFDESCR_LEN 0x20 -/* the short configuration descriptor before reset */ -//#define AT76C503A_USB_SHORT_CONFDESCR_LEN 0x19 - -static int update_usb_intf_descr(struct at76c503 *dev) -{ - int intf0; /* begin of intf descriptor in configuration */ - int ep0, ep1; /* begin of endpoint descriptors */ - - struct usb_device *udev = dev->udev; - struct usb_config_descriptor *cfg_desc; - int result = 0, size; - u8 *buffer; - struct usb_host_interface *ifp; - int i; - - dbg(DBG_DEVSTART, "%s: ENTER", __FUNCTION__); - - cfg_desc = (struct usb_config_descriptor *) - kmalloc(AT76C503A_USB_CONFDESCR_LEN, GFP_KERNEL); - if (!cfg_desc) { - err("cannot kmalloc config desc"); - return -ENOMEM; - } - - result = usb_get_descriptor(udev, USB_DT_CONFIG, 0, - cfg_desc, AT76C503A_USB_CONFDESCR_LEN); - if (result < AT76C503A_USB_CONFDESCR_LEN) { - if (result < 0) - err("unable to get descriptor"); - else { - err("config descriptor too short (expected >= %i, got %i)", - AT76C503A_USB_CONFDESCR_LEN, result); - result = -EINVAL; - } - goto err; - } - - /* now check the config descriptor */ - le16_to_cpus(&cfg_desc->wTotalLength); - size = cfg_desc->wTotalLength; - buffer = (u8 *)cfg_desc; - - if (cfg_desc->bNumInterfaces > 1) { - err("found %d interfaces", cfg_desc->bNumInterfaces); - result = - EINVAL; - goto err; - } - - if ((result=analyze_usb_config(buffer, size, &intf0, &ep0, &ep1))) { - - err("analyze_usb_config returned %d for config desc %s", - result, - hex2str(dev->obuf, (u8 *)cfg_desc, - min((int)(sizeof(dev->obuf)-1)/2,size), '\0')); - result=-EINVAL; - goto err; - } - - /* we got the correct config descriptor - update the interface's endpoints */ - ifp = &udev->actconfig->interface[0]->altsetting[0]; - - if (ifp->endpoint) - kfree(ifp->endpoint); - - memcpy(&ifp->desc, buffer+intf0, USB_DT_INTERFACE_SIZE); - - if (!(ifp->endpoint = kmalloc(2 * sizeof(struct usb_host_endpoint), - GFP_KERNEL))) { - result = -ENOMEM; - goto err; - } - memset(ifp->endpoint, 0, 2 * sizeof(struct usb_host_endpoint)); - memcpy(&ifp->endpoint[0].desc, buffer+ep0, USB_DT_ENDPOINT_SIZE); - le16_to_cpus(&ifp->endpoint[0].desc.wMaxPacketSize); - memcpy(&ifp->endpoint[1].desc, buffer+ep1, USB_DT_ENDPOINT_SIZE); - le16_to_cpus(&ifp->endpoint[1].desc.wMaxPacketSize); - - /* we must set the max packet for the new ep (see usb_set_maxpacket() ) */ - -#define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) - for(i=0; i < ifp->desc.bNumEndpoints; i++) { - struct usb_endpoint_descriptor *d = &ifp->endpoint[i].desc; - int b = d->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; - if (usb_endpoint_out(d->bEndpointAddress)) { - if (d->wMaxPacketSize > udev->epmaxpacketout[b]) - udev->epmaxpacketout[b] = d->wMaxPacketSize; - } else { - if (d->wMaxPacketSize > udev->epmaxpacketin[b]) - udev->epmaxpacketin[b] = d->wMaxPacketSize; - } - } - - dbg(DBG_DEVSTART, "%s: ifp %p num_altsetting %d " - "endpoint addr x%x, x%x", __FUNCTION__, - ifp, udev->actconfig->interface[0]->num_altsetting, - ifp->endpoint[0].desc.bEndpointAddress, - ifp->endpoint[1].desc.bEndpointAddress); - result = 0; -err: - kfree(cfg_desc); - dbg(DBG_DEVSTART, "%s: EXIT with %d", __FUNCTION__, result); - return result; -} /* update_usb_intf_descr */ - -#endif /* #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8) */ - - static int at76c503_remap(struct usb_device *udev) { int ret; @@ -2893,27 +2695,7 @@ end_join: usb_reset_device(dev->udev); -/* with 2.6.8 the reset above will cause a disconnect as the USB subsys - recognizes the change in the config descriptors. Subsequently the device - will be registered again. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8) - - //jal: patch the state (patch by Dmitri) - dev->udev->state = USB_STATE_CONFIGURED; - - /* jal: currently (2.6.0-test2 and 2.4.23) - usb_reset_device() does not recognize that - the interface descr. are changed. - This procedure reads the configuration and does a limited parsing of - the interface and endpoint descriptors */ - update_usb_intf_descr(dev); - - /* continue immediately with external fw download */ - set_bit (KEVENT_EXTERNAL_FW, &dev->kevent_flags); -#else - /* kernel >= 2.6.8 */ NEW_STATE(dev, WAIT_FOR_DISCONNECT); -#endif } if (test_bit(KEVENT_EXTERNAL_FW, &dev->kevent_flags)) { @@ -6500,11 +6282,7 @@ static void at76c503_delete_device(struct at76c503 *dev) dbg(DBG_PROC_ENTRY, "%s: ENTER",__FUNCTION__); if (dev->netdev_registered) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17) - if (down_trylock(&rtnl_sem) != 0) { -#else if (rtnl_trylock() == 0) { -#endif info("%s: rtnl_sem already down'ed", __FUNCTION__); } else { /* synchronously calls at76c503_stop() */ @@ -7376,9 +7154,6 @@ static void at76c50x_disconnect(struct usb_interface *interface) /* structure for registering this driver with the USB subsystem */ static struct usb_driver module_usb = { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) - .owner = THIS_MODULE, -#endif .name = DRIVER_NAME, .probe = at76c50x_probe, .disconnect = at76c50x_disconnect, -- cgit v1.2.3