2 * Copyright (c) 1999-2005 Petko Manolov (petkan@users.sourceforge.net)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9 * .... Most of the time spent on reading sources & docs.
10 * v0.2.x First official release for the Linux kernel.
11 * v0.3.0 Beutified and structured, some bugs fixed.
12 * v0.3.x URBifying bulk requests and bugfixing. First relatively
13 * stable release. Still can touch device's registers only
15 * v0.4.0 Control messages remained unurbified are now URBs.
16 * Now we can touch the HW at any time.
17 * v0.4.9 Control urbs again use process context to wait. Argh...
18 * Some long standing bugs (enable_net_traffic) fixed.
19 * Also nasty trick about resubmiting control urb from
20 * interrupt context used. Please let me know how it
21 * behaves. Pegasus II support added since this version.
22 * TODO: suppressing HCD warnings spewage on disconnect.
23 * v0.4.13 Ethernet address is now set at probe(), not at open()
24 * time as this seems to break dhcpd.
25 * v0.5.0 branch to 2.5.x kernels
26 * v0.5.1 ethtool support added
27 * v0.5.5 rx socket buffers are in a pool and the their allocation
28 * is out of the interrupt routine.
33 #include <linux/sched.h>
34 #include <linux/slab.h>
35 #include <linux/init.h>
36 #include <linux/delay.h>
37 #include <linux/netdevice.h>
38 #include <linux/etherdevice.h>
39 #include <linux/ethtool.h>
40 #include <linux/mii.h>
41 #include <linux/usb.h>
42 #include <linux/module.h>
43 #include <asm/byteorder.h>
44 #include <asm/uaccess.h>
50 #define DRIVER_VERSION "v0.6.12 (2005/01/13)"
51 #define DRIVER_AUTHOR "Petko Manolov <petkan@users.sourceforge.net>"
52 #define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver"
54 static const char driver_name
[] = "pegasus";
56 #undef PEGASUS_WRITE_EEPROM
57 #define BMSR_MEDIA (BMSR_10HALF | BMSR_10FULL | BMSR_100HALF | \
58 BMSR_100FULL | BMSR_ANEGCAPABLE)
60 static int loopback
= 0;
61 static int mii_mode
= 0;
63 static struct usb_eth_dev usb_dev_id
[] = {
64 #define PEGASUS_DEV(pn, vid, pid, flags) \
65 {.name = pn, .vendor = vid, .device = pid, .private = flags},
71 static struct usb_device_id pegasus_ids
[] = {
72 #define PEGASUS_DEV(pn, vid, pid, flags) \
73 {.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = vid, .idProduct = pid},
79 MODULE_AUTHOR(DRIVER_AUTHOR
);
80 MODULE_DESCRIPTION(DRIVER_DESC
);
81 MODULE_LICENSE("GPL");
82 module_param(loopback
, bool, 0);
83 module_param(mii_mode
, bool, 0);
84 MODULE_PARM_DESC(loopback
, "Enable MAC loopback mode (bit 0)");
85 MODULE_PARM_DESC(mii_mode
, "Enable HomePNA mode (bit 0),default=MII mode = 0");
87 /* use ethtool to change the level for any given device */
88 static int msg_level
= -1;
89 module_param (msg_level
, int, 0);
90 MODULE_PARM_DESC (msg_level
, "Override default message level");
92 MODULE_DEVICE_TABLE(usb
, pegasus_ids
);
94 static int update_eth_regs_async(pegasus_t
*);
95 /* Aargh!!! I _really_ hate such tweaks */
96 static void ctrl_callback(struct urb
*urb
, struct pt_regs
*regs
)
98 pegasus_t
*pegasus
= urb
->context
;
103 switch (urb
->status
) {
105 if (pegasus
->flags
& ETH_REGS_CHANGE
) {
106 pegasus
->flags
&= ~ETH_REGS_CHANGE
;
107 pegasus
->flags
|= ETH_REGS_CHANGED
;
108 update_eth_regs_async(pegasus
);
117 if (netif_msg_drv(pegasus
))
118 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
119 __FUNCTION__
, urb
->status
);
121 pegasus
->flags
&= ~ETH_REGS_CHANGED
;
122 wake_up(&pegasus
->ctrl_wait
);
125 static int get_registers(pegasus_t
* pegasus
, __u16 indx
, __u16 size
,
130 DECLARE_WAITQUEUE(wait
, current
);
132 buffer
= kmalloc(size
, GFP_KERNEL
);
134 if (netif_msg_drv(pegasus
))
135 dev_warn(&pegasus
->intf
->dev
, "out of memory in %s\n",
139 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
140 set_current_state(TASK_UNINTERRUPTIBLE
);
141 while (pegasus
->flags
& ETH_REGS_CHANGED
)
143 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
144 set_current_state(TASK_RUNNING
);
146 pegasus
->dr
.bRequestType
= PEGASUS_REQT_READ
;
147 pegasus
->dr
.bRequest
= PEGASUS_REQ_GET_REGS
;
148 pegasus
->dr
.wValue
= cpu_to_le16(0);
149 pegasus
->dr
.wIndex
= cpu_to_le16p(&indx
);
150 pegasus
->dr
.wLength
= cpu_to_le16p(&size
);
151 pegasus
->ctrl_urb
->transfer_buffer_length
= size
;
153 usb_fill_control_urb(pegasus
->ctrl_urb
, pegasus
->usb
,
154 usb_rcvctrlpipe(pegasus
->usb
, 0),
155 (char *) &pegasus
->dr
,
156 buffer
, size
, ctrl_callback
, pegasus
);
158 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
159 set_current_state(TASK_UNINTERRUPTIBLE
);
161 /* using ATOMIC, we'd never wake up if we slept */
162 if ((ret
= usb_submit_urb(pegasus
->ctrl_urb
, GFP_ATOMIC
))) {
163 if (netif_msg_drv(pegasus
))
164 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
171 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
172 memcpy(data
, buffer
, size
);
178 static int set_registers(pegasus_t
* pegasus
, __u16 indx
, __u16 size
,
183 DECLARE_WAITQUEUE(wait
, current
);
185 buffer
= kmalloc(size
, GFP_KERNEL
);
187 if (netif_msg_drv(pegasus
))
188 dev_warn(&pegasus
->intf
->dev
, "out of memory in %s\n",
192 memcpy(buffer
, data
, size
);
194 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
195 set_current_state(TASK_UNINTERRUPTIBLE
);
196 while (pegasus
->flags
& ETH_REGS_CHANGED
)
198 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
199 set_current_state(TASK_RUNNING
);
201 pegasus
->dr
.bRequestType
= PEGASUS_REQT_WRITE
;
202 pegasus
->dr
.bRequest
= PEGASUS_REQ_SET_REGS
;
203 pegasus
->dr
.wValue
= cpu_to_le16(0);
204 pegasus
->dr
.wIndex
= cpu_to_le16p(&indx
);
205 pegasus
->dr
.wLength
= cpu_to_le16p(&size
);
206 pegasus
->ctrl_urb
->transfer_buffer_length
= size
;
208 usb_fill_control_urb(pegasus
->ctrl_urb
, pegasus
->usb
,
209 usb_sndctrlpipe(pegasus
->usb
, 0),
210 (char *) &pegasus
->dr
,
211 buffer
, size
, ctrl_callback
, pegasus
);
213 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
214 set_current_state(TASK_UNINTERRUPTIBLE
);
216 if ((ret
= usb_submit_urb(pegasus
->ctrl_urb
, GFP_ATOMIC
))) {
217 if (netif_msg_drv(pegasus
))
218 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
225 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
231 static int set_register(pegasus_t
* pegasus
, __u16 indx
, __u8 data
)
235 DECLARE_WAITQUEUE(wait
, current
);
237 tmp
= kmalloc(1, GFP_KERNEL
);
239 if (netif_msg_drv(pegasus
))
240 dev_warn(&pegasus
->intf
->dev
, "out of memory in %s\n",
244 memcpy(tmp
, &data
, 1);
245 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
246 set_current_state(TASK_UNINTERRUPTIBLE
);
247 while (pegasus
->flags
& ETH_REGS_CHANGED
)
249 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
250 set_current_state(TASK_RUNNING
);
252 pegasus
->dr
.bRequestType
= PEGASUS_REQT_WRITE
;
253 pegasus
->dr
.bRequest
= PEGASUS_REQ_SET_REG
;
254 pegasus
->dr
.wValue
= cpu_to_le16(data
);
255 pegasus
->dr
.wIndex
= cpu_to_le16p(&indx
);
256 pegasus
->dr
.wLength
= cpu_to_le16(1);
257 pegasus
->ctrl_urb
->transfer_buffer_length
= 1;
259 usb_fill_control_urb(pegasus
->ctrl_urb
, pegasus
->usb
,
260 usb_sndctrlpipe(pegasus
->usb
, 0),
261 (char *) &pegasus
->dr
,
262 &tmp
, 1, ctrl_callback
, pegasus
);
264 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
265 set_current_state(TASK_UNINTERRUPTIBLE
);
267 if ((ret
= usb_submit_urb(pegasus
->ctrl_urb
, GFP_ATOMIC
))) {
268 if (netif_msg_drv(pegasus
))
269 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
276 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
282 static int update_eth_regs_async(pegasus_t
* pegasus
)
286 pegasus
->dr
.bRequestType
= PEGASUS_REQT_WRITE
;
287 pegasus
->dr
.bRequest
= PEGASUS_REQ_SET_REGS
;
288 pegasus
->dr
.wValue
= 0;
289 pegasus
->dr
.wIndex
= cpu_to_le16(EthCtrl0
);
290 pegasus
->dr
.wLength
= cpu_to_le16(3);
291 pegasus
->ctrl_urb
->transfer_buffer_length
= 3;
293 usb_fill_control_urb(pegasus
->ctrl_urb
, pegasus
->usb
,
294 usb_sndctrlpipe(pegasus
->usb
, 0),
295 (char *) &pegasus
->dr
,
296 pegasus
->eth_regs
, 3, ctrl_callback
, pegasus
);
298 if ((ret
= usb_submit_urb(pegasus
->ctrl_urb
, GFP_ATOMIC
)))
299 if (netif_msg_drv(pegasus
))
300 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
306 static int read_mii_word(pegasus_t
* pegasus
, __u8 phy
, __u8 indx
, __u16
* regd
)
309 __u8 data
[4] = { phy
, 0, 0, indx
};
313 ret
= set_register(pegasus
, PhyCtrl
, 0);
314 ret
= set_registers(pegasus
, PhyAddr
, sizeof (data
), data
);
315 ret
= set_register(pegasus
, PhyCtrl
, (indx
| PHY_READ
));
316 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
317 ret
= get_registers(pegasus
, PhyCtrl
, 1, data
);
318 if (data
[0] & PHY_DONE
)
321 if (i
< REG_TIMEOUT
) {
322 ret
= get_registers(pegasus
, PhyData
, 2, ®di
);
323 *regd
= le16_to_cpu(regdi
);
326 if (netif_msg_drv(pegasus
))
327 dev_warn(&pegasus
->intf
->dev
, "fail %s\n", __FUNCTION__
);
332 static int mdio_read(struct net_device
*dev
, int phy_id
, int loc
)
334 pegasus_t
*pegasus
= (pegasus_t
*) netdev_priv(dev
);
337 read_mii_word(pegasus
, phy_id
, loc
, &res
);
341 static int write_mii_word(pegasus_t
* pegasus
, __u8 phy
, __u8 indx
, __u16 regd
)
344 __u8 data
[4] = { phy
, 0, 0, indx
};
348 data
[2] = (u8
) (regd
>> 8);
349 ret
= set_register(pegasus
, PhyCtrl
, 0);
350 ret
= set_registers(pegasus
, PhyAddr
, sizeof(data
), data
);
351 ret
= set_register(pegasus
, PhyCtrl
, (indx
| PHY_WRITE
));
352 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
353 ret
= get_registers(pegasus
, PhyCtrl
, 1, data
);
354 if (data
[0] & PHY_DONE
)
360 if (netif_msg_drv(pegasus
))
361 dev_warn(&pegasus
->intf
->dev
, "fail %s\n", __FUNCTION__
);
365 static void mdio_write(struct net_device
*dev
, int phy_id
, int loc
, int val
)
367 pegasus_t
*pegasus
= (pegasus_t
*) netdev_priv(dev
);
369 write_mii_word(pegasus
, phy_id
, loc
, val
);
372 static int read_eprom_word(pegasus_t
* pegasus
, __u8 index
, __u16
* retdata
)
379 ret
= set_register(pegasus
, EpromCtrl
, 0);
380 ret
= set_register(pegasus
, EpromOffset
, index
);
381 ret
= set_register(pegasus
, EpromCtrl
, EPROM_READ
);
383 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
384 ret
= get_registers(pegasus
, EpromCtrl
, 1, &tmp
);
385 if (tmp
& EPROM_DONE
)
388 if (i
< REG_TIMEOUT
) {
389 ret
= get_registers(pegasus
, EpromData
, 2, &retdatai
);
390 *retdata
= le16_to_cpu(retdatai
);
394 if (netif_msg_drv(pegasus
))
395 dev_warn(&pegasus
->intf
->dev
, "fail %s\n", __FUNCTION__
);
399 #ifdef PEGASUS_WRITE_EEPROM
400 static inline void enable_eprom_write(pegasus_t
* pegasus
)
405 ret
= get_registers(pegasus
, EthCtrl2
, 1, &tmp
);
406 ret
= set_register(pegasus
, EthCtrl2
, tmp
| EPROM_WR_ENABLE
);
409 static inline void disable_eprom_write(pegasus_t
* pegasus
)
414 ret
= get_registers(pegasus
, EthCtrl2
, 1, &tmp
);
415 ret
= set_register(pegasus
, EpromCtrl
, 0);
416 ret
= set_register(pegasus
, EthCtrl2
, tmp
& ~EPROM_WR_ENABLE
);
419 static int write_eprom_word(pegasus_t
* pegasus
, __u8 index
, __u16 data
)
422 __u8 tmp
, d
[4] = { 0x3f, 0, 0, EPROM_WRITE
};
425 ret
= set_registers(pegasus
, EpromOffset
, 4, d
);
426 enable_eprom_write(pegasus
);
427 ret
= set_register(pegasus
, EpromOffset
, index
);
428 ret
= set_registers(pegasus
, EpromData
, 2, &data
);
429 ret
= set_register(pegasus
, EpromCtrl
, EPROM_WRITE
);
431 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
432 ret
= get_registers(pegasus
, EpromCtrl
, 1, &tmp
);
433 if (tmp
& EPROM_DONE
)
436 disable_eprom_write(pegasus
);
439 if (netif_msg_drv(pegasus
))
440 dev_warn(&pegasus
->intf
->dev
, "fail %s\n", __FUNCTION__
);
443 #endif /* PEGASUS_WRITE_EEPROM */
445 static inline void get_node_id(pegasus_t
* pegasus
, __u8
* id
)
450 for (i
= 0; i
< 3; i
++) {
451 read_eprom_word(pegasus
, i
, &w16
);
452 ((__le16
*) id
)[i
] = cpu_to_le16p(&w16
);
456 static void set_ethernet_addr(pegasus_t
* pegasus
)
461 get_node_id(pegasus
, node_id
);
462 ret
= set_registers(pegasus
, EthID
, sizeof (node_id
), node_id
);
463 memcpy(pegasus
->net
->dev_addr
, node_id
, sizeof (node_id
));
466 static inline int reset_mac(pegasus_t
* pegasus
)
472 ret
= set_register(pegasus
, EthCtrl1
, data
);
473 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
474 ret
= get_registers(pegasus
, EthCtrl1
, 1, &data
);
478 if (mii_mode
&& (pegasus
->features
& HAS_HOME_PNA
))
479 ret
= set_register(pegasus
, Gpio1
, 0x34);
481 ret
= set_register(pegasus
, Gpio1
, 0x26);
482 ret
= set_register(pegasus
, Gpio0
, pegasus
->features
);
483 ret
= set_register(pegasus
, Gpio0
, DEFAULT_GPIO_SET
);
487 if (i
== REG_TIMEOUT
)
490 if (usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_LINKSYS
||
491 usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_DLINK
) {
492 ret
= set_register(pegasus
, Gpio0
, 0x24);
493 ret
= set_register(pegasus
, Gpio0
, 0x26);
495 if (usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_ELCON
) {
497 read_mii_word(pegasus
, 3, 0x1b, &auxmode
);
498 write_mii_word(pegasus
, 3, 0x1b, auxmode
| 4);
504 static int enable_net_traffic(struct net_device
*dev
, struct usb_device
*usb
)
508 pegasus_t
*pegasus
= netdev_priv(dev
);
511 read_mii_word(pegasus
, pegasus
->phy
, MII_LPA
, &linkpart
);
514 if (linkpart
& (ADVERTISE_100FULL
| ADVERTISE_10FULL
))
515 data
[1] |= 0x20; /* set full duplex */
516 if (linkpart
& (ADVERTISE_100FULL
| ADVERTISE_100HALF
))
517 data
[1] |= 0x10; /* set 100 Mbps */
520 data
[2] = (loopback
& 1) ? 0x09 : 0x01;
522 memcpy(pegasus
->eth_regs
, data
, sizeof (data
));
523 ret
= set_registers(pegasus
, EthCtrl0
, 3, data
);
525 if (usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_LINKSYS
||
526 usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_DLINK
) {
528 read_mii_word(pegasus
, 0, 0x1b, &auxmode
);
529 write_mii_word(pegasus
, 0, 0x1b, auxmode
| 4);
535 static void fill_skb_pool(pegasus_t
* pegasus
)
539 for (i
= 0; i
< RX_SKBS
; i
++) {
540 if (pegasus
->rx_pool
[i
])
542 pegasus
->rx_pool
[i
] = dev_alloc_skb(PEGASUS_MTU
+ 2);
544 ** we give up if the allocation fail. the tasklet will be
545 ** rescheduled again anyway...
547 if (pegasus
->rx_pool
[i
] == NULL
)
549 pegasus
->rx_pool
[i
]->dev
= pegasus
->net
;
550 skb_reserve(pegasus
->rx_pool
[i
], 2);
554 static void free_skb_pool(pegasus_t
* pegasus
)
558 for (i
= 0; i
< RX_SKBS
; i
++) {
559 if (pegasus
->rx_pool
[i
]) {
560 dev_kfree_skb(pegasus
->rx_pool
[i
]);
561 pegasus
->rx_pool
[i
] = NULL
;
566 static inline struct sk_buff
*pull_skb(pegasus_t
* pegasus
)
571 for (i
= 0; i
< RX_SKBS
; i
++) {
572 if (likely(pegasus
->rx_pool
[i
] != NULL
)) {
573 skb
= pegasus
->rx_pool
[i
];
574 pegasus
->rx_pool
[i
] = NULL
;
581 static void read_bulk_callback(struct urb
*urb
, struct pt_regs
*regs
)
583 pegasus_t
*pegasus
= urb
->context
;
584 struct net_device
*net
;
585 int rx_status
, count
= urb
->actual_length
;
586 u8
*buf
= urb
->transfer_buffer
;
593 if (!netif_device_present(net
) || !netif_running(net
))
596 switch (urb
->status
) {
600 if (netif_msg_rx_err(pegasus
))
601 pr_debug("%s: reset MAC\n", net
->name
);
602 pegasus
->flags
&= ~PEGASUS_RX_BUSY
;
604 case -EPIPE
: /* stall, or disconnect from TT */
605 /* FIXME schedule work to clear the halt */
606 if (netif_msg_rx_err(pegasus
))
607 printk(KERN_WARNING
"%s: no rx stall recovery\n",
613 if (netif_msg_ifdown(pegasus
))
614 pr_debug("%s: rx unlink, %d\n", net
->name
, urb
->status
);
617 if (netif_msg_rx_err(pegasus
))
618 pr_debug("%s: RX status %d\n", net
->name
, urb
->status
);
622 if (!count
|| count
< 4)
625 rx_status
= buf
[count
- 2];
626 if (rx_status
& 0x1e) {
627 if (netif_msg_rx_err(pegasus
))
628 pr_debug("%s: RX packet error %x\n",
629 net
->name
, rx_status
);
630 pegasus
->stats
.rx_errors
++;
631 if (rx_status
& 0x06) // long or runt
632 pegasus
->stats
.rx_length_errors
++;
633 if (rx_status
& 0x08)
634 pegasus
->stats
.rx_crc_errors
++;
635 if (rx_status
& 0x10) // extra bits
636 pegasus
->stats
.rx_frame_errors
++;
639 if (pegasus
->chip
== 0x8513) {
640 pkt_len
= le32_to_cpu(*(__le32
*)urb
->transfer_buffer
);
642 pegasus
->rx_skb
->data
+= 2;
644 pkt_len
= buf
[count
- 3] << 8;
645 pkt_len
+= buf
[count
- 4];
651 * at this point we are sure pegasus->rx_skb != NULL
652 * so we go ahead and pass up the packet.
654 skb_put(pegasus
->rx_skb
, pkt_len
);
655 pegasus
->rx_skb
->protocol
= eth_type_trans(pegasus
->rx_skb
, net
);
656 netif_rx(pegasus
->rx_skb
);
657 pegasus
->stats
.rx_packets
++;
658 pegasus
->stats
.rx_bytes
+= pkt_len
;
660 if (pegasus
->flags
& PEGASUS_UNPLUG
)
663 spin_lock(&pegasus
->rx_pool_lock
);
664 pegasus
->rx_skb
= pull_skb(pegasus
);
665 spin_unlock(&pegasus
->rx_pool_lock
);
667 if (pegasus
->rx_skb
== NULL
)
670 usb_fill_bulk_urb(pegasus
->rx_urb
, pegasus
->usb
,
671 usb_rcvbulkpipe(pegasus
->usb
, 1),
672 pegasus
->rx_skb
->data
, PEGASUS_MTU
+ 8,
673 read_bulk_callback
, pegasus
);
674 if (usb_submit_urb(pegasus
->rx_urb
, GFP_ATOMIC
)) {
675 pegasus
->flags
|= PEGASUS_RX_URB_FAIL
;
678 pegasus
->flags
&= ~PEGASUS_RX_URB_FAIL
;
684 tasklet_schedule(&pegasus
->rx_tl
);
687 static void rx_fixup(unsigned long data
)
692 pegasus
= (pegasus_t
*) data
;
693 if (pegasus
->flags
& PEGASUS_UNPLUG
)
696 spin_lock_irqsave(&pegasus
->rx_pool_lock
, flags
);
697 fill_skb_pool(pegasus
);
698 if (pegasus
->flags
& PEGASUS_RX_URB_FAIL
)
701 if (pegasus
->rx_skb
== NULL
) {
702 pegasus
->rx_skb
= pull_skb(pegasus
);
704 if (pegasus
->rx_skb
== NULL
) {
705 if (netif_msg_rx_err(pegasus
))
706 printk(KERN_WARNING
"%s: low on memory\n",
708 tasklet_schedule(&pegasus
->rx_tl
);
711 usb_fill_bulk_urb(pegasus
->rx_urb
, pegasus
->usb
,
712 usb_rcvbulkpipe(pegasus
->usb
, 1),
713 pegasus
->rx_skb
->data
, PEGASUS_MTU
+ 8,
714 read_bulk_callback
, pegasus
);
716 if (usb_submit_urb(pegasus
->rx_urb
, GFP_ATOMIC
)) {
717 pegasus
->flags
|= PEGASUS_RX_URB_FAIL
;
718 tasklet_schedule(&pegasus
->rx_tl
);
720 pegasus
->flags
&= ~PEGASUS_RX_URB_FAIL
;
723 spin_unlock_irqrestore(&pegasus
->rx_pool_lock
, flags
);
726 static void write_bulk_callback(struct urb
*urb
, struct pt_regs
*regs
)
728 pegasus_t
*pegasus
= urb
->context
;
729 struct net_device
*net
= pegasus
->net
;
734 if (!netif_device_present(net
) || !netif_running(net
))
737 switch (urb
->status
) {
739 /* FIXME schedule_work() to clear the tx halt */
740 netif_stop_queue(net
);
741 if (netif_msg_tx_err(pegasus
))
742 printk(KERN_WARNING
"%s: no tx stall recovery\n",
748 if (netif_msg_ifdown(pegasus
))
749 pr_debug("%s: tx unlink, %d\n", net
->name
, urb
->status
);
752 if (netif_msg_tx_err(pegasus
))
753 pr_info("%s: TX status %d\n", net
->name
, urb
->status
);
759 net
->trans_start
= jiffies
;
760 netif_wake_queue(net
);
763 static void intr_callback(struct urb
*urb
, struct pt_regs
*regs
)
765 pegasus_t
*pegasus
= urb
->context
;
766 struct net_device
*net
;
773 switch (urb
->status
) {
776 case -ECONNRESET
: /* unlink */
781 /* some Pegasus-I products report LOTS of data
782 * toggle errors... avoid log spamming
784 if (netif_msg_timer(pegasus
))
785 pr_debug("%s: intr status %d\n", net
->name
,
789 if (urb
->actual_length
>= 6) {
790 u8
* d
= urb
->transfer_buffer
;
792 /* byte 0 == tx_status1, reg 2B */
793 if (d
[0] & (TX_UNDERRUN
|EXCESSIVE_COL
794 |LATE_COL
|JABBER_TIMEOUT
)) {
795 pegasus
->stats
.tx_errors
++;
796 if (d
[0] & TX_UNDERRUN
)
797 pegasus
->stats
.tx_fifo_errors
++;
798 if (d
[0] & (EXCESSIVE_COL
| JABBER_TIMEOUT
))
799 pegasus
->stats
.tx_aborted_errors
++;
801 pegasus
->stats
.tx_window_errors
++;
804 /* d[5].LINK_STATUS lies on some adapters.
805 * d[0].NO_CARRIER kicks in only with failed TX.
806 * ... so monitoring with MII may be safest.
808 if (d
[0] & NO_CARRIER
)
809 netif_carrier_off(net
);
811 netif_carrier_on(net
);
813 /* bytes 3-4 == rx_lostpkt, reg 2E/2F */
814 pegasus
->stats
.rx_missed_errors
+= ((d
[3] & 0x7f) << 8) | d
[4];
817 status
= usb_submit_urb(urb
, SLAB_ATOMIC
);
818 if (status
&& netif_msg_timer(pegasus
))
819 printk(KERN_ERR
"%s: can't resubmit interrupt urb, %d\n",
823 static void pegasus_tx_timeout(struct net_device
*net
)
825 pegasus_t
*pegasus
= netdev_priv(net
);
826 if (netif_msg_timer(pegasus
))
827 printk(KERN_WARNING
"%s: tx timeout\n", net
->name
);
828 usb_unlink_urb(pegasus
->tx_urb
);
829 pegasus
->stats
.tx_errors
++;
832 static int pegasus_start_xmit(struct sk_buff
*skb
, struct net_device
*net
)
834 pegasus_t
*pegasus
= netdev_priv(net
);
835 int count
= ((skb
->len
+ 2) & 0x3f) ? skb
->len
+ 2 : skb
->len
+ 3;
837 __u16 l16
= skb
->len
;
839 netif_stop_queue(net
);
841 ((__le16
*) pegasus
->tx_buff
)[0] = cpu_to_le16(l16
);
842 memcpy(pegasus
->tx_buff
+ 2, skb
->data
, skb
->len
);
843 usb_fill_bulk_urb(pegasus
->tx_urb
, pegasus
->usb
,
844 usb_sndbulkpipe(pegasus
->usb
, 2),
845 pegasus
->tx_buff
, count
,
846 write_bulk_callback
, pegasus
);
847 if ((res
= usb_submit_urb(pegasus
->tx_urb
, GFP_ATOMIC
))) {
848 if (netif_msg_tx_err(pegasus
))
849 printk(KERN_WARNING
"%s: fail tx, %d\n",
852 case -EPIPE
: /* stall, or disconnect from TT */
853 /* cleanup should already have been scheduled */
855 case -ENODEV
: /* disconnect() upcoming */
858 pegasus
->stats
.tx_errors
++;
859 netif_start_queue(net
);
862 pegasus
->stats
.tx_packets
++;
863 pegasus
->stats
.tx_bytes
+= skb
->len
;
864 net
->trans_start
= jiffies
;
871 static struct net_device_stats
*pegasus_netdev_stats(struct net_device
*dev
)
873 return &((pegasus_t
*) netdev_priv(dev
))->stats
;
876 static inline void disable_net_traffic(pegasus_t
* pegasus
)
881 ret
= set_registers(pegasus
, EthCtrl0
, 2, &tmp
);
884 static inline void get_interrupt_interval(pegasus_t
* pegasus
)
888 read_eprom_word(pegasus
, 4, (__u16
*) data
);
889 if (data
[1] < 0x80) {
890 if (netif_msg_timer(pegasus
))
891 dev_info(&pegasus
->intf
->dev
,
892 "intr interval changed from %ums to %ums\n",
895 #ifdef PEGASUS_WRITE_EEPROM
896 write_eprom_word(pegasus
, 4, *(__u16
*) data
);
899 pegasus
->intr_interval
= data
[1];
902 static void set_carrier(struct net_device
*net
)
904 pegasus_t
*pegasus
= netdev_priv(net
);
907 if (read_mii_word(pegasus
, pegasus
->phy
, MII_BMSR
, &tmp
))
909 if (tmp
& BMSR_LSTATUS
)
910 netif_carrier_on(net
);
912 netif_carrier_off(net
);
915 static void free_all_urbs(pegasus_t
* pegasus
)
917 usb_free_urb(pegasus
->intr_urb
);
918 usb_free_urb(pegasus
->tx_urb
);
919 usb_free_urb(pegasus
->rx_urb
);
920 usb_free_urb(pegasus
->ctrl_urb
);
923 static void unlink_all_urbs(pegasus_t
* pegasus
)
925 usb_kill_urb(pegasus
->intr_urb
);
926 usb_kill_urb(pegasus
->tx_urb
);
927 usb_kill_urb(pegasus
->rx_urb
);
928 usb_kill_urb(pegasus
->ctrl_urb
);
931 static int alloc_urbs(pegasus_t
* pegasus
)
933 pegasus
->ctrl_urb
= usb_alloc_urb(0, GFP_KERNEL
);
934 if (!pegasus
->ctrl_urb
) {
937 pegasus
->rx_urb
= usb_alloc_urb(0, GFP_KERNEL
);
938 if (!pegasus
->rx_urb
) {
939 usb_free_urb(pegasus
->ctrl_urb
);
942 pegasus
->tx_urb
= usb_alloc_urb(0, GFP_KERNEL
);
943 if (!pegasus
->tx_urb
) {
944 usb_free_urb(pegasus
->rx_urb
);
945 usb_free_urb(pegasus
->ctrl_urb
);
948 pegasus
->intr_urb
= usb_alloc_urb(0, GFP_KERNEL
);
949 if (!pegasus
->intr_urb
) {
950 usb_free_urb(pegasus
->tx_urb
);
951 usb_free_urb(pegasus
->rx_urb
);
952 usb_free_urb(pegasus
->ctrl_urb
);
959 static int pegasus_open(struct net_device
*net
)
961 pegasus_t
*pegasus
= netdev_priv(net
);
964 if (pegasus
->rx_skb
== NULL
)
965 pegasus
->rx_skb
= pull_skb(pegasus
);
967 ** Note: no point to free the pool. it is empty :-)
969 if (!pegasus
->rx_skb
)
972 res
= set_registers(pegasus
, EthID
, 6, net
->dev_addr
);
974 usb_fill_bulk_urb(pegasus
->rx_urb
, pegasus
->usb
,
975 usb_rcvbulkpipe(pegasus
->usb
, 1),
976 pegasus
->rx_skb
->data
, PEGASUS_MTU
+ 8,
977 read_bulk_callback
, pegasus
);
978 if ((res
= usb_submit_urb(pegasus
->rx_urb
, GFP_KERNEL
))) {
979 if (netif_msg_ifup(pegasus
))
980 pr_debug("%s: failed rx_urb, %d", net
->name
, res
);
984 usb_fill_int_urb(pegasus
->intr_urb
, pegasus
->usb
,
985 usb_rcvintpipe(pegasus
->usb
, 3),
986 pegasus
->intr_buff
, sizeof (pegasus
->intr_buff
),
987 intr_callback
, pegasus
, pegasus
->intr_interval
);
988 if ((res
= usb_submit_urb(pegasus
->intr_urb
, GFP_KERNEL
))) {
989 if (netif_msg_ifup(pegasus
))
990 pr_debug("%s: failed intr_urb, %d\n", net
->name
, res
);
991 usb_kill_urb(pegasus
->rx_urb
);
994 if ((res
= enable_net_traffic(net
, pegasus
->usb
))) {
995 if (netif_msg_ifup(pegasus
))
996 pr_debug("%s: can't enable_net_traffic() - %d\n",
999 usb_kill_urb(pegasus
->rx_urb
);
1000 usb_kill_urb(pegasus
->intr_urb
);
1001 free_skb_pool(pegasus
);
1005 netif_start_queue(net
);
1006 if (netif_msg_ifup(pegasus
))
1007 pr_debug("%s: open\n", net
->name
);
1013 static int pegasus_close(struct net_device
*net
)
1015 pegasus_t
*pegasus
= netdev_priv(net
);
1017 netif_stop_queue(net
);
1018 if (!(pegasus
->flags
& PEGASUS_UNPLUG
))
1019 disable_net_traffic(pegasus
);
1020 tasklet_kill(&pegasus
->rx_tl
);
1021 unlink_all_urbs(pegasus
);
1026 static void pegasus_get_drvinfo(struct net_device
*dev
,
1027 struct ethtool_drvinfo
*info
)
1029 pegasus_t
*pegasus
= netdev_priv(dev
);
1030 strncpy(info
->driver
, driver_name
, sizeof (info
->driver
) - 1);
1031 strncpy(info
->version
, DRIVER_VERSION
, sizeof (info
->version
) - 1);
1032 usb_make_path(pegasus
->usb
, info
->bus_info
, sizeof (info
->bus_info
));
1035 /* also handles three patterns of some kind in hardware */
1036 #define WOL_SUPPORTED (WAKE_MAGIC|WAKE_PHY)
1039 pegasus_get_wol(struct net_device
*dev
, struct ethtool_wolinfo
*wol
)
1041 pegasus_t
*pegasus
= netdev_priv(dev
);
1043 wol
->supported
= WAKE_MAGIC
| WAKE_PHY
;
1044 wol
->wolopts
= pegasus
->wolopts
;
1048 pegasus_set_wol(struct net_device
*dev
, struct ethtool_wolinfo
*wol
)
1050 pegasus_t
*pegasus
= netdev_priv(dev
);
1053 if (wol
->wolopts
& ~WOL_SUPPORTED
)
1056 if (wol
->wolopts
& WAKE_MAGIC
)
1058 if (wol
->wolopts
& WAKE_PHY
)
1060 /* FIXME this 0x10 bit still needs to get set in the chip... */
1062 pegasus
->eth_regs
[0] |= 0x10;
1064 pegasus
->eth_regs
[0] &= ~0x10;
1065 pegasus
->wolopts
= wol
->wolopts
;
1066 return set_register(pegasus
, WakeupControl
, reg78
);
1069 static inline void pegasus_reset_wol(struct net_device
*dev
)
1071 struct ethtool_wolinfo wol
;
1073 memset(&wol
, 0, sizeof wol
);
1074 (void) pegasus_set_wol(dev
, &wol
);
1078 pegasus_get_settings(struct net_device
*dev
, struct ethtool_cmd
*ecmd
)
1085 pegasus
= netdev_priv(dev
);
1086 mii_ethtool_gset(&pegasus
->mii
, ecmd
);
1092 pegasus_set_settings(struct net_device
*dev
, struct ethtool_cmd
*ecmd
)
1094 pegasus_t
*pegasus
= netdev_priv(dev
);
1095 return mii_ethtool_sset(&pegasus
->mii
, ecmd
);
1098 static int pegasus_nway_reset(struct net_device
*dev
)
1100 pegasus_t
*pegasus
= netdev_priv(dev
);
1101 return mii_nway_restart(&pegasus
->mii
);
1104 static u32
pegasus_get_link(struct net_device
*dev
)
1106 pegasus_t
*pegasus
= netdev_priv(dev
);
1107 return mii_link_ok(&pegasus
->mii
);
1110 static u32
pegasus_get_msglevel(struct net_device
*dev
)
1112 pegasus_t
*pegasus
= netdev_priv(dev
);
1113 return pegasus
->msg_enable
;
1116 static void pegasus_set_msglevel(struct net_device
*dev
, u32 v
)
1118 pegasus_t
*pegasus
= netdev_priv(dev
);
1119 pegasus
->msg_enable
= v
;
1122 static struct ethtool_ops ops
= {
1123 .get_drvinfo
= pegasus_get_drvinfo
,
1124 .get_settings
= pegasus_get_settings
,
1125 .set_settings
= pegasus_set_settings
,
1126 .nway_reset
= pegasus_nway_reset
,
1127 .get_link
= pegasus_get_link
,
1128 .get_msglevel
= pegasus_get_msglevel
,
1129 .set_msglevel
= pegasus_set_msglevel
,
1130 .get_wol
= pegasus_get_wol
,
1131 .set_wol
= pegasus_set_wol
,
1134 static int pegasus_ioctl(struct net_device
*net
, struct ifreq
*rq
, int cmd
)
1136 __u16
*data
= (__u16
*) & rq
->ifr_ifru
;
1137 pegasus_t
*pegasus
= netdev_priv(net
);
1141 case SIOCDEVPRIVATE
:
1142 data
[0] = pegasus
->phy
;
1143 case SIOCDEVPRIVATE
+ 1:
1144 read_mii_word(pegasus
, data
[0], data
[1] & 0x1f, &data
[3]);
1147 case SIOCDEVPRIVATE
+ 2:
1148 if (!capable(CAP_NET_ADMIN
))
1150 write_mii_word(pegasus
, pegasus
->phy
, data
[1] & 0x1f, data
[2]);
1159 static void pegasus_set_multicast(struct net_device
*net
)
1161 pegasus_t
*pegasus
= netdev_priv(net
);
1163 if (net
->flags
& IFF_PROMISC
) {
1164 pegasus
->eth_regs
[EthCtrl2
] |= RX_PROMISCUOUS
;
1165 if (netif_msg_link(pegasus
))
1166 pr_info("%s: Promiscuous mode enabled.\n", net
->name
);
1167 } else if (net
->mc_count
||
1168 (net
->flags
& IFF_ALLMULTI
)) {
1169 pegasus
->eth_regs
[EthCtrl0
] |= RX_MULTICAST
;
1170 pegasus
->eth_regs
[EthCtrl2
] &= ~RX_PROMISCUOUS
;
1171 if (netif_msg_link(pegasus
))
1172 pr_info("%s: set allmulti\n", net
->name
);
1174 pegasus
->eth_regs
[EthCtrl0
] &= ~RX_MULTICAST
;
1175 pegasus
->eth_regs
[EthCtrl2
] &= ~RX_PROMISCUOUS
;
1178 pegasus
->flags
|= ETH_REGS_CHANGE
;
1179 ctrl_callback(pegasus
->ctrl_urb
, NULL
);
1182 static __u8
mii_phy_probe(pegasus_t
* pegasus
)
1187 for (i
= 0; i
< 32; i
++) {
1188 read_mii_word(pegasus
, i
, MII_BMSR
, &tmp
);
1189 if (tmp
== 0 || tmp
== 0xffff || (tmp
& BMSR_MEDIA
) == 0)
1198 static inline void setup_pegasus_II(pegasus_t
* pegasus
)
1203 ret
= set_register(pegasus
, Reg1d
, 0);
1204 ret
= set_register(pegasus
, Reg7b
, 1);
1206 if ((pegasus
->features
& HAS_HOME_PNA
) && mii_mode
)
1207 ret
= set_register(pegasus
, Reg7b
, 0);
1209 ret
= set_register(pegasus
, Reg7b
, 2);
1211 ret
= set_register(pegasus
, 0x83, data
);
1212 ret
= get_registers(pegasus
, 0x83, 1, &data
);
1215 pegasus
->chip
= 0x8513;
1220 ret
= set_register(pegasus
, 0x80, 0xc0);
1221 ret
= set_register(pegasus
, 0x83, 0xff);
1222 ret
= set_register(pegasus
, 0x84, 0x01);
1224 if (pegasus
->features
& HAS_HOME_PNA
&& mii_mode
)
1225 ret
= set_register(pegasus
, Reg81
, 6);
1227 ret
= set_register(pegasus
, Reg81
, 2);
1231 static struct workqueue_struct
*pegasus_workqueue
= NULL
;
1232 #define CARRIER_CHECK_DELAY (2 * HZ)
1234 static void check_carrier(void *data
)
1236 pegasus_t
*pegasus
= data
;
1237 set_carrier(pegasus
->net
);
1238 if (!(pegasus
->flags
& PEGASUS_UNPLUG
)) {
1239 queue_delayed_work(pegasus_workqueue
, &pegasus
->carrier_check
,
1240 CARRIER_CHECK_DELAY
);
1244 static int pegasus_probe(struct usb_interface
*intf
,
1245 const struct usb_device_id
*id
)
1247 struct usb_device
*dev
= interface_to_usbdev(intf
);
1248 struct net_device
*net
;
1250 int dev_index
= id
- pegasus_ids
;
1254 net
= alloc_etherdev(sizeof(struct pegasus
));
1256 dev_err(&intf
->dev
, "can't allocate %s\n", "device");
1260 pegasus
= netdev_priv(net
);
1261 memset(pegasus
, 0, sizeof (struct pegasus
));
1262 pegasus
->dev_index
= dev_index
;
1263 init_waitqueue_head(&pegasus
->ctrl_wait
);
1265 if (!alloc_urbs(pegasus
)) {
1266 dev_err(&intf
->dev
, "can't allocate %s\n", "urbs");
1270 tasklet_init(&pegasus
->rx_tl
, rx_fixup
, (unsigned long) pegasus
);
1272 INIT_WORK(&pegasus
->carrier_check
, check_carrier
, pegasus
);
1274 pegasus
->intf
= intf
;
1277 SET_MODULE_OWNER(net
);
1278 net
->open
= pegasus_open
;
1279 net
->stop
= pegasus_close
;
1280 net
->watchdog_timeo
= PEGASUS_TX_TIMEOUT
;
1281 net
->tx_timeout
= pegasus_tx_timeout
;
1282 net
->do_ioctl
= pegasus_ioctl
;
1283 net
->hard_start_xmit
= pegasus_start_xmit
;
1284 net
->set_multicast_list
= pegasus_set_multicast
;
1285 net
->get_stats
= pegasus_netdev_stats
;
1286 SET_ETHTOOL_OPS(net
, &ops
);
1287 pegasus
->mii
.dev
= net
;
1288 pegasus
->mii
.mdio_read
= mdio_read
;
1289 pegasus
->mii
.mdio_write
= mdio_write
;
1290 pegasus
->mii
.phy_id_mask
= 0x1f;
1291 pegasus
->mii
.reg_num_mask
= 0x1f;
1292 spin_lock_init(&pegasus
->rx_pool_lock
);
1293 pegasus
->msg_enable
= netif_msg_init (msg_level
, NETIF_MSG_DRV
1294 | NETIF_MSG_PROBE
| NETIF_MSG_LINK
);
1296 pegasus
->features
= usb_dev_id
[dev_index
].private;
1297 get_interrupt_interval(pegasus
);
1298 if (reset_mac(pegasus
)) {
1299 dev_err(&intf
->dev
, "can't reset MAC\n");
1303 set_ethernet_addr(pegasus
);
1304 fill_skb_pool(pegasus
);
1305 if (pegasus
->features
& PEGASUS_II
) {
1306 dev_info(&intf
->dev
, "setup Pegasus II specific registers\n");
1307 setup_pegasus_II(pegasus
);
1309 pegasus
->phy
= mii_phy_probe(pegasus
);
1310 if (pegasus
->phy
== 0xff) {
1311 dev_warn(&intf
->dev
, "can't locate MII phy, using default\n");
1314 pegasus
->mii
.phy_id
= pegasus
->phy
;
1315 usb_set_intfdata(intf
, pegasus
);
1316 SET_NETDEV_DEV(net
, &intf
->dev
);
1317 pegasus_reset_wol(net
);
1318 res
= register_netdev(net
);
1321 queue_delayed_work(pegasus_workqueue
, &pegasus
->carrier_check
,
1322 CARRIER_CHECK_DELAY
);
1324 dev_info(&intf
->dev
, "%s, %s, %02x:%02x:%02x:%02x:%02x:%02x\n",
1326 usb_dev_id
[dev_index
].name
,
1327 net
->dev_addr
[0], net
->dev_addr
[1],
1328 net
->dev_addr
[2], net
->dev_addr
[3],
1329 net
->dev_addr
[4], net
->dev_addr
[5]);
1333 usb_set_intfdata(intf
, NULL
);
1334 free_skb_pool(pegasus
);
1336 free_all_urbs(pegasus
);
1344 static void pegasus_disconnect(struct usb_interface
*intf
)
1346 struct pegasus
*pegasus
= usb_get_intfdata(intf
);
1348 usb_set_intfdata(intf
, NULL
);
1350 dev_dbg(&intf
->dev
, "unregistering non-bound device?\n");
1354 pegasus
->flags
|= PEGASUS_UNPLUG
;
1355 cancel_delayed_work(&pegasus
->carrier_check
);
1356 unregister_netdev(pegasus
->net
);
1357 usb_put_dev(interface_to_usbdev(intf
));
1358 free_all_urbs(pegasus
);
1359 free_skb_pool(pegasus
);
1360 if (pegasus
->rx_skb
)
1361 dev_kfree_skb(pegasus
->rx_skb
);
1362 free_netdev(pegasus
->net
);
1365 static int pegasus_suspend (struct usb_interface
*intf
, pm_message_t message
)
1367 struct pegasus
*pegasus
= usb_get_intfdata(intf
);
1369 netif_device_detach (pegasus
->net
);
1370 if (netif_running(pegasus
->net
)) {
1371 cancel_delayed_work(&pegasus
->carrier_check
);
1373 usb_kill_urb(pegasus
->rx_urb
);
1374 usb_kill_urb(pegasus
->intr_urb
);
1376 intf
->dev
.power
.power_state
= PMSG_SUSPEND
;
1380 static int pegasus_resume (struct usb_interface
*intf
)
1382 struct pegasus
*pegasus
= usb_get_intfdata(intf
);
1384 intf
->dev
.power
.power_state
= PMSG_ON
;
1385 netif_device_attach (pegasus
->net
);
1386 if (netif_running(pegasus
->net
)) {
1387 pegasus
->rx_urb
->status
= 0;
1388 pegasus
->rx_urb
->actual_length
= 0;
1389 read_bulk_callback(pegasus
->rx_urb
, NULL
);
1391 pegasus
->intr_urb
->status
= 0;
1392 pegasus
->intr_urb
->actual_length
= 0;
1393 intr_callback(pegasus
->intr_urb
, NULL
);
1395 queue_delayed_work(pegasus_workqueue
, &pegasus
->carrier_check
,
1396 CARRIER_CHECK_DELAY
);
1401 static struct usb_driver pegasus_driver
= {
1402 .name
= driver_name
,
1403 .probe
= pegasus_probe
,
1404 .disconnect
= pegasus_disconnect
,
1405 .id_table
= pegasus_ids
,
1406 .suspend
= pegasus_suspend
,
1407 .resume
= pegasus_resume
,
1410 static int __init
pegasus_init(void)
1412 pr_info("%s: %s, " DRIVER_DESC
"\n", driver_name
, DRIVER_VERSION
);
1413 pegasus_workqueue
= create_singlethread_workqueue("pegasus");
1414 if (!pegasus_workqueue
)
1416 return usb_register(&pegasus_driver
);
1419 static void __exit
pegasus_exit(void)
1421 destroy_workqueue(pegasus_workqueue
);
1422 usb_deregister(&pegasus_driver
);
1425 module_init(pegasus_init
);
1426 module_exit(pegasus_exit
);