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.
31 #include <linux/sched.h>
32 #include <linux/slab.h>
33 #include <linux/init.h>
34 #include <linux/delay.h>
35 #include <linux/netdevice.h>
36 #include <linux/etherdevice.h>
37 #include <linux/ethtool.h>
38 #include <linux/mii.h>
39 #include <linux/usb.h>
40 #include <linux/module.h>
41 #include <asm/byteorder.h>
42 #include <asm/uaccess.h>
48 #define DRIVER_VERSION "v0.6.12 (2005/01/13)"
49 #define DRIVER_AUTHOR "Petko Manolov <petkan@users.sourceforge.net>"
50 #define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver"
52 static const char driver_name
[] = "pegasus";
54 #undef PEGASUS_WRITE_EEPROM
55 #define BMSR_MEDIA (BMSR_10HALF | BMSR_10FULL | BMSR_100HALF | \
56 BMSR_100FULL | BMSR_ANEGCAPABLE)
58 static int loopback
= 0;
59 static int mii_mode
= 0;
61 static struct usb_eth_dev usb_dev_id
[] = {
62 #define PEGASUS_DEV(pn, vid, pid, flags) \
63 {.name = pn, .vendor = vid, .device = pid, .private = flags},
69 static struct usb_device_id pegasus_ids
[] = {
70 #define PEGASUS_DEV(pn, vid, pid, flags) \
71 {.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = vid, .idProduct = pid},
77 MODULE_AUTHOR(DRIVER_AUTHOR
);
78 MODULE_DESCRIPTION(DRIVER_DESC
);
79 MODULE_LICENSE("GPL");
80 module_param(loopback
, bool, 0);
81 module_param(mii_mode
, bool, 0);
82 MODULE_PARM_DESC(loopback
, "Enable MAC loopback mode (bit 0)");
83 MODULE_PARM_DESC(mii_mode
, "Enable HomePNA mode (bit 0),default=MII mode = 0");
85 /* use ethtool to change the level for any given device */
86 static int msg_level
= -1;
87 module_param (msg_level
, int, 0);
88 MODULE_PARM_DESC (msg_level
, "Override default message level");
90 MODULE_DEVICE_TABLE(usb
, pegasus_ids
);
92 static int update_eth_regs_async(pegasus_t
*);
93 /* Aargh!!! I _really_ hate such tweaks */
94 static void ctrl_callback(struct urb
*urb
, struct pt_regs
*regs
)
96 pegasus_t
*pegasus
= urb
->context
;
101 switch (urb
->status
) {
103 if (pegasus
->flags
& ETH_REGS_CHANGE
) {
104 pegasus
->flags
&= ~ETH_REGS_CHANGE
;
105 pegasus
->flags
|= ETH_REGS_CHANGED
;
106 update_eth_regs_async(pegasus
);
115 if (netif_msg_drv(pegasus
))
116 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
117 __FUNCTION__
, urb
->status
);
119 pegasus
->flags
&= ~ETH_REGS_CHANGED
;
120 wake_up(&pegasus
->ctrl_wait
);
123 static int get_registers(pegasus_t
* pegasus
, __u16 indx
, __u16 size
,
128 DECLARE_WAITQUEUE(wait
, current
);
130 buffer
= kmalloc(size
, GFP_KERNEL
);
132 if (netif_msg_drv(pegasus
))
133 dev_warn(&pegasus
->intf
->dev
, "out of memory in %s\n",
137 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
138 set_current_state(TASK_UNINTERRUPTIBLE
);
139 while (pegasus
->flags
& ETH_REGS_CHANGED
)
141 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
142 set_current_state(TASK_RUNNING
);
144 pegasus
->dr
.bRequestType
= PEGASUS_REQT_READ
;
145 pegasus
->dr
.bRequest
= PEGASUS_REQ_GET_REGS
;
146 pegasus
->dr
.wValue
= cpu_to_le16(0);
147 pegasus
->dr
.wIndex
= cpu_to_le16p(&indx
);
148 pegasus
->dr
.wLength
= cpu_to_le16p(&size
);
149 pegasus
->ctrl_urb
->transfer_buffer_length
= size
;
151 usb_fill_control_urb(pegasus
->ctrl_urb
, pegasus
->usb
,
152 usb_rcvctrlpipe(pegasus
->usb
, 0),
153 (char *) &pegasus
->dr
,
154 buffer
, size
, ctrl_callback
, pegasus
);
156 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
157 set_current_state(TASK_UNINTERRUPTIBLE
);
159 /* using ATOMIC, we'd never wake up if we slept */
160 if ((ret
= usb_submit_urb(pegasus
->ctrl_urb
, GFP_ATOMIC
))) {
161 if (netif_msg_drv(pegasus
))
162 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
169 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
170 memcpy(data
, buffer
, size
);
176 static int set_registers(pegasus_t
* pegasus
, __u16 indx
, __u16 size
,
181 DECLARE_WAITQUEUE(wait
, current
);
183 buffer
= kmalloc(size
, GFP_KERNEL
);
185 if (netif_msg_drv(pegasus
))
186 dev_warn(&pegasus
->intf
->dev
, "out of memory in %s\n",
190 memcpy(buffer
, data
, size
);
192 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
193 set_current_state(TASK_UNINTERRUPTIBLE
);
194 while (pegasus
->flags
& ETH_REGS_CHANGED
)
196 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
197 set_current_state(TASK_RUNNING
);
199 pegasus
->dr
.bRequestType
= PEGASUS_REQT_WRITE
;
200 pegasus
->dr
.bRequest
= PEGASUS_REQ_SET_REGS
;
201 pegasus
->dr
.wValue
= cpu_to_le16(0);
202 pegasus
->dr
.wIndex
= cpu_to_le16p(&indx
);
203 pegasus
->dr
.wLength
= cpu_to_le16p(&size
);
204 pegasus
->ctrl_urb
->transfer_buffer_length
= size
;
206 usb_fill_control_urb(pegasus
->ctrl_urb
, pegasus
->usb
,
207 usb_sndctrlpipe(pegasus
->usb
, 0),
208 (char *) &pegasus
->dr
,
209 buffer
, size
, ctrl_callback
, pegasus
);
211 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
212 set_current_state(TASK_UNINTERRUPTIBLE
);
214 if ((ret
= usb_submit_urb(pegasus
->ctrl_urb
, GFP_ATOMIC
))) {
215 if (netif_msg_drv(pegasus
))
216 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
223 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
229 static int set_register(pegasus_t
* pegasus
, __u16 indx
, __u8 data
)
233 DECLARE_WAITQUEUE(wait
, current
);
235 tmp
= kmalloc(1, GFP_KERNEL
);
237 if (netif_msg_drv(pegasus
))
238 dev_warn(&pegasus
->intf
->dev
, "out of memory in %s\n",
242 memcpy(tmp
, &data
, 1);
243 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
244 set_current_state(TASK_UNINTERRUPTIBLE
);
245 while (pegasus
->flags
& ETH_REGS_CHANGED
)
247 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
248 set_current_state(TASK_RUNNING
);
250 pegasus
->dr
.bRequestType
= PEGASUS_REQT_WRITE
;
251 pegasus
->dr
.bRequest
= PEGASUS_REQ_SET_REG
;
252 pegasus
->dr
.wValue
= cpu_to_le16(data
);
253 pegasus
->dr
.wIndex
= cpu_to_le16p(&indx
);
254 pegasus
->dr
.wLength
= cpu_to_le16(1);
255 pegasus
->ctrl_urb
->transfer_buffer_length
= 1;
257 usb_fill_control_urb(pegasus
->ctrl_urb
, pegasus
->usb
,
258 usb_sndctrlpipe(pegasus
->usb
, 0),
259 (char *) &pegasus
->dr
,
260 &tmp
, 1, ctrl_callback
, pegasus
);
262 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
263 set_current_state(TASK_UNINTERRUPTIBLE
);
265 if ((ret
= usb_submit_urb(pegasus
->ctrl_urb
, GFP_ATOMIC
))) {
266 if (netif_msg_drv(pegasus
))
267 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
274 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
280 static int update_eth_regs_async(pegasus_t
* pegasus
)
284 pegasus
->dr
.bRequestType
= PEGASUS_REQT_WRITE
;
285 pegasus
->dr
.bRequest
= PEGASUS_REQ_SET_REGS
;
286 pegasus
->dr
.wValue
= 0;
287 pegasus
->dr
.wIndex
= cpu_to_le16(EthCtrl0
);
288 pegasus
->dr
.wLength
= cpu_to_le16(3);
289 pegasus
->ctrl_urb
->transfer_buffer_length
= 3;
291 usb_fill_control_urb(pegasus
->ctrl_urb
, pegasus
->usb
,
292 usb_sndctrlpipe(pegasus
->usb
, 0),
293 (char *) &pegasus
->dr
,
294 pegasus
->eth_regs
, 3, ctrl_callback
, pegasus
);
296 if ((ret
= usb_submit_urb(pegasus
->ctrl_urb
, GFP_ATOMIC
)))
297 if (netif_msg_drv(pegasus
))
298 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
304 static int read_mii_word(pegasus_t
* pegasus
, __u8 phy
, __u8 indx
, __u16
* regd
)
307 __u8 data
[4] = { phy
, 0, 0, indx
};
311 ret
= set_register(pegasus
, PhyCtrl
, 0);
312 ret
= set_registers(pegasus
, PhyAddr
, sizeof (data
), data
);
313 ret
= set_register(pegasus
, PhyCtrl
, (indx
| PHY_READ
));
314 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
315 ret
= get_registers(pegasus
, PhyCtrl
, 1, data
);
316 if (data
[0] & PHY_DONE
)
319 if (i
< REG_TIMEOUT
) {
320 ret
= get_registers(pegasus
, PhyData
, 2, ®di
);
321 *regd
= le16_to_cpu(regdi
);
324 if (netif_msg_drv(pegasus
))
325 dev_warn(&pegasus
->intf
->dev
, "fail %s\n", __FUNCTION__
);
330 static int mdio_read(struct net_device
*dev
, int phy_id
, int loc
)
332 pegasus_t
*pegasus
= (pegasus_t
*) netdev_priv(dev
);
335 read_mii_word(pegasus
, phy_id
, loc
, &res
);
339 static int write_mii_word(pegasus_t
* pegasus
, __u8 phy
, __u8 indx
, __u16 regd
)
342 __u8 data
[4] = { phy
, 0, 0, indx
};
346 data
[2] = (u8
) (regd
>> 8);
347 ret
= set_register(pegasus
, PhyCtrl
, 0);
348 ret
= set_registers(pegasus
, PhyAddr
, sizeof(data
), data
);
349 ret
= set_register(pegasus
, PhyCtrl
, (indx
| PHY_WRITE
));
350 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
351 ret
= get_registers(pegasus
, PhyCtrl
, 1, data
);
352 if (data
[0] & PHY_DONE
)
358 if (netif_msg_drv(pegasus
))
359 dev_warn(&pegasus
->intf
->dev
, "fail %s\n", __FUNCTION__
);
363 static void mdio_write(struct net_device
*dev
, int phy_id
, int loc
, int val
)
365 pegasus_t
*pegasus
= (pegasus_t
*) netdev_priv(dev
);
367 write_mii_word(pegasus
, phy_id
, loc
, val
);
370 static int read_eprom_word(pegasus_t
* pegasus
, __u8 index
, __u16
* retdata
)
377 ret
= set_register(pegasus
, EpromCtrl
, 0);
378 ret
= set_register(pegasus
, EpromOffset
, index
);
379 ret
= set_register(pegasus
, EpromCtrl
, EPROM_READ
);
381 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
382 ret
= get_registers(pegasus
, EpromCtrl
, 1, &tmp
);
383 if (tmp
& EPROM_DONE
)
386 if (i
< REG_TIMEOUT
) {
387 ret
= get_registers(pegasus
, EpromData
, 2, &retdatai
);
388 *retdata
= le16_to_cpu(retdatai
);
392 if (netif_msg_drv(pegasus
))
393 dev_warn(&pegasus
->intf
->dev
, "fail %s\n", __FUNCTION__
);
397 #ifdef PEGASUS_WRITE_EEPROM
398 static inline void enable_eprom_write(pegasus_t
* pegasus
)
403 ret
= get_registers(pegasus
, EthCtrl2
, 1, &tmp
);
404 ret
= set_register(pegasus
, EthCtrl2
, tmp
| EPROM_WR_ENABLE
);
407 static inline void disable_eprom_write(pegasus_t
* pegasus
)
412 ret
= get_registers(pegasus
, EthCtrl2
, 1, &tmp
);
413 ret
= set_register(pegasus
, EpromCtrl
, 0);
414 ret
= set_register(pegasus
, EthCtrl2
, tmp
& ~EPROM_WR_ENABLE
);
417 static int write_eprom_word(pegasus_t
* pegasus
, __u8 index
, __u16 data
)
420 __u8 tmp
, d
[4] = { 0x3f, 0, 0, EPROM_WRITE
};
423 ret
= set_registers(pegasus
, EpromOffset
, 4, d
);
424 enable_eprom_write(pegasus
);
425 ret
= set_register(pegasus
, EpromOffset
, index
);
426 ret
= set_registers(pegasus
, EpromData
, 2, &data
);
427 ret
= set_register(pegasus
, EpromCtrl
, EPROM_WRITE
);
429 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
430 ret
= get_registers(pegasus
, EpromCtrl
, 1, &tmp
);
431 if (tmp
& EPROM_DONE
)
434 disable_eprom_write(pegasus
);
437 if (netif_msg_drv(pegasus
))
438 dev_warn(&pegasus
->intf
->dev
, "fail %s\n", __FUNCTION__
);
441 #endif /* PEGASUS_WRITE_EEPROM */
443 static inline void get_node_id(pegasus_t
* pegasus
, __u8
* id
)
448 for (i
= 0; i
< 3; i
++) {
449 read_eprom_word(pegasus
, i
, &w16
);
450 ((__le16
*) id
)[i
] = cpu_to_le16p(&w16
);
454 static void set_ethernet_addr(pegasus_t
* pegasus
)
459 get_node_id(pegasus
, node_id
);
460 ret
= set_registers(pegasus
, EthID
, sizeof (node_id
), node_id
);
461 memcpy(pegasus
->net
->dev_addr
, node_id
, sizeof (node_id
));
464 static inline int reset_mac(pegasus_t
* pegasus
)
470 ret
= set_register(pegasus
, EthCtrl1
, data
);
471 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
472 ret
= get_registers(pegasus
, EthCtrl1
, 1, &data
);
476 if (mii_mode
&& (pegasus
->features
& HAS_HOME_PNA
))
477 ret
= set_register(pegasus
, Gpio1
, 0x34);
479 ret
= set_register(pegasus
, Gpio1
, 0x26);
480 ret
= set_register(pegasus
, Gpio0
, pegasus
->features
);
481 ret
= set_register(pegasus
, Gpio0
, DEFAULT_GPIO_SET
);
485 if (i
== REG_TIMEOUT
)
488 if (usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_LINKSYS
||
489 usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_DLINK
) {
490 ret
= set_register(pegasus
, Gpio0
, 0x24);
491 ret
= set_register(pegasus
, Gpio0
, 0x26);
493 if (usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_ELCON
) {
495 read_mii_word(pegasus
, 3, 0x1b, &auxmode
);
496 write_mii_word(pegasus
, 3, 0x1b, auxmode
| 4);
502 static int enable_net_traffic(struct net_device
*dev
, struct usb_device
*usb
)
506 pegasus_t
*pegasus
= netdev_priv(dev
);
509 read_mii_word(pegasus
, pegasus
->phy
, MII_LPA
, &linkpart
);
512 if (linkpart
& (ADVERTISE_100FULL
| ADVERTISE_10FULL
))
513 data
[1] |= 0x20; /* set full duplex */
514 if (linkpart
& (ADVERTISE_100FULL
| ADVERTISE_100HALF
))
515 data
[1] |= 0x10; /* set 100 Mbps */
518 data
[2] = (loopback
& 1) ? 0x09 : 0x01;
520 memcpy(pegasus
->eth_regs
, data
, sizeof (data
));
521 ret
= set_registers(pegasus
, EthCtrl0
, 3, data
);
523 if (usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_LINKSYS
||
524 usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_DLINK
) {
526 read_mii_word(pegasus
, 0, 0x1b, &auxmode
);
527 write_mii_word(pegasus
, 0, 0x1b, auxmode
| 4);
533 static void fill_skb_pool(pegasus_t
* pegasus
)
537 for (i
= 0; i
< RX_SKBS
; i
++) {
538 if (pegasus
->rx_pool
[i
])
540 pegasus
->rx_pool
[i
] = dev_alloc_skb(PEGASUS_MTU
+ 2);
542 ** we give up if the allocation fail. the tasklet will be
543 ** rescheduled again anyway...
545 if (pegasus
->rx_pool
[i
] == NULL
)
547 pegasus
->rx_pool
[i
]->dev
= pegasus
->net
;
548 skb_reserve(pegasus
->rx_pool
[i
], 2);
552 static void free_skb_pool(pegasus_t
* pegasus
)
556 for (i
= 0; i
< RX_SKBS
; i
++) {
557 if (pegasus
->rx_pool
[i
]) {
558 dev_kfree_skb(pegasus
->rx_pool
[i
]);
559 pegasus
->rx_pool
[i
] = NULL
;
564 static inline struct sk_buff
*pull_skb(pegasus_t
* pegasus
)
569 for (i
= 0; i
< RX_SKBS
; i
++) {
570 if (likely(pegasus
->rx_pool
[i
] != NULL
)) {
571 skb
= pegasus
->rx_pool
[i
];
572 pegasus
->rx_pool
[i
] = NULL
;
579 static void read_bulk_callback(struct urb
*urb
, struct pt_regs
*regs
)
581 pegasus_t
*pegasus
= urb
->context
;
582 struct net_device
*net
;
583 int rx_status
, count
= urb
->actual_length
;
584 u8
*buf
= urb
->transfer_buffer
;
591 if (!netif_device_present(net
) || !netif_running(net
))
594 switch (urb
->status
) {
598 if (netif_msg_rx_err(pegasus
))
599 pr_debug("%s: reset MAC\n", net
->name
);
600 pegasus
->flags
&= ~PEGASUS_RX_BUSY
;
602 case -EPIPE
: /* stall, or disconnect from TT */
603 /* FIXME schedule work to clear the halt */
604 if (netif_msg_rx_err(pegasus
))
605 printk(KERN_WARNING
"%s: no rx stall recovery\n",
611 if (netif_msg_ifdown(pegasus
))
612 pr_debug("%s: rx unlink, %d\n", net
->name
, urb
->status
);
615 if (netif_msg_rx_err(pegasus
))
616 pr_debug("%s: RX status %d\n", net
->name
, urb
->status
);
620 if (!count
|| count
< 4)
623 rx_status
= buf
[count
- 2];
624 if (rx_status
& 0x1e) {
625 if (netif_msg_rx_err(pegasus
))
626 pr_debug("%s: RX packet error %x\n",
627 net
->name
, rx_status
);
628 pegasus
->stats
.rx_errors
++;
629 if (rx_status
& 0x06) // long or runt
630 pegasus
->stats
.rx_length_errors
++;
631 if (rx_status
& 0x08)
632 pegasus
->stats
.rx_crc_errors
++;
633 if (rx_status
& 0x10) // extra bits
634 pegasus
->stats
.rx_frame_errors
++;
637 if (pegasus
->chip
== 0x8513) {
638 pkt_len
= le32_to_cpu(*(__le32
*)urb
->transfer_buffer
);
640 pegasus
->rx_skb
->data
+= 2;
642 pkt_len
= buf
[count
- 3] << 8;
643 pkt_len
+= buf
[count
- 4];
649 * If the packet is unreasonably long, quietly drop it rather than
650 * kernel panicing by calling skb_put.
652 if (pkt_len
> PEGASUS_MTU
)
656 * at this point we are sure pegasus->rx_skb != NULL
657 * so we go ahead and pass up the packet.
659 skb_put(pegasus
->rx_skb
, pkt_len
);
660 pegasus
->rx_skb
->protocol
= eth_type_trans(pegasus
->rx_skb
, net
);
661 netif_rx(pegasus
->rx_skb
);
662 pegasus
->stats
.rx_packets
++;
663 pegasus
->stats
.rx_bytes
+= pkt_len
;
665 if (pegasus
->flags
& PEGASUS_UNPLUG
)
668 spin_lock(&pegasus
->rx_pool_lock
);
669 pegasus
->rx_skb
= pull_skb(pegasus
);
670 spin_unlock(&pegasus
->rx_pool_lock
);
672 if (pegasus
->rx_skb
== NULL
)
675 usb_fill_bulk_urb(pegasus
->rx_urb
, pegasus
->usb
,
676 usb_rcvbulkpipe(pegasus
->usb
, 1),
677 pegasus
->rx_skb
->data
, PEGASUS_MTU
+ 8,
678 read_bulk_callback
, pegasus
);
679 if (usb_submit_urb(pegasus
->rx_urb
, GFP_ATOMIC
)) {
680 pegasus
->flags
|= PEGASUS_RX_URB_FAIL
;
683 pegasus
->flags
&= ~PEGASUS_RX_URB_FAIL
;
689 tasklet_schedule(&pegasus
->rx_tl
);
692 static void rx_fixup(unsigned long data
)
697 pegasus
= (pegasus_t
*) data
;
698 if (pegasus
->flags
& PEGASUS_UNPLUG
)
701 spin_lock_irqsave(&pegasus
->rx_pool_lock
, flags
);
702 fill_skb_pool(pegasus
);
703 if (pegasus
->flags
& PEGASUS_RX_URB_FAIL
)
706 if (pegasus
->rx_skb
== NULL
) {
707 pegasus
->rx_skb
= pull_skb(pegasus
);
709 if (pegasus
->rx_skb
== NULL
) {
710 if (netif_msg_rx_err(pegasus
))
711 printk(KERN_WARNING
"%s: low on memory\n",
713 tasklet_schedule(&pegasus
->rx_tl
);
716 usb_fill_bulk_urb(pegasus
->rx_urb
, pegasus
->usb
,
717 usb_rcvbulkpipe(pegasus
->usb
, 1),
718 pegasus
->rx_skb
->data
, PEGASUS_MTU
+ 8,
719 read_bulk_callback
, pegasus
);
721 if (usb_submit_urb(pegasus
->rx_urb
, GFP_ATOMIC
)) {
722 pegasus
->flags
|= PEGASUS_RX_URB_FAIL
;
723 tasklet_schedule(&pegasus
->rx_tl
);
725 pegasus
->flags
&= ~PEGASUS_RX_URB_FAIL
;
728 spin_unlock_irqrestore(&pegasus
->rx_pool_lock
, flags
);
731 static void write_bulk_callback(struct urb
*urb
, struct pt_regs
*regs
)
733 pegasus_t
*pegasus
= urb
->context
;
734 struct net_device
*net
= pegasus
->net
;
739 if (!netif_device_present(net
) || !netif_running(net
))
742 switch (urb
->status
) {
744 /* FIXME schedule_work() to clear the tx halt */
745 netif_stop_queue(net
);
746 if (netif_msg_tx_err(pegasus
))
747 printk(KERN_WARNING
"%s: no tx stall recovery\n",
753 if (netif_msg_ifdown(pegasus
))
754 pr_debug("%s: tx unlink, %d\n", net
->name
, urb
->status
);
757 if (netif_msg_tx_err(pegasus
))
758 pr_info("%s: TX status %d\n", net
->name
, urb
->status
);
764 net
->trans_start
= jiffies
;
765 netif_wake_queue(net
);
768 static void intr_callback(struct urb
*urb
, struct pt_regs
*regs
)
770 pegasus_t
*pegasus
= urb
->context
;
771 struct net_device
*net
;
778 switch (urb
->status
) {
781 case -ECONNRESET
: /* unlink */
786 /* some Pegasus-I products report LOTS of data
787 * toggle errors... avoid log spamming
789 if (netif_msg_timer(pegasus
))
790 pr_debug("%s: intr status %d\n", net
->name
,
794 if (urb
->actual_length
>= 6) {
795 u8
* d
= urb
->transfer_buffer
;
797 /* byte 0 == tx_status1, reg 2B */
798 if (d
[0] & (TX_UNDERRUN
|EXCESSIVE_COL
799 |LATE_COL
|JABBER_TIMEOUT
)) {
800 pegasus
->stats
.tx_errors
++;
801 if (d
[0] & TX_UNDERRUN
)
802 pegasus
->stats
.tx_fifo_errors
++;
803 if (d
[0] & (EXCESSIVE_COL
| JABBER_TIMEOUT
))
804 pegasus
->stats
.tx_aborted_errors
++;
806 pegasus
->stats
.tx_window_errors
++;
809 /* d[5].LINK_STATUS lies on some adapters.
810 * d[0].NO_CARRIER kicks in only with failed TX.
811 * ... so monitoring with MII may be safest.
813 if (d
[0] & NO_CARRIER
)
814 netif_carrier_off(net
);
816 netif_carrier_on(net
);
818 /* bytes 3-4 == rx_lostpkt, reg 2E/2F */
819 pegasus
->stats
.rx_missed_errors
+= ((d
[3] & 0x7f) << 8) | d
[4];
822 status
= usb_submit_urb(urb
, SLAB_ATOMIC
);
823 if (status
&& netif_msg_timer(pegasus
))
824 printk(KERN_ERR
"%s: can't resubmit interrupt urb, %d\n",
828 static void pegasus_tx_timeout(struct net_device
*net
)
830 pegasus_t
*pegasus
= netdev_priv(net
);
831 if (netif_msg_timer(pegasus
))
832 printk(KERN_WARNING
"%s: tx timeout\n", net
->name
);
833 usb_unlink_urb(pegasus
->tx_urb
);
834 pegasus
->stats
.tx_errors
++;
837 static int pegasus_start_xmit(struct sk_buff
*skb
, struct net_device
*net
)
839 pegasus_t
*pegasus
= netdev_priv(net
);
840 int count
= ((skb
->len
+ 2) & 0x3f) ? skb
->len
+ 2 : skb
->len
+ 3;
842 __u16 l16
= skb
->len
;
844 netif_stop_queue(net
);
846 ((__le16
*) pegasus
->tx_buff
)[0] = cpu_to_le16(l16
);
847 memcpy(pegasus
->tx_buff
+ 2, skb
->data
, skb
->len
);
848 usb_fill_bulk_urb(pegasus
->tx_urb
, pegasus
->usb
,
849 usb_sndbulkpipe(pegasus
->usb
, 2),
850 pegasus
->tx_buff
, count
,
851 write_bulk_callback
, pegasus
);
852 if ((res
= usb_submit_urb(pegasus
->tx_urb
, GFP_ATOMIC
))) {
853 if (netif_msg_tx_err(pegasus
))
854 printk(KERN_WARNING
"%s: fail tx, %d\n",
857 case -EPIPE
: /* stall, or disconnect from TT */
858 /* cleanup should already have been scheduled */
860 case -ENODEV
: /* disconnect() upcoming */
863 pegasus
->stats
.tx_errors
++;
864 netif_start_queue(net
);
867 pegasus
->stats
.tx_packets
++;
868 pegasus
->stats
.tx_bytes
+= skb
->len
;
869 net
->trans_start
= jiffies
;
876 static struct net_device_stats
*pegasus_netdev_stats(struct net_device
*dev
)
878 return &((pegasus_t
*) netdev_priv(dev
))->stats
;
881 static inline void disable_net_traffic(pegasus_t
* pegasus
)
886 ret
= set_registers(pegasus
, EthCtrl0
, 2, &tmp
);
889 static inline void get_interrupt_interval(pegasus_t
* pegasus
)
893 read_eprom_word(pegasus
, 4, (__u16
*) data
);
894 if (pegasus
->usb
->speed
!= USB_SPEED_HIGH
) {
895 if (data
[1] < 0x80) {
896 if (netif_msg_timer(pegasus
))
897 dev_info(&pegasus
->intf
->dev
, "intr interval "
898 "changed from %ums to %ums\n",
901 #ifdef PEGASUS_WRITE_EEPROM
902 write_eprom_word(pegasus
, 4, *(__u16
*) data
);
906 pegasus
->intr_interval
= data
[1];
909 static void set_carrier(struct net_device
*net
)
911 pegasus_t
*pegasus
= netdev_priv(net
);
914 if (!read_mii_word(pegasus
, pegasus
->phy
, MII_BMSR
, &tmp
))
917 if (tmp
& BMSR_LSTATUS
)
918 netif_carrier_on(net
);
920 netif_carrier_off(net
);
923 static void free_all_urbs(pegasus_t
* pegasus
)
925 usb_free_urb(pegasus
->intr_urb
);
926 usb_free_urb(pegasus
->tx_urb
);
927 usb_free_urb(pegasus
->rx_urb
);
928 usb_free_urb(pegasus
->ctrl_urb
);
931 static void unlink_all_urbs(pegasus_t
* pegasus
)
933 usb_kill_urb(pegasus
->intr_urb
);
934 usb_kill_urb(pegasus
->tx_urb
);
935 usb_kill_urb(pegasus
->rx_urb
);
936 usb_kill_urb(pegasus
->ctrl_urb
);
939 static int alloc_urbs(pegasus_t
* pegasus
)
941 pegasus
->ctrl_urb
= usb_alloc_urb(0, GFP_KERNEL
);
942 if (!pegasus
->ctrl_urb
) {
945 pegasus
->rx_urb
= usb_alloc_urb(0, GFP_KERNEL
);
946 if (!pegasus
->rx_urb
) {
947 usb_free_urb(pegasus
->ctrl_urb
);
950 pegasus
->tx_urb
= usb_alloc_urb(0, GFP_KERNEL
);
951 if (!pegasus
->tx_urb
) {
952 usb_free_urb(pegasus
->rx_urb
);
953 usb_free_urb(pegasus
->ctrl_urb
);
956 pegasus
->intr_urb
= usb_alloc_urb(0, GFP_KERNEL
);
957 if (!pegasus
->intr_urb
) {
958 usb_free_urb(pegasus
->tx_urb
);
959 usb_free_urb(pegasus
->rx_urb
);
960 usb_free_urb(pegasus
->ctrl_urb
);
967 static int pegasus_open(struct net_device
*net
)
969 pegasus_t
*pegasus
= netdev_priv(net
);
972 if (pegasus
->rx_skb
== NULL
)
973 pegasus
->rx_skb
= pull_skb(pegasus
);
975 ** Note: no point to free the pool. it is empty :-)
977 if (!pegasus
->rx_skb
)
980 res
= set_registers(pegasus
, EthID
, 6, net
->dev_addr
);
982 usb_fill_bulk_urb(pegasus
->rx_urb
, pegasus
->usb
,
983 usb_rcvbulkpipe(pegasus
->usb
, 1),
984 pegasus
->rx_skb
->data
, PEGASUS_MTU
+ 8,
985 read_bulk_callback
, pegasus
);
986 if ((res
= usb_submit_urb(pegasus
->rx_urb
, GFP_KERNEL
))) {
987 if (netif_msg_ifup(pegasus
))
988 pr_debug("%s: failed rx_urb, %d", net
->name
, res
);
992 usb_fill_int_urb(pegasus
->intr_urb
, pegasus
->usb
,
993 usb_rcvintpipe(pegasus
->usb
, 3),
994 pegasus
->intr_buff
, sizeof (pegasus
->intr_buff
),
995 intr_callback
, pegasus
, pegasus
->intr_interval
);
996 if ((res
= usb_submit_urb(pegasus
->intr_urb
, GFP_KERNEL
))) {
997 if (netif_msg_ifup(pegasus
))
998 pr_debug("%s: failed intr_urb, %d\n", net
->name
, res
);
999 usb_kill_urb(pegasus
->rx_urb
);
1002 if ((res
= enable_net_traffic(net
, pegasus
->usb
))) {
1003 if (netif_msg_ifup(pegasus
))
1004 pr_debug("%s: can't enable_net_traffic() - %d\n",
1007 usb_kill_urb(pegasus
->rx_urb
);
1008 usb_kill_urb(pegasus
->intr_urb
);
1009 free_skb_pool(pegasus
);
1013 netif_start_queue(net
);
1014 if (netif_msg_ifup(pegasus
))
1015 pr_debug("%s: open\n", net
->name
);
1021 static int pegasus_close(struct net_device
*net
)
1023 pegasus_t
*pegasus
= netdev_priv(net
);
1025 netif_stop_queue(net
);
1026 if (!(pegasus
->flags
& PEGASUS_UNPLUG
))
1027 disable_net_traffic(pegasus
);
1028 tasklet_kill(&pegasus
->rx_tl
);
1029 unlink_all_urbs(pegasus
);
1034 static void pegasus_get_drvinfo(struct net_device
*dev
,
1035 struct ethtool_drvinfo
*info
)
1037 pegasus_t
*pegasus
= netdev_priv(dev
);
1038 strncpy(info
->driver
, driver_name
, sizeof (info
->driver
) - 1);
1039 strncpy(info
->version
, DRIVER_VERSION
, sizeof (info
->version
) - 1);
1040 usb_make_path(pegasus
->usb
, info
->bus_info
, sizeof (info
->bus_info
));
1043 /* also handles three patterns of some kind in hardware */
1044 #define WOL_SUPPORTED (WAKE_MAGIC|WAKE_PHY)
1047 pegasus_get_wol(struct net_device
*dev
, struct ethtool_wolinfo
*wol
)
1049 pegasus_t
*pegasus
= netdev_priv(dev
);
1051 wol
->supported
= WAKE_MAGIC
| WAKE_PHY
;
1052 wol
->wolopts
= pegasus
->wolopts
;
1056 pegasus_set_wol(struct net_device
*dev
, struct ethtool_wolinfo
*wol
)
1058 pegasus_t
*pegasus
= netdev_priv(dev
);
1061 if (wol
->wolopts
& ~WOL_SUPPORTED
)
1064 if (wol
->wolopts
& WAKE_MAGIC
)
1066 if (wol
->wolopts
& WAKE_PHY
)
1068 /* FIXME this 0x10 bit still needs to get set in the chip... */
1070 pegasus
->eth_regs
[0] |= 0x10;
1072 pegasus
->eth_regs
[0] &= ~0x10;
1073 pegasus
->wolopts
= wol
->wolopts
;
1074 return set_register(pegasus
, WakeupControl
, reg78
);
1077 static inline void pegasus_reset_wol(struct net_device
*dev
)
1079 struct ethtool_wolinfo wol
;
1081 memset(&wol
, 0, sizeof wol
);
1082 (void) pegasus_set_wol(dev
, &wol
);
1086 pegasus_get_settings(struct net_device
*dev
, struct ethtool_cmd
*ecmd
)
1093 pegasus
= netdev_priv(dev
);
1094 mii_ethtool_gset(&pegasus
->mii
, ecmd
);
1100 pegasus_set_settings(struct net_device
*dev
, struct ethtool_cmd
*ecmd
)
1102 pegasus_t
*pegasus
= netdev_priv(dev
);
1103 return mii_ethtool_sset(&pegasus
->mii
, ecmd
);
1106 static int pegasus_nway_reset(struct net_device
*dev
)
1108 pegasus_t
*pegasus
= netdev_priv(dev
);
1109 return mii_nway_restart(&pegasus
->mii
);
1112 static u32
pegasus_get_link(struct net_device
*dev
)
1114 pegasus_t
*pegasus
= netdev_priv(dev
);
1115 return mii_link_ok(&pegasus
->mii
);
1118 static u32
pegasus_get_msglevel(struct net_device
*dev
)
1120 pegasus_t
*pegasus
= netdev_priv(dev
);
1121 return pegasus
->msg_enable
;
1124 static void pegasus_set_msglevel(struct net_device
*dev
, u32 v
)
1126 pegasus_t
*pegasus
= netdev_priv(dev
);
1127 pegasus
->msg_enable
= v
;
1130 static struct ethtool_ops ops
= {
1131 .get_drvinfo
= pegasus_get_drvinfo
,
1132 .get_settings
= pegasus_get_settings
,
1133 .set_settings
= pegasus_set_settings
,
1134 .nway_reset
= pegasus_nway_reset
,
1135 .get_link
= pegasus_get_link
,
1136 .get_msglevel
= pegasus_get_msglevel
,
1137 .set_msglevel
= pegasus_set_msglevel
,
1138 .get_wol
= pegasus_get_wol
,
1139 .set_wol
= pegasus_set_wol
,
1142 static int pegasus_ioctl(struct net_device
*net
, struct ifreq
*rq
, int cmd
)
1144 __u16
*data
= (__u16
*) & rq
->ifr_ifru
;
1145 pegasus_t
*pegasus
= netdev_priv(net
);
1149 case SIOCDEVPRIVATE
:
1150 data
[0] = pegasus
->phy
;
1151 case SIOCDEVPRIVATE
+ 1:
1152 read_mii_word(pegasus
, data
[0], data
[1] & 0x1f, &data
[3]);
1155 case SIOCDEVPRIVATE
+ 2:
1156 if (!capable(CAP_NET_ADMIN
))
1158 write_mii_word(pegasus
, pegasus
->phy
, data
[1] & 0x1f, data
[2]);
1167 static void pegasus_set_multicast(struct net_device
*net
)
1169 pegasus_t
*pegasus
= netdev_priv(net
);
1171 if (net
->flags
& IFF_PROMISC
) {
1172 pegasus
->eth_regs
[EthCtrl2
] |= RX_PROMISCUOUS
;
1173 if (netif_msg_link(pegasus
))
1174 pr_info("%s: Promiscuous mode enabled.\n", net
->name
);
1175 } else if (net
->mc_count
||
1176 (net
->flags
& IFF_ALLMULTI
)) {
1177 pegasus
->eth_regs
[EthCtrl0
] |= RX_MULTICAST
;
1178 pegasus
->eth_regs
[EthCtrl2
] &= ~RX_PROMISCUOUS
;
1179 if (netif_msg_link(pegasus
))
1180 pr_info("%s: set allmulti\n", net
->name
);
1182 pegasus
->eth_regs
[EthCtrl0
] &= ~RX_MULTICAST
;
1183 pegasus
->eth_regs
[EthCtrl2
] &= ~RX_PROMISCUOUS
;
1186 pegasus
->flags
|= ETH_REGS_CHANGE
;
1187 ctrl_callback(pegasus
->ctrl_urb
, NULL
);
1190 static __u8
mii_phy_probe(pegasus_t
* pegasus
)
1195 for (i
= 0; i
< 32; i
++) {
1196 read_mii_word(pegasus
, i
, MII_BMSR
, &tmp
);
1197 if (tmp
== 0 || tmp
== 0xffff || (tmp
& BMSR_MEDIA
) == 0)
1206 static inline void setup_pegasus_II(pegasus_t
* pegasus
)
1211 ret
= set_register(pegasus
, Reg1d
, 0);
1212 ret
= set_register(pegasus
, Reg7b
, 1);
1214 if ((pegasus
->features
& HAS_HOME_PNA
) && mii_mode
)
1215 ret
= set_register(pegasus
, Reg7b
, 0);
1217 ret
= set_register(pegasus
, Reg7b
, 2);
1219 ret
= set_register(pegasus
, 0x83, data
);
1220 ret
= get_registers(pegasus
, 0x83, 1, &data
);
1223 pegasus
->chip
= 0x8513;
1228 ret
= set_register(pegasus
, 0x80, 0xc0);
1229 ret
= set_register(pegasus
, 0x83, 0xff);
1230 ret
= set_register(pegasus
, 0x84, 0x01);
1232 if (pegasus
->features
& HAS_HOME_PNA
&& mii_mode
)
1233 ret
= set_register(pegasus
, Reg81
, 6);
1235 ret
= set_register(pegasus
, Reg81
, 2);
1239 static struct workqueue_struct
*pegasus_workqueue
= NULL
;
1240 #define CARRIER_CHECK_DELAY (2 * HZ)
1242 static void check_carrier(void *data
)
1244 pegasus_t
*pegasus
= data
;
1245 set_carrier(pegasus
->net
);
1246 if (!(pegasus
->flags
& PEGASUS_UNPLUG
)) {
1247 queue_delayed_work(pegasus_workqueue
, &pegasus
->carrier_check
,
1248 CARRIER_CHECK_DELAY
);
1252 static int pegasus_probe(struct usb_interface
*intf
,
1253 const struct usb_device_id
*id
)
1255 struct usb_device
*dev
= interface_to_usbdev(intf
);
1256 struct net_device
*net
;
1258 int dev_index
= id
- pegasus_ids
;
1262 net
= alloc_etherdev(sizeof(struct pegasus
));
1264 dev_err(&intf
->dev
, "can't allocate %s\n", "device");
1268 pegasus
= netdev_priv(net
);
1269 memset(pegasus
, 0, sizeof (struct pegasus
));
1270 pegasus
->dev_index
= dev_index
;
1271 init_waitqueue_head(&pegasus
->ctrl_wait
);
1273 if (!alloc_urbs(pegasus
)) {
1274 dev_err(&intf
->dev
, "can't allocate %s\n", "urbs");
1278 tasklet_init(&pegasus
->rx_tl
, rx_fixup
, (unsigned long) pegasus
);
1280 INIT_WORK(&pegasus
->carrier_check
, check_carrier
, pegasus
);
1282 pegasus
->intf
= intf
;
1285 SET_MODULE_OWNER(net
);
1286 net
->open
= pegasus_open
;
1287 net
->stop
= pegasus_close
;
1288 net
->watchdog_timeo
= PEGASUS_TX_TIMEOUT
;
1289 net
->tx_timeout
= pegasus_tx_timeout
;
1290 net
->do_ioctl
= pegasus_ioctl
;
1291 net
->hard_start_xmit
= pegasus_start_xmit
;
1292 net
->set_multicast_list
= pegasus_set_multicast
;
1293 net
->get_stats
= pegasus_netdev_stats
;
1294 SET_ETHTOOL_OPS(net
, &ops
);
1295 pegasus
->mii
.dev
= net
;
1296 pegasus
->mii
.mdio_read
= mdio_read
;
1297 pegasus
->mii
.mdio_write
= mdio_write
;
1298 pegasus
->mii
.phy_id_mask
= 0x1f;
1299 pegasus
->mii
.reg_num_mask
= 0x1f;
1300 spin_lock_init(&pegasus
->rx_pool_lock
);
1301 pegasus
->msg_enable
= netif_msg_init (msg_level
, NETIF_MSG_DRV
1302 | NETIF_MSG_PROBE
| NETIF_MSG_LINK
);
1304 pegasus
->features
= usb_dev_id
[dev_index
].private;
1305 get_interrupt_interval(pegasus
);
1306 if (reset_mac(pegasus
)) {
1307 dev_err(&intf
->dev
, "can't reset MAC\n");
1311 set_ethernet_addr(pegasus
);
1312 fill_skb_pool(pegasus
);
1313 if (pegasus
->features
& PEGASUS_II
) {
1314 dev_info(&intf
->dev
, "setup Pegasus II specific registers\n");
1315 setup_pegasus_II(pegasus
);
1317 pegasus
->phy
= mii_phy_probe(pegasus
);
1318 if (pegasus
->phy
== 0xff) {
1319 dev_warn(&intf
->dev
, "can't locate MII phy, using default\n");
1322 pegasus
->mii
.phy_id
= pegasus
->phy
;
1323 usb_set_intfdata(intf
, pegasus
);
1324 SET_NETDEV_DEV(net
, &intf
->dev
);
1325 pegasus_reset_wol(net
);
1326 res
= register_netdev(net
);
1329 queue_delayed_work(pegasus_workqueue
, &pegasus
->carrier_check
,
1330 CARRIER_CHECK_DELAY
);
1332 dev_info(&intf
->dev
, "%s, %s, %02x:%02x:%02x:%02x:%02x:%02x\n",
1334 usb_dev_id
[dev_index
].name
,
1335 net
->dev_addr
[0], net
->dev_addr
[1],
1336 net
->dev_addr
[2], net
->dev_addr
[3],
1337 net
->dev_addr
[4], net
->dev_addr
[5]);
1341 usb_set_intfdata(intf
, NULL
);
1342 free_skb_pool(pegasus
);
1344 free_all_urbs(pegasus
);
1352 static void pegasus_disconnect(struct usb_interface
*intf
)
1354 struct pegasus
*pegasus
= usb_get_intfdata(intf
);
1356 usb_set_intfdata(intf
, NULL
);
1358 dev_dbg(&intf
->dev
, "unregistering non-bound device?\n");
1362 pegasus
->flags
|= PEGASUS_UNPLUG
;
1363 cancel_delayed_work(&pegasus
->carrier_check
);
1364 unregister_netdev(pegasus
->net
);
1365 usb_put_dev(interface_to_usbdev(intf
));
1366 unlink_all_urbs(pegasus
);
1367 free_all_urbs(pegasus
);
1368 free_skb_pool(pegasus
);
1369 if (pegasus
->rx_skb
)
1370 dev_kfree_skb(pegasus
->rx_skb
);
1371 free_netdev(pegasus
->net
);
1374 static int pegasus_suspend (struct usb_interface
*intf
, pm_message_t message
)
1376 struct pegasus
*pegasus
= usb_get_intfdata(intf
);
1378 netif_device_detach (pegasus
->net
);
1379 if (netif_running(pegasus
->net
)) {
1380 cancel_delayed_work(&pegasus
->carrier_check
);
1382 usb_kill_urb(pegasus
->rx_urb
);
1383 usb_kill_urb(pegasus
->intr_urb
);
1388 static int pegasus_resume (struct usb_interface
*intf
)
1390 struct pegasus
*pegasus
= usb_get_intfdata(intf
);
1392 netif_device_attach (pegasus
->net
);
1393 if (netif_running(pegasus
->net
)) {
1394 pegasus
->rx_urb
->status
= 0;
1395 pegasus
->rx_urb
->actual_length
= 0;
1396 read_bulk_callback(pegasus
->rx_urb
, NULL
);
1398 pegasus
->intr_urb
->status
= 0;
1399 pegasus
->intr_urb
->actual_length
= 0;
1400 intr_callback(pegasus
->intr_urb
, NULL
);
1402 queue_delayed_work(pegasus_workqueue
, &pegasus
->carrier_check
,
1403 CARRIER_CHECK_DELAY
);
1408 static struct usb_driver pegasus_driver
= {
1409 .name
= driver_name
,
1410 .probe
= pegasus_probe
,
1411 .disconnect
= pegasus_disconnect
,
1412 .id_table
= pegasus_ids
,
1413 .suspend
= pegasus_suspend
,
1414 .resume
= pegasus_resume
,
1417 static int __init
pegasus_init(void)
1419 pr_info("%s: %s, " DRIVER_DESC
"\n", driver_name
, DRIVER_VERSION
);
1420 pegasus_workqueue
= create_singlethread_workqueue("pegasus");
1421 if (!pegasus_workqueue
)
1423 return usb_register(&pegasus_driver
);
1426 static void __exit
pegasus_exit(void)
1428 destroy_workqueue(pegasus_workqueue
);
1429 usb_deregister(&pegasus_driver
);
1432 module_init(pegasus_init
);
1433 module_exit(pegasus_exit
);