X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fusb%2Fgadget%2Fnet2280.c;h=9498be87a72450dd2e31c9945351a1924f753c90;hb=dca1d9f6d7ae428c193f32bd3e9a4ca13176648b;hp=1facdea56a8a54140d72f4a5d9063fb95cffe003;hpb=2d61bde7a0e630e1906e6478b6b2a7aeaaa8f8da;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index 1facdea..9498be8 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c @@ -2,7 +2,7 @@ * Driver for the PLX NET2280 USB device controller. * Specs and errata are available from . * - * PLX Technology Inc. (formerly NetChip Technology) supported the + * PLX Technology Inc. (formerly NetChip Technology) supported the * development of this driver. * * @@ -26,7 +26,8 @@ * Copyright (C) 2003 David Brownell * Copyright (C) 2003-2005 PLX Technology, Inc. * - * Modified Seth Levy 2005 PLX Technology, Inc. to provide compatibility with 2282 chip + * Modified Seth Levy 2005 PLX Technology, Inc. to provide compatibility + * with 2282 chip * * 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 @@ -46,16 +47,13 @@ #undef DEBUG /* messages on error and most fault paths */ #undef VERBOSE /* extra debug messages (success too) */ -#include #include #include #include #include #include #include -#include #include -#include #include #include #include @@ -63,8 +61,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -86,7 +84,7 @@ static const char driver_name [] = "net2280"; static const char driver_desc [] = DRIVER_DESC; static const char ep0name [] = "ep0"; -static const char *ep_name [] = { +static const char *const ep_name [] = { ep0name, "ep-a", "ep-b", "ep-c", "ep-d", "ep-e", "ep-f", @@ -144,8 +142,8 @@ static char *type_string (u8 bmAttributes) #include "net2280.h" -#define valid_bit __constant_cpu_to_le32 (1 << VALID_BIT) -#define dma_done_ie __constant_cpu_to_le32 (1 << DMA_DONE_INTERRUPT_ENABLE) +#define valid_bit cpu_to_le32 (1 << VALID_BIT) +#define dma_done_ie cpu_to_le32 (1 << DMA_DONE_INTERRUPT_ENABLE) /*-------------------------------------------------------------------------*/ @@ -180,6 +178,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) /* ep_reset() has already been called */ ep->stopped = 0; + ep->wedged = 0; ep->out_overflow = 0; /* set speed-dependent max packet; may kick in high bandwidth */ @@ -226,7 +225,9 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) if (!ep->is_in) writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp); else if (dev->pdev->device != 0x2280) { - /* Added for 2282, Don't use nak packets on an in endpoint, this was ignored on 2280 */ + /* Added for 2282, Don't use nak packets on an in endpoint, + * this was ignored on 2280 + */ writel ((1 << CLEAR_NAK_OUT_PACKETS) | (1 << CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp); } @@ -289,7 +290,7 @@ static int handshake (u32 __iomem *ptr, u32 mask, u32 done, int usec) return -ETIMEDOUT; } -static struct usb_ep_ops net2280_ep_ops; +static const struct usb_ep_ops net2280_ep_ops; static void ep_reset (struct net2280_regs __iomem *regs, struct net2280_ep *ep) { @@ -424,7 +425,7 @@ net2280_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags) return NULL; } td->dmacount = 0; /* not VALID */ - td->dmaaddr = __constant_cpu_to_le32 (DMA_ADDR_INVALID); + td->dmaaddr = cpu_to_le32 (DMA_ADDR_INVALID); td->dmadesc = td->dmaaddr; req->td = td; } @@ -450,91 +451,6 @@ net2280_free_request (struct usb_ep *_ep, struct usb_request *_req) /*-------------------------------------------------------------------------*/ -#undef USE_KMALLOC - -/* many common platforms have dma-coherent caches, which means that it's - * safe to use kmalloc() memory for all i/o buffers without using any - * cache flushing calls. (unless you're trying to share cache lines - * between dma and non-dma activities, which is a slow idea in any case.) - * - * other platforms need more care, with 2.5 having a moderately general - * solution (which falls down for allocations smaller than one page) - * that improves significantly on the 2.4 PCI allocators by removing - * the restriction that memory never be freed in_interrupt(). - */ -#if defined(CONFIG_X86) -#define USE_KMALLOC - -#elif defined(CONFIG_PPC) && !defined(CONFIG_NOT_COHERENT_CACHE) -#define USE_KMALLOC - -#elif defined(CONFIG_MIPS) && !defined(CONFIG_DMA_NONCOHERENT) -#define USE_KMALLOC - -/* FIXME there are other cases, including an x86-64 one ... */ -#endif - -/* allocating buffers this way eliminates dma mapping overhead, which - * on some platforms will mean eliminating a per-io buffer copy. with - * some kinds of system caches, further tweaks may still be needed. - */ -static void * -net2280_alloc_buffer ( - struct usb_ep *_ep, - unsigned bytes, - dma_addr_t *dma, - gfp_t gfp_flags -) -{ - void *retval; - struct net2280_ep *ep; - - ep = container_of (_ep, struct net2280_ep, ep); - if (!_ep) - return NULL; - *dma = DMA_ADDR_INVALID; - -#if defined(USE_KMALLOC) - retval = kmalloc(bytes, gfp_flags); - if (retval) - *dma = virt_to_phys(retval); -#else - if (ep->dma) { - /* the main problem with this call is that it wastes memory - * on typical 1/N page allocations: it allocates 1-N pages. - */ -#warning Using dma_alloc_coherent even with buffers smaller than a page. - retval = dma_alloc_coherent(&ep->dev->pdev->dev, - bytes, dma, gfp_flags); - } else - retval = kmalloc(bytes, gfp_flags); -#endif - return retval; -} - -static void -net2280_free_buffer ( - struct usb_ep *_ep, - void *buf, - dma_addr_t dma, - unsigned bytes -) { - /* free memory into the right allocator */ -#ifndef USE_KMALLOC - if (dma != DMA_ADDR_INVALID) { - struct net2280_ep *ep; - - ep = container_of(_ep, struct net2280_ep, ep); - if (!_ep) - return; - dma_free_coherent(&ep->dev->pdev->dev, bytes, buf, dma); - } else -#endif - kfree (buf); -} - -/*-------------------------------------------------------------------------*/ - /* load a packet into the fifo we use for usb IN transfers. * works for all endpoints. * @@ -738,7 +654,8 @@ fill_dma_desc (struct net2280_ep *ep, struct net2280_request *req, int valid) */ if (ep->is_in) dmacount |= (1 << DMA_DIRECTION); - if ((!ep->is_in && (dmacount % ep->ep.maxpacket) != 0) || ep->dev->pdev->device != 0x2280) + if ((!ep->is_in && (dmacount % ep->ep.maxpacket) != 0) + || ep->dev->pdev->device != 0x2280) dmacount |= (1 << END_OF_CHAIN); req->valid = valid; @@ -752,7 +669,7 @@ fill_dma_desc (struct net2280_ep *ep, struct net2280_request *req, int valid) /* 2280 may be polling VALID_BIT through ep->dma->dmadesc */ wmb (); - td->dmacount = cpu_to_le32p (&dmacount); + td->dmacount = cpu_to_le32(dmacount); } static const u32 dmactl_default = @@ -813,7 +730,7 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req) /* previous OUT packet might have been short */ if (!ep->is_in && ((tmp = readl (&ep->regs->ep_stat)) - & (1 << NAK_OUT_PACKETS)) != 0) { + & (1 << NAK_OUT_PACKETS)) != 0) { writel ((1 << SHORT_PACKET_TRANSFERRED_INTERRUPT), &ep->regs->ep_stat); @@ -858,7 +775,7 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req) fill_dma_desc (ep, req, 1); if (!use_dma_chaining) - req->td->dmacount |= __constant_cpu_to_le32 (1 << END_OF_CHAIN); + req->td->dmacount |= cpu_to_le32 (1 << END_OF_CHAIN); start_queue (ep, tmp, req->td_dma); } @@ -1028,6 +945,7 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) } /* else the irq handler advances the queue. */ + ep->responded = 1; if (req) list_add_tail (&req->queue, &ep->queue); done: @@ -1090,7 +1008,7 @@ static void scan_dma_completions (struct net2280_ep *ep) * 0122, and 0124; not all cases trigger the warning. */ if ((tmp & (1 << NAK_OUT_PACKETS)) == 0) { - WARN (ep->dev, "%s lost packet sync!\n", + WARNING (ep->dev, "%s lost packet sync!\n", ep->ep.name); req->req.status = -EOVERFLOW; } else if ((tmp = readl (&ep->regs->ep_avail)) != 0) { @@ -1301,7 +1219,7 @@ static int net2280_dequeue (struct usb_ep *_ep, struct usb_request *_req) static int net2280_fifo_status (struct usb_ep *_ep); static int -net2280_set_halt (struct usb_ep *_ep, int value) +net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged) { struct net2280_ep *ep; unsigned long flags; @@ -1322,16 +1240,21 @@ net2280_set_halt (struct usb_ep *_ep, int value) else if (ep->is_in && value && net2280_fifo_status (_ep) != 0) retval = -EAGAIN; else { - VDEBUG (ep->dev, "%s %s halt\n", _ep->name, - value ? "set" : "clear"); + VDEBUG (ep->dev, "%s %s %s\n", _ep->name, + value ? "set" : "clear", + wedged ? "wedge" : "halt"); /* set/clear, then synch memory views with the device */ if (value) { if (ep->num == 0) ep->dev->protocol_stall = 1; else set_halt (ep); - } else + if (wedged) + ep->wedged = 1; + } else { clear_halt (ep); + ep->wedged = 0; + } (void) readl (&ep->regs->ep_rsp); } spin_unlock_irqrestore (&ep->dev->lock, flags); @@ -1340,6 +1263,20 @@ net2280_set_halt (struct usb_ep *_ep, int value) } static int +net2280_set_halt(struct usb_ep *_ep, int value) +{ + return net2280_set_halt_and_wedge(_ep, value, 0); +} + +static int +net2280_set_wedge(struct usb_ep *_ep) +{ + if (!_ep || _ep->name == ep0name) + return -EINVAL; + return net2280_set_halt_and_wedge(_ep, 1, 1); +} + +static int net2280_fifo_status (struct usb_ep *_ep) { struct net2280_ep *ep; @@ -1374,20 +1311,18 @@ net2280_fifo_flush (struct usb_ep *_ep) (void) readl (&ep->regs->ep_rsp); } -static struct usb_ep_ops net2280_ep_ops = { +static const struct usb_ep_ops net2280_ep_ops = { .enable = net2280_enable, .disable = net2280_disable, .alloc_request = net2280_alloc_request, .free_request = net2280_free_request, - .alloc_buffer = net2280_alloc_buffer, - .free_buffer = net2280_free_buffer, - .queue = net2280_queue, .dequeue = net2280_dequeue, .set_halt = net2280_set_halt, + .set_wedge = net2280_set_wedge, .fifo_status = net2280_fifo_status, .fifo_flush = net2280_fifo_flush, }; @@ -1504,8 +1439,8 @@ show_function (struct device *_dev, struct device_attribute *attr, char *buf) } static DEVICE_ATTR (function, S_IRUGO, show_function, NULL); -static ssize_t -show_registers (struct device *_dev, struct device_attribute *attr, char *buf) +static ssize_t net2280_show_registers(struct device *_dev, + struct device_attribute *attr, char *buf) { struct net2280 *dev; char *next; @@ -1632,7 +1567,7 @@ show_registers (struct device *_dev, struct device_attribute *attr, char *buf) } /* Indexed Registers */ - // none yet + // none yet /* Statistics */ t = scnprintf (next, size, "\nirqs: "); @@ -1657,7 +1592,7 @@ show_registers (struct device *_dev, struct device_attribute *attr, char *buf) return PAGE_SIZE - size; } -static DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL); +static DEVICE_ATTR(registers, S_IRUGO, net2280_show_registers, NULL); static ssize_t show_queues (struct device *_dev, struct device_attribute *attr, char *buf) @@ -1692,11 +1627,11 @@ show_queues (struct device *_dev, struct device_attribute *attr, char *buf) ({ char *val; switch (d->bmAttributes & 0x03) { case USB_ENDPOINT_XFER_BULK: - val = "bulk"; break; + val = "bulk"; break; case USB_ENDPOINT_XFER_INT: - val = "intr"; break; + val = "intr"; break; default: - val = "iso"; break; + val = "iso"; break; }; val; }), le16_to_cpu (d->wMaxPacketSize) & 0x1fff, ep->dma ? "dma" : "pio", ep->fifo_size @@ -1762,8 +1697,8 @@ static DEVICE_ATTR (queues, S_IRUGO, show_queues, NULL); #else -#define device_create_file(a,b) do {} while (0) -#define device_remove_file device_create_file +#define device_create_file(a,b) (0) +#define device_remove_file(a,b) do { } while (0) #endif @@ -1809,8 +1744,8 @@ extern int net2280_set_fifo_mode (struct usb_gadget *gadget, int mode); * net2280_set_fifo_mode - change allocation of fifo buffers * @gadget: access to the net2280 device that will be updated * @mode: 0 for default, four 1kB buffers (ep-a through ep-d); - * 1 for two 2kB buffers (ep-a and ep-b only); - * 2 for one 2kB buffer (ep-a) and two 1kB ones (ep-b, ep-c). + * 1 for two 2kB buffers (ep-a and ep-b only); + * 2 for one 2kB buffer (ep-a) and two 1kB ones (ep-b, ep-c). * * returns zero on success, else negative errno. when this succeeds, * the contents of gadget->ep_list may have changed. @@ -2007,7 +1942,6 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver) if (!driver || driver->speed != USB_SPEED_HIGH || !driver->bind - || !driver->unbind || !driver->setup) return -EINVAL; if (!dev) @@ -2032,8 +1966,10 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver) return retval; } - device_create_file (&dev->pdev->dev, &dev_attr_function); - device_create_file (&dev->pdev->dev, &dev_attr_queues); + retval = device_create_file (&dev->pdev->dev, &dev_attr_function); + if (retval) goto err_unbind; + retval = device_create_file (&dev->pdev->dev, &dev_attr_queues); + if (retval) goto err_func; /* ... then enable host detection and ep0; and we're ready * for set_configuration as well as eventual disconnect. @@ -2048,6 +1984,14 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver) /* pci writes may still be posted */ return 0; + +err_func: + device_remove_file (&dev->pdev->dev, &dev_attr_function); +err_unbind: + driver->unbind (&dev->gadget); + dev->gadget.dev.driver = NULL; + dev->driver = NULL; + return retval; } EXPORT_SYMBOL (usb_gadget_register_driver); @@ -2084,7 +2028,7 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) if (!dev) return -ENODEV; - if (!driver || driver != dev->driver) + if (!driver || driver != dev->driver || !driver->unbind) return -EINVAL; spin_lock_irqsave (&dev->lock, flags); @@ -2166,7 +2110,8 @@ static void handle_ep_small (struct net2280_ep *ep) ep->stopped = 1; set_halt (ep); mode = 2; - } else if (!req && !ep->stopped) + } else if (ep->responded && + !req && !ep->stopped) write_fifo (ep, NULL); } } else { @@ -2181,7 +2126,7 @@ static void handle_ep_small (struct net2280_ep *ep) } else if (((t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT)) && req && req->req.actual == req->req.length) - || !req) { + || (ep->responded && !req)) { ep->dev->protocol_stall = 1; set_halt (ep); ep->stopped = 1; @@ -2242,7 +2187,8 @@ static void handle_ep_small (struct net2280_ep *ep) req->td->dmacount = 0; t = readl (&ep->regs->ep_avail); dma_done (ep, req, count, - (ep->out_overflow || t) ? -EOVERFLOW : 0); + (ep->out_overflow || t) + ? -EOVERFLOW : 0); } /* also flush to prevent erratum 0106 trouble */ @@ -2412,15 +2358,15 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) , &ep->regs->ep_stat); u.raw [0] = readl (&dev->usb->setup0123); u.raw [1] = readl (&dev->usb->setup4567); - + cpu_to_le32s (&u.raw [0]); cpu_to_le32s (&u.raw [1]); tmp = 0; -#define w_value le16_to_cpup (&u.r.wValue) -#define w_index le16_to_cpup (&u.r.wIndex) -#define w_length le16_to_cpup (&u.r.wLength) +#define w_value le16_to_cpu(u.r.wValue) +#define w_index le16_to_cpu(u.r.wIndex) +#define w_length le16_to_cpu(u.r.wLength) /* ack the irq */ writel (1 << SETUP_PACKET_INTERRUPT, &dev->regs->irqstat0); @@ -2446,6 +2392,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) /* we made the hardware handle most lowlevel requests; * everything else goes uplevel to the gadget code. */ + ep->responded = 1; switch (u.r.bRequest) { case USB_REQ_GET_STATUS: { struct net2280_ep *e; @@ -2460,9 +2407,9 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) if (readl (&e->regs->ep_rsp) & (1 << SET_ENDPOINT_HALT)) - status = __constant_cpu_to_le32 (1); + status = cpu_to_le32 (1); else - status = __constant_cpu_to_le32 (0); + status = cpu_to_le32 (0); /* don't bother with a request object! */ writel (0, &dev->epregs [0].ep_irqenb); @@ -2484,9 +2431,14 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) goto do_stall; if ((e = get_ep_by_addr (dev, w_index)) == 0) goto do_stall; - clear_halt (e); + if (e->wedged) { + VDEBUG(dev, "%s wedged, halt not cleared\n", + ep->ep.name); + } else { + VDEBUG(dev, "%s clear halt\n", ep->ep.name); + clear_halt(e); + } allow_status (ep); - VDEBUG (dev, "%s clear halt\n", ep->ep.name); goto next_endpoints; } break; @@ -2501,6 +2453,8 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) goto do_stall; if ((e = get_ep_by_addr (dev, w_index)) == 0) goto do_stall; + if (e->ep.name == ep0name) + goto do_stall; set_halt (e); allow_status (ep); VDEBUG (dev, "%s set halt\n", ep->ep.name); @@ -2509,11 +2463,12 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) break; default: delegate: - VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x" + VDEBUG (dev, "setup %02x.%02x v%04x i%04x l%04x " "ep_cfg %08x\n", u.r.bRequestType, u.r.bRequest, w_value, w_index, w_length, readl (&ep->regs->ep_cfg)); + ep->responded = 0; spin_unlock (&dev->lock); tmp = dev->driver->setup (&dev->gadget, &u.r); spin_lock (&dev->lock); @@ -2579,14 +2534,16 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat) /* VBUS disconnect is indicated by VBUS_PIN and VBUS_INTERRUPT set. * Root Port Reset is indicated by ROOT_PORT_RESET_INTERRRUPT set and - * both HIGH_SPEED and FULL_SPEED clear (as ROOT_PORT_RESET_INTERRUPT + * both HIGH_SPEED and FULL_SPEED clear (as ROOT_PORT_RESET_INTERRUPT * only indicates a change in the reset state). */ if (stat & tmp) { writel (tmp, &dev->regs->irqstat1); - if ((((stat & (1 << ROOT_PORT_RESET_INTERRUPT)) && - ((readl (&dev->usb->usbstat) & mask) == 0)) - || ((readl (&dev->usb->usbctl) & (1 << VBUS_PIN)) == 0) + if ((((stat & (1 << ROOT_PORT_RESET_INTERRUPT)) + && ((readl (&dev->usb->usbstat) & mask) + == 0)) + || ((readl (&dev->usb->usbctl) + & (1 << VBUS_PIN)) == 0) ) && ( dev->gadget.speed != USB_SPEED_UNKNOWN)) { DEBUG (dev, "disconnect %s\n", dev->driver->driver.name); @@ -2710,7 +2667,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat) req = list_entry (ep->queue.next, struct net2280_request, queue); dmacount = req->td->dmacount; - dmacount &= __constant_cpu_to_le32 ( + dmacount &= cpu_to_le32 ( (1 << VALID_BIT) | DMA_BYTE_COUNT_MASK); if (dmacount && (dmacount & valid_bit) == 0) @@ -2738,7 +2695,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat) DEBUG (dev, "unhandled irqstat1 %08x\n", stat); } -static irqreturn_t net2280_irq (int irq, void *_dev, struct pt_regs * r) +static irqreturn_t net2280_irq (int irq, void *_dev) { struct net2280 *dev = _dev; @@ -2774,13 +2731,7 @@ static void net2280_remove (struct pci_dev *pdev) { struct net2280 *dev = pci_get_drvdata (pdev); - /* start with the driver above us */ - if (dev->driver) { - /* should have been done already by driver model core */ - WARN (dev, "pci remove, driver '%s' is still registered\n", - dev->driver->driver.name); - usb_gadget_unregister_driver (dev->driver); - } + BUG_ON(dev->driver); /* then clean up the resources we allocated during probe() */ net2280_led_shutdown (dev); @@ -2832,7 +2783,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) } /* alloc, and start init */ - dev = kzalloc (sizeof *dev, SLAB_KERNEL); + dev = kzalloc (sizeof *dev, GFP_KERNEL); if (dev == NULL){ retval = -ENOMEM; goto done; @@ -2845,7 +2796,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) dev->gadget.is_dualspeed = 1; /* the "gadget" abstracts/virtualizes the controller */ - strcpy (dev->gadget.dev.bus_id, "gadget"); + dev_set_name(&dev->gadget.dev, "gadget"); dev->gadget.dev.parent = &pdev->dev; dev->gadget.dev.dma_mask = pdev->dev.dma_mask; dev->gadget.dev.release = gadget_release; @@ -2853,7 +2804,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) /* now all the pci goodies ... */ if (pci_enable_device (pdev) < 0) { - retval = -ENODEV; + retval = -ENODEV; goto done; } dev->enabled = 1; @@ -2871,6 +2822,10 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) } dev->region = 1; + /* FIXME provide firmware download interface to put + * 8051 code into the chip, e.g. to turn on PCI PM. + */ + base = ioremap_nocache (resource, len); if (base == NULL) { DEBUG (dev, "can't map memory\n"); @@ -2896,7 +2851,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) goto done; } - if (request_irq (pdev->irq, net2280_irq, SA_SHIRQ, driver_name, dev) + if (request_irq (pdev->irq, net2280_irq, IRQF_SHARED, driver_name, dev) != 0) { ERROR (dev, "request interrupt %d failed\n", pdev->irq); retval = -EBUSY; @@ -2926,7 +2881,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) goto done; } td->dmacount = 0; /* not VALID */ - td->dmaaddr = __constant_cpu_to_le32 (DMA_ADDR_INVALID); + td->dmaaddr = cpu_to_le32 (DMA_ADDR_INVALID); td->dmadesc = td->dmaaddr; dev->ep [i].dummy = td; } @@ -2940,7 +2895,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) , &dev->pci->pcimstctl); /* erratum 0115 shouldn't appear: Linux inits PCI_LATENCY_TIMER */ pci_set_master (pdev); - pci_set_mwi (pdev); + pci_try_set_mwi (pdev); /* ... also flushes any posted pci writes */ dev->chiprev = get_idx_reg (dev->regs, REG_CHIPREV) & 0xffff; @@ -2955,8 +2910,10 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) : "disabled"); the_controller = dev; - device_register (&dev->gadget.dev); - device_create_file (&pdev->dev, &dev_attr_registers); + retval = device_register (&dev->gadget.dev); + if (retval) goto done; + retval = device_create_file (&pdev->dev, &dev_attr_registers); + if (retval) goto done; return 0; @@ -2985,16 +2942,16 @@ static void net2280_shutdown (struct pci_dev *pdev) /*-------------------------------------------------------------------------*/ -static struct pci_device_id pci_ids [] = { { - .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), - .class_mask = ~0, +static const struct pci_device_id pci_ids [] = { { + .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), + .class_mask = ~0, .vendor = 0x17cc, .device = 0x2280, .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, }, { - .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), - .class_mask = ~0, + .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), + .class_mask = ~0, .vendor = 0x17cc, .device = 0x2282, .subvendor = PCI_ANY_ID,