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;
62 static int multicast_filter_limit
= 32;
64 static struct usb_eth_dev usb_dev_id
[] = {
65 #define PEGASUS_DEV(pn, vid, pid, flags) \
66 {.name = pn, .vendor = vid, .device = pid, .private = flags},
72 static struct usb_device_id pegasus_ids
[] = {
73 #define PEGASUS_DEV(pn, vid, pid, flags) \
74 {.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = vid, .idProduct = pid},
80 MODULE_AUTHOR(DRIVER_AUTHOR
);
81 MODULE_DESCRIPTION(DRIVER_DESC
);
82 MODULE_LICENSE("GPL");
83 module_param(loopback
, bool, 0);
84 module_param(mii_mode
, bool, 0);
85 MODULE_PARM_DESC(loopback
, "Enable MAC loopback mode (bit 0)");
86 MODULE_PARM_DESC(mii_mode
, "Enable HomePNA mode (bit 0),default=MII mode = 0");
88 /* use ethtool to change the level for any given device */
89 static int msg_level
= -1;
90 module_param (msg_level
, int, 0);
91 MODULE_PARM_DESC (msg_level
, "Override default message level");
93 MODULE_DEVICE_TABLE(usb
, pegasus_ids
);
95 static int update_eth_regs_async(pegasus_t
*);
96 /* Aargh!!! I _really_ hate such tweaks */
97 static void ctrl_callback(struct urb
*urb
, struct pt_regs
*regs
)
99 pegasus_t
*pegasus
= urb
->context
;
104 switch (urb
->status
) {
106 if (pegasus
->flags
& ETH_REGS_CHANGE
) {
107 pegasus
->flags
&= ~ETH_REGS_CHANGE
;
108 pegasus
->flags
|= ETH_REGS_CHANGED
;
109 update_eth_regs_async(pegasus
);
118 if (netif_msg_drv(pegasus
))
119 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
120 __FUNCTION__
, urb
->status
);
122 pegasus
->flags
&= ~ETH_REGS_CHANGED
;
123 wake_up(&pegasus
->ctrl_wait
);
126 static int get_registers(pegasus_t
* pegasus
, __u16 indx
, __u16 size
,
131 DECLARE_WAITQUEUE(wait
, current
);
133 buffer
= kmalloc(size
, GFP_KERNEL
);
135 if (netif_msg_drv(pegasus
))
136 dev_warn(&pegasus
->intf
->dev
, "out of memory in %s\n",
140 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
141 set_current_state(TASK_UNINTERRUPTIBLE
);
142 while (pegasus
->flags
& ETH_REGS_CHANGED
)
144 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
145 set_current_state(TASK_RUNNING
);
147 pegasus
->dr
.bRequestType
= PEGASUS_REQT_READ
;
148 pegasus
->dr
.bRequest
= PEGASUS_REQ_GET_REGS
;
149 pegasus
->dr
.wValue
= cpu_to_le16(0);
150 pegasus
->dr
.wIndex
= cpu_to_le16p(&indx
);
151 pegasus
->dr
.wLength
= cpu_to_le16p(&size
);
152 pegasus
->ctrl_urb
->transfer_buffer_length
= size
;
154 usb_fill_control_urb(pegasus
->ctrl_urb
, pegasus
->usb
,
155 usb_rcvctrlpipe(pegasus
->usb
, 0),
156 (char *) &pegasus
->dr
,
157 buffer
, size
, ctrl_callback
, pegasus
);
159 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
160 set_current_state(TASK_UNINTERRUPTIBLE
);
162 /* using ATOMIC, we'd never wake up if we slept */
163 if ((ret
= usb_submit_urb(pegasus
->ctrl_urb
, GFP_ATOMIC
))) {
164 if (netif_msg_drv(pegasus
))
165 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
172 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
173 memcpy(data
, buffer
, size
);
179 static int set_registers(pegasus_t
* pegasus
, __u16 indx
, __u16 size
,
184 DECLARE_WAITQUEUE(wait
, current
);
186 buffer
= kmalloc(size
, GFP_KERNEL
);
188 if (netif_msg_drv(pegasus
))
189 dev_warn(&pegasus
->intf
->dev
, "out of memory in %s\n",
193 memcpy(buffer
, data
, size
);
195 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
196 set_current_state(TASK_UNINTERRUPTIBLE
);
197 while (pegasus
->flags
& ETH_REGS_CHANGED
)
199 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
200 set_current_state(TASK_RUNNING
);
202 pegasus
->dr
.bRequestType
= PEGASUS_REQT_WRITE
;
203 pegasus
->dr
.bRequest
= PEGASUS_REQ_SET_REGS
;
204 pegasus
->dr
.wValue
= cpu_to_le16(0);
205 pegasus
->dr
.wIndex
= cpu_to_le16p(&indx
);
206 pegasus
->dr
.wLength
= cpu_to_le16p(&size
);
207 pegasus
->ctrl_urb
->transfer_buffer_length
= size
;
209 usb_fill_control_urb(pegasus
->ctrl_urb
, pegasus
->usb
,
210 usb_sndctrlpipe(pegasus
->usb
, 0),
211 (char *) &pegasus
->dr
,
212 buffer
, size
, ctrl_callback
, pegasus
);
214 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
215 set_current_state(TASK_UNINTERRUPTIBLE
);
217 if ((ret
= usb_submit_urb(pegasus
->ctrl_urb
, GFP_ATOMIC
))) {
218 if (netif_msg_drv(pegasus
))
219 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
226 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
232 static int set_register(pegasus_t
* pegasus
, __u16 indx
, __u8 data
)
236 DECLARE_WAITQUEUE(wait
, current
);
238 tmp
= kmalloc(1, GFP_KERNEL
);
240 if (netif_msg_drv(pegasus
))
241 dev_warn(&pegasus
->intf
->dev
, "out of memory in %s\n",
245 memcpy(tmp
, &data
, 1);
246 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
247 set_current_state(TASK_UNINTERRUPTIBLE
);
248 while (pegasus
->flags
& ETH_REGS_CHANGED
)
250 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
251 set_current_state(TASK_RUNNING
);
253 pegasus
->dr
.bRequestType
= PEGASUS_REQT_WRITE
;
254 pegasus
->dr
.bRequest
= PEGASUS_REQ_SET_REG
;
255 pegasus
->dr
.wValue
= cpu_to_le16(data
);
256 pegasus
->dr
.wIndex
= cpu_to_le16p(&indx
);
257 pegasus
->dr
.wLength
= cpu_to_le16(1);
258 pegasus
->ctrl_urb
->transfer_buffer_length
= 1;
260 usb_fill_control_urb(pegasus
->ctrl_urb
, pegasus
->usb
,
261 usb_sndctrlpipe(pegasus
->usb
, 0),
262 (char *) &pegasus
->dr
,
263 &tmp
, 1, ctrl_callback
, pegasus
);
265 add_wait_queue(&pegasus
->ctrl_wait
, &wait
);
266 set_current_state(TASK_UNINTERRUPTIBLE
);
268 if ((ret
= usb_submit_urb(pegasus
->ctrl_urb
, GFP_ATOMIC
))) {
269 if (netif_msg_drv(pegasus
))
270 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
277 remove_wait_queue(&pegasus
->ctrl_wait
, &wait
);
283 static int update_eth_regs_async(pegasus_t
* pegasus
)
287 pegasus
->dr
.bRequestType
= PEGASUS_REQT_WRITE
;
288 pegasus
->dr
.bRequest
= PEGASUS_REQ_SET_REGS
;
289 pegasus
->dr
.wValue
= 0;
290 pegasus
->dr
.wIndex
= cpu_to_le16(EthCtrl0
);
291 pegasus
->dr
.wLength
= cpu_to_le16(3);
292 pegasus
->ctrl_urb
->transfer_buffer_length
= 3;
294 usb_fill_control_urb(pegasus
->ctrl_urb
, pegasus
->usb
,
295 usb_sndctrlpipe(pegasus
->usb
, 0),
296 (char *) &pegasus
->dr
,
297 pegasus
->eth_regs
, 3, ctrl_callback
, pegasus
);
299 if ((ret
= usb_submit_urb(pegasus
->ctrl_urb
, GFP_ATOMIC
)))
300 if (netif_msg_drv(pegasus
))
301 dev_err(&pegasus
->intf
->dev
, "%s, status %d\n",
307 static int read_mii_word(pegasus_t
* pegasus
, __u8 phy
, __u8 indx
, __u16
* regd
)
310 __u8 data
[4] = { phy
, 0, 0, indx
};
314 ret
= set_register(pegasus
, PhyCtrl
, 0);
315 ret
= set_registers(pegasus
, PhyAddr
, sizeof (data
), data
);
316 ret
= set_register(pegasus
, PhyCtrl
, (indx
| PHY_READ
));
317 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
318 ret
= get_registers(pegasus
, PhyCtrl
, 1, data
);
319 if (data
[0] & PHY_DONE
)
322 if (i
< REG_TIMEOUT
) {
323 ret
= get_registers(pegasus
, PhyData
, 2, ®di
);
324 *regd
= le16_to_cpu(regdi
);
327 if (netif_msg_drv(pegasus
))
328 dev_warn(&pegasus
->intf
->dev
, "fail %s\n", __FUNCTION__
);
333 static int mdio_read(struct net_device
*dev
, int phy_id
, int loc
)
335 pegasus_t
*pegasus
= (pegasus_t
*) netdev_priv(dev
);
338 read_mii_word(pegasus
, phy_id
, loc
, &res
);
342 static int write_mii_word(pegasus_t
* pegasus
, __u8 phy
, __u8 indx
, __u16 regd
)
345 __u8 data
[4] = { phy
, 0, 0, indx
};
349 data
[2] = (u8
) (regd
>> 8);
350 ret
= set_register(pegasus
, PhyCtrl
, 0);
351 ret
= set_registers(pegasus
, PhyAddr
, sizeof(data
), data
);
352 ret
= set_register(pegasus
, PhyCtrl
, (indx
| PHY_WRITE
));
353 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
354 ret
= get_registers(pegasus
, PhyCtrl
, 1, data
);
355 if (data
[0] & PHY_DONE
)
361 if (netif_msg_drv(pegasus
))
362 dev_warn(&pegasus
->intf
->dev
, "fail %s\n", __FUNCTION__
);
366 static void mdio_write(struct net_device
*dev
, int phy_id
, int loc
, int val
)
368 pegasus_t
*pegasus
= (pegasus_t
*) netdev_priv(dev
);
370 write_mii_word(pegasus
, phy_id
, loc
, val
);
373 static int read_eprom_word(pegasus_t
* pegasus
, __u8 index
, __u16
* retdata
)
380 ret
= set_register(pegasus
, EpromCtrl
, 0);
381 ret
= set_register(pegasus
, EpromOffset
, index
);
382 ret
= set_register(pegasus
, EpromCtrl
, EPROM_READ
);
384 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
385 ret
= get_registers(pegasus
, EpromCtrl
, 1, &tmp
);
386 if (tmp
& EPROM_DONE
)
389 if (i
< REG_TIMEOUT
) {
390 ret
= get_registers(pegasus
, EpromData
, 2, &retdatai
);
391 *retdata
= le16_to_cpu(retdatai
);
395 if (netif_msg_drv(pegasus
))
396 dev_warn(&pegasus
->intf
->dev
, "fail %s\n", __FUNCTION__
);
400 #ifdef PEGASUS_WRITE_EEPROM
401 static inline void enable_eprom_write(pegasus_t
* pegasus
)
406 ret
= get_registers(pegasus
, EthCtrl2
, 1, &tmp
);
407 ret
= set_register(pegasus
, EthCtrl2
, tmp
| EPROM_WR_ENABLE
);
410 static inline void disable_eprom_write(pegasus_t
* pegasus
)
415 ret
= get_registers(pegasus
, EthCtrl2
, 1, &tmp
);
416 ret
= set_register(pegasus
, EpromCtrl
, 0);
417 ret
= set_register(pegasus
, EthCtrl2
, tmp
& ~EPROM_WR_ENABLE
);
420 static int write_eprom_word(pegasus_t
* pegasus
, __u8 index
, __u16 data
)
423 __u8 tmp
, d
[4] = { 0x3f, 0, 0, EPROM_WRITE
};
426 ret
= set_registers(pegasus
, EpromOffset
, 4, d
);
427 enable_eprom_write(pegasus
);
428 ret
= set_register(pegasus
, EpromOffset
, index
);
429 ret
= set_registers(pegasus
, EpromData
, 2, &data
);
430 ret
= set_register(pegasus
, EpromCtrl
, EPROM_WRITE
);
432 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
433 ret
= get_registers(pegasus
, EpromCtrl
, 1, &tmp
);
434 if (tmp
& EPROM_DONE
)
437 disable_eprom_write(pegasus
);
440 if (netif_msg_drv(pegasus
))
441 dev_warn(&pegasus
->intf
->dev
, "fail %s\n", __FUNCTION__
);
444 #endif /* PEGASUS_WRITE_EEPROM */
446 static inline void get_node_id(pegasus_t
* pegasus
, __u8
* id
)
451 for (i
= 0; i
< 3; i
++) {
452 read_eprom_word(pegasus
, i
, &w16
);
453 ((__le16
*) id
)[i
] = cpu_to_le16p(&w16
);
457 static void set_ethernet_addr(pegasus_t
* pegasus
)
462 get_node_id(pegasus
, node_id
);
463 ret
= set_registers(pegasus
, EthID
, sizeof (node_id
), node_id
);
464 memcpy(pegasus
->net
->dev_addr
, node_id
, sizeof (node_id
));
467 static inline int reset_mac(pegasus_t
* pegasus
)
473 ret
= set_register(pegasus
, EthCtrl1
, data
);
474 for (i
= 0; i
< REG_TIMEOUT
; i
++) {
475 ret
= get_registers(pegasus
, EthCtrl1
, 1, &data
);
479 if (mii_mode
&& (pegasus
->features
& HAS_HOME_PNA
))
480 ret
= set_register(pegasus
, Gpio1
, 0x34);
482 ret
= set_register(pegasus
, Gpio1
, 0x26);
483 ret
= set_register(pegasus
, Gpio0
, pegasus
->features
);
484 ret
= set_register(pegasus
, Gpio0
, DEFAULT_GPIO_SET
);
488 if (i
== REG_TIMEOUT
)
491 if (usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_LINKSYS
||
492 usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_DLINK
) {
493 ret
= set_register(pegasus
, Gpio0
, 0x24);
494 ret
= set_register(pegasus
, Gpio0
, 0x26);
496 if (usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_ELCON
) {
498 read_mii_word(pegasus
, 3, 0x1b, &auxmode
);
499 write_mii_word(pegasus
, 3, 0x1b, auxmode
| 4);
505 static int enable_net_traffic(struct net_device
*dev
, struct usb_device
*usb
)
509 pegasus_t
*pegasus
= netdev_priv(dev
);
512 read_mii_word(pegasus
, pegasus
->phy
, MII_LPA
, &linkpart
);
515 if (linkpart
& (ADVERTISE_100FULL
| ADVERTISE_10FULL
))
516 data
[1] |= 0x20; /* set full duplex */
517 if (linkpart
& (ADVERTISE_100FULL
| ADVERTISE_100HALF
))
518 data
[1] |= 0x10; /* set 100 Mbps */
521 data
[2] = (loopback
& 1) ? 0x09 : 0x01;
523 memcpy(pegasus
->eth_regs
, data
, sizeof (data
));
524 ret
= set_registers(pegasus
, EthCtrl0
, 3, data
);
526 if (usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_LINKSYS
||
527 usb_dev_id
[pegasus
->dev_index
].vendor
== VENDOR_DLINK
) {
529 read_mii_word(pegasus
, 0, 0x1b, &auxmode
);
530 write_mii_word(pegasus
, 0, 0x1b, auxmode
| 4);
536 static void fill_skb_pool(pegasus_t
* pegasus
)
540 for (i
= 0; i
< RX_SKBS
; i
++) {
541 if (pegasus
->rx_pool
[i
])
543 pegasus
->rx_pool
[i
] = dev_alloc_skb(PEGASUS_MTU
+ 2);
545 ** we give up if the allocation fail. the tasklet will be
546 ** rescheduled again anyway...
548 if (pegasus
->rx_pool
[i
] == NULL
)
550 pegasus
->rx_pool
[i
]->dev
= pegasus
->net
;
551 skb_reserve(pegasus
->rx_pool
[i
], 2);
555 static void free_skb_pool(pegasus_t
* pegasus
)
559 for (i
= 0; i
< RX_SKBS
; i
++) {
560 if (pegasus
->rx_pool
[i
]) {
561 dev_kfree_skb(pegasus
->rx_pool
[i
]);
562 pegasus
->rx_pool
[i
] = NULL
;
567 static inline struct sk_buff
*pull_skb(pegasus_t
* pegasus
)
572 for (i
= 0; i
< RX_SKBS
; i
++) {
573 if (likely(pegasus
->rx_pool
[i
] != NULL
)) {
574 skb
= pegasus
->rx_pool
[i
];
575 pegasus
->rx_pool
[i
] = NULL
;
582 static void read_bulk_callback(struct urb
*urb
, struct pt_regs
*regs
)
584 pegasus_t
*pegasus
= urb
->context
;
585 struct net_device
*net
;
586 int rx_status
, count
= urb
->actual_length
;
587 u8
*buf
= urb
->transfer_buffer
;
594 if (!netif_device_present(net
) || !netif_running(net
))
597 switch (urb
->status
) {
601 if (netif_msg_rx_err(pegasus
))
602 pr_debug("%s: reset MAC\n", net
->name
);
603 pegasus
->flags
&= ~PEGASUS_RX_BUSY
;
605 case -EPIPE
: /* stall, or disconnect from TT */
606 /* FIXME schedule work to clear the halt */
607 if (netif_msg_rx_err(pegasus
))
608 printk(KERN_WARNING
"%s: no rx stall recovery\n",
614 if (netif_msg_ifdown(pegasus
))
615 pr_debug("%s: rx unlink, %d\n", net
->name
, urb
->status
);
618 if (netif_msg_rx_err(pegasus
))
619 pr_debug("%s: RX status %d\n", net
->name
, urb
->status
);
623 if (!count
|| count
< 4)
626 rx_status
= buf
[count
- 2];
627 if (rx_status
& 0x1e) {
628 if (netif_msg_rx_err(pegasus
))
629 pr_debug("%s: RX packet error %x\n",
630 net
->name
, rx_status
);
631 pegasus
->stats
.rx_errors
++;
632 if (rx_status
& 0x06) // long or runt
633 pegasus
->stats
.rx_length_errors
++;
634 if (rx_status
& 0x08)
635 pegasus
->stats
.rx_crc_errors
++;
636 if (rx_status
& 0x10) // extra bits
637 pegasus
->stats
.rx_frame_errors
++;
640 if (pegasus
->chip
== 0x8513) {
641 pkt_len
= le32_to_cpu(*(__le32
*)urb
->transfer_buffer
);
643 pegasus
->rx_skb
->data
+= 2;
645 pkt_len
= buf
[count
- 3] << 8;
646 pkt_len
+= buf
[count
- 4];
652 * at this point we are sure pegasus->rx_skb != NULL
653 * so we go ahead and pass up the packet.
655 skb_put(pegasus
->rx_skb
, pkt_len
);
656 pegasus
->rx_skb
->protocol
= eth_type_trans(pegasus
->rx_skb
, net
);
657 netif_rx(pegasus
->rx_skb
);
658 pegasus
->stats
.rx_packets
++;
659 pegasus
->stats
.rx_bytes
+= pkt_len
;
661 if (pegasus
->flags
& PEGASUS_UNPLUG
)
664 spin_lock(&pegasus
->rx_pool_lock
);
665 pegasus
->rx_skb
= pull_skb(pegasus
);
666 spin_unlock(&pegasus
->rx_pool_lock
);
668 if (pegasus
->rx_skb
== NULL
)
671 usb_fill_bulk_urb(pegasus
->rx_urb
, pegasus
->usb
,
672 usb_rcvbulkpipe(pegasus
->usb
, 1),
673 pegasus
->rx_skb
->data
, PEGASUS_MTU
+ 8,
674 read_bulk_callback
, pegasus
);
675 if (usb_submit_urb(pegasus
->rx_urb
, GFP_ATOMIC
)) {
676 pegasus
->flags
|= PEGASUS_RX_URB_FAIL
;
679 pegasus
->flags
&= ~PEGASUS_RX_URB_FAIL
;
685 tasklet_schedule(&pegasus
->rx_tl
);
688 static void rx_fixup(unsigned long data
)
693 pegasus
= (pegasus_t
*) data
;
694 if (pegasus
->flags
& PEGASUS_UNPLUG
)
697 spin_lock_irqsave(&pegasus
->rx_pool_lock
, flags
);
698 fill_skb_pool(pegasus
);
699 if (pegasus
->flags
& PEGASUS_RX_URB_FAIL
)
702 if (pegasus
->rx_skb
== NULL
) {
703 pegasus
->rx_skb
= pull_skb(pegasus
);
705 if (pegasus
->rx_skb
== NULL
) {
706 if (netif_msg_rx_err(pegasus
))
707 printk(KERN_WARNING
"%s: low on memory\n",
709 tasklet_schedule(&pegasus
->rx_tl
);
712 usb_fill_bulk_urb(pegasus
->rx_urb
, pegasus
->usb
,
713 usb_rcvbulkpipe(pegasus
->usb
, 1),
714 pegasus
->rx_skb
->data
, PEGASUS_MTU
+ 8,
715 read_bulk_callback
, pegasus
);
717 if (usb_submit_urb(pegasus
->rx_urb
, GFP_ATOMIC
)) {
718 pegasus
->flags
|= PEGASUS_RX_URB_FAIL
;
719 tasklet_schedule(&pegasus
->rx_tl
);
721 pegasus
->flags
&= ~PEGASUS_RX_URB_FAIL
;
724 spin_unlock_irqrestore(&pegasus
->rx_pool_lock
, flags
);
727 static void write_bulk_callback(struct urb
*urb
, struct pt_regs
*regs
)
729 pegasus_t
*pegasus
= urb
->context
;
730 struct net_device
*net
= pegasus
->net
;
735 if (!netif_device_present(net
) || !netif_running(net
))
738 switch (urb
->status
) {
740 /* FIXME schedule_work() to clear the tx halt */
741 netif_stop_queue(net
);
742 if (netif_msg_tx_err(pegasus
))
743 printk(KERN_WARNING
"%s: no tx stall recovery\n",
749 if (netif_msg_ifdown(pegasus
))
750 pr_debug("%s: tx unlink, %d\n", net
->name
, urb
->status
);
753 if (netif_msg_tx_err(pegasus
))
754 pr_info("%s: TX status %d\n", net
->name
, urb
->status
);
760 net
->trans_start
= jiffies
;
761 netif_wake_queue(net
);
764 static void intr_callback(struct urb
*urb
, struct pt_regs
*regs
)
766 pegasus_t
*pegasus
= urb
->context
;
767 struct net_device
*net
;
774 switch (urb
->status
) {
777 case -ECONNRESET
: /* unlink */
782 /* some Pegasus-I products report LOTS of data
783 * toggle errors... avoid log spamming
785 if (netif_msg_timer(pegasus
))
786 pr_debug("%s: intr status %d\n", net
->name
,
790 if (urb
->actual_length
>= 6) {
791 u8
* d
= urb
->transfer_buffer
;
793 /* byte 0 == tx_status1, reg 2B */
794 if (d
[0] & (TX_UNDERRUN
|EXCESSIVE_COL
795 |LATE_COL
|JABBER_TIMEOUT
)) {
796 pegasus
->stats
.tx_errors
++;
797 if (d
[0] & TX_UNDERRUN
)
798 pegasus
->stats
.tx_fifo_errors
++;
799 if (d
[0] & (EXCESSIVE_COL
| JABBER_TIMEOUT
))
800 pegasus
->stats
.tx_aborted_errors
++;
802 pegasus
->stats
.tx_window_errors
++;
805 /* d[5].LINK_STATUS lies on some adapters.
806 * d[0].NO_CARRIER kicks in only with failed TX.
807 * ... so monitoring with MII may be safest.
809 if (d
[0] & NO_CARRIER
)
810 netif_carrier_off(net
);
812 netif_carrier_on(net
);
814 /* bytes 3-4 == rx_lostpkt, reg 2E/2F */
815 pegasus
->stats
.rx_missed_errors
+= ((d
[3] & 0x7f) << 8) | d
[4];
818 status
= usb_submit_urb(urb
, SLAB_ATOMIC
);
819 if (status
&& netif_msg_timer(pegasus
))
820 printk(KERN_ERR
"%s: can't resubmit interrupt urb, %d\n",
824 static void pegasus_tx_timeout(struct net_device
*net
)
826 pegasus_t
*pegasus
= netdev_priv(net
);
827 if (netif_msg_timer(pegasus
))
828 printk(KERN_WARNING
"%s: tx timeout\n", net
->name
);
829 pegasus
->tx_urb
->transfer_flags
|= URB_ASYNC_UNLINK
;
830 usb_unlink_urb(pegasus
->tx_urb
);
831 pegasus
->stats
.tx_errors
++;
834 static int pegasus_start_xmit(struct sk_buff
*skb
, struct net_device
*net
)
836 pegasus_t
*pegasus
= netdev_priv(net
);
837 int count
= ((skb
->len
+ 2) & 0x3f) ? skb
->len
+ 2 : skb
->len
+ 3;
839 __u16 l16
= skb
->len
;
841 netif_stop_queue(net
);
843 ((__le16
*) pegasus
->tx_buff
)[0] = cpu_to_le16(l16
);
844 memcpy(pegasus
->tx_buff
+ 2, skb
->data
, skb
->len
);
845 usb_fill_bulk_urb(pegasus
->tx_urb
, pegasus
->usb
,
846 usb_sndbulkpipe(pegasus
->usb
, 2),
847 pegasus
->tx_buff
, count
,
848 write_bulk_callback
, pegasus
);
849 if ((res
= usb_submit_urb(pegasus
->tx_urb
, GFP_ATOMIC
))) {
850 if (netif_msg_tx_err(pegasus
))
851 printk(KERN_WARNING
"%s: fail tx, %d\n",
854 case -EPIPE
: /* stall, or disconnect from TT */
855 /* cleanup should already have been scheduled */
857 case -ENODEV
: /* disconnect() upcoming */
860 pegasus
->stats
.tx_errors
++;
861 netif_start_queue(net
);
864 pegasus
->stats
.tx_packets
++;
865 pegasus
->stats
.tx_bytes
+= skb
->len
;
866 net
->trans_start
= jiffies
;
873 static struct net_device_stats
*pegasus_netdev_stats(struct net_device
*dev
)
875 return &((pegasus_t
*) netdev_priv(dev
))->stats
;
878 static inline void disable_net_traffic(pegasus_t
* pegasus
)
883 ret
= set_registers(pegasus
, EthCtrl0
, 2, &tmp
);
886 static inline void get_interrupt_interval(pegasus_t
* pegasus
)
890 read_eprom_word(pegasus
, 4, (__u16
*) data
);
891 if (data
[1] < 0x80) {
892 if (netif_msg_timer(pegasus
))
893 dev_info(&pegasus
->intf
->dev
,
894 "intr interval changed from %ums to %ums\n",
897 #ifdef PEGASUS_WRITE_EEPROM
898 write_eprom_word(pegasus
, 4, *(__u16
*) data
);
901 pegasus
->intr_interval
= data
[1];
904 static void set_carrier(struct net_device
*net
)
906 pegasus_t
*pegasus
= netdev_priv(net
);
909 if (read_mii_word(pegasus
, pegasus
->phy
, MII_BMSR
, &tmp
))
911 if (tmp
& BMSR_LSTATUS
)
912 netif_carrier_on(net
);
914 netif_carrier_off(net
);
917 static void free_all_urbs(pegasus_t
* pegasus
)
919 usb_free_urb(pegasus
->intr_urb
);
920 usb_free_urb(pegasus
->tx_urb
);
921 usb_free_urb(pegasus
->rx_urb
);
922 usb_free_urb(pegasus
->ctrl_urb
);
925 static void unlink_all_urbs(pegasus_t
* pegasus
)
927 usb_kill_urb(pegasus
->intr_urb
);
928 usb_kill_urb(pegasus
->tx_urb
);
929 usb_kill_urb(pegasus
->rx_urb
);
930 usb_kill_urb(pegasus
->ctrl_urb
);
933 static int alloc_urbs(pegasus_t
* pegasus
)
935 pegasus
->ctrl_urb
= usb_alloc_urb(0, GFP_KERNEL
);
936 if (!pegasus
->ctrl_urb
) {
939 pegasus
->rx_urb
= usb_alloc_urb(0, GFP_KERNEL
);
940 if (!pegasus
->rx_urb
) {
941 usb_free_urb(pegasus
->ctrl_urb
);
944 pegasus
->tx_urb
= usb_alloc_urb(0, GFP_KERNEL
);
945 if (!pegasus
->tx_urb
) {
946 usb_free_urb(pegasus
->rx_urb
);
947 usb_free_urb(pegasus
->ctrl_urb
);
950 pegasus
->intr_urb
= usb_alloc_urb(0, GFP_KERNEL
);
951 if (!pegasus
->intr_urb
) {
952 usb_free_urb(pegasus
->tx_urb
);
953 usb_free_urb(pegasus
->rx_urb
);
954 usb_free_urb(pegasus
->ctrl_urb
);
961 static int pegasus_open(struct net_device
*net
)
963 pegasus_t
*pegasus
= netdev_priv(net
);
966 if (pegasus
->rx_skb
== NULL
)
967 pegasus
->rx_skb
= pull_skb(pegasus
);
969 ** Note: no point to free the pool. it is empty :-)
971 if (!pegasus
->rx_skb
)
974 res
= set_registers(pegasus
, EthID
, 6, net
->dev_addr
);
976 usb_fill_bulk_urb(pegasus
->rx_urb
, pegasus
->usb
,
977 usb_rcvbulkpipe(pegasus
->usb
, 1),
978 pegasus
->rx_skb
->data
, PEGASUS_MTU
+ 8,
979 read_bulk_callback
, pegasus
);
980 if ((res
= usb_submit_urb(pegasus
->rx_urb
, GFP_KERNEL
))) {
981 if (netif_msg_ifup(pegasus
))
982 pr_debug("%s: failed rx_urb, %d", net
->name
, res
);
986 usb_fill_int_urb(pegasus
->intr_urb
, pegasus
->usb
,
987 usb_rcvintpipe(pegasus
->usb
, 3),
988 pegasus
->intr_buff
, sizeof (pegasus
->intr_buff
),
989 intr_callback
, pegasus
, pegasus
->intr_interval
);
990 if ((res
= usb_submit_urb(pegasus
->intr_urb
, GFP_KERNEL
))) {
991 if (netif_msg_ifup(pegasus
))
992 pr_debug("%s: failed intr_urb, %d\n", net
->name
, res
);
993 usb_kill_urb(pegasus
->rx_urb
);
996 if ((res
= enable_net_traffic(net
, pegasus
->usb
))) {
997 if (netif_msg_ifup(pegasus
))
998 pr_debug("%s: can't enable_net_traffic() - %d\n",
1001 usb_kill_urb(pegasus
->rx_urb
);
1002 usb_kill_urb(pegasus
->intr_urb
);
1003 free_skb_pool(pegasus
);
1007 netif_start_queue(net
);
1008 if (netif_msg_ifup(pegasus
))
1009 pr_debug("%s: open\n", net
->name
);
1015 static int pegasus_close(struct net_device
*net
)
1017 pegasus_t
*pegasus
= netdev_priv(net
);
1019 netif_stop_queue(net
);
1020 if (!(pegasus
->flags
& PEGASUS_UNPLUG
))
1021 disable_net_traffic(pegasus
);
1022 tasklet_kill(&pegasus
->rx_tl
);
1023 unlink_all_urbs(pegasus
);
1028 static void pegasus_get_drvinfo(struct net_device
*dev
,
1029 struct ethtool_drvinfo
*info
)
1031 pegasus_t
*pegasus
= netdev_priv(dev
);
1032 strncpy(info
->driver
, driver_name
, sizeof (info
->driver
) - 1);
1033 strncpy(info
->version
, DRIVER_VERSION
, sizeof (info
->version
) - 1);
1034 usb_make_path(pegasus
->usb
, info
->bus_info
, sizeof (info
->bus_info
));
1037 /* also handles three patterns of some kind in hardware */
1038 #define WOL_SUPPORTED (WAKE_MAGIC|WAKE_PHY)
1041 pegasus_get_wol(struct net_device
*dev
, struct ethtool_wolinfo
*wol
)
1043 pegasus_t
*pegasus
= netdev_priv(dev
);
1045 wol
->supported
= WAKE_MAGIC
| WAKE_PHY
;
1046 wol
->wolopts
= pegasus
->wolopts
;
1050 pegasus_set_wol(struct net_device
*dev
, struct ethtool_wolinfo
*wol
)
1052 pegasus_t
*pegasus
= netdev_priv(dev
);
1055 if (wol
->wolopts
& ~WOL_SUPPORTED
)
1058 if (wol
->wolopts
& WAKE_MAGIC
)
1060 if (wol
->wolopts
& WAKE_PHY
)
1062 /* FIXME this 0x10 bit still needs to get set in the chip... */
1064 pegasus
->eth_regs
[0] |= 0x10;
1066 pegasus
->eth_regs
[0] &= ~0x10;
1067 pegasus
->wolopts
= wol
->wolopts
;
1068 return set_register(pegasus
, WakeupControl
, reg78
);
1071 static inline void pegasus_reset_wol(struct net_device
*dev
)
1073 struct ethtool_wolinfo wol
;
1075 memset(&wol
, 0, sizeof wol
);
1076 (void) pegasus_set_wol(dev
, &wol
);
1080 pegasus_get_settings(struct net_device
*dev
, struct ethtool_cmd
*ecmd
)
1087 pegasus
= netdev_priv(dev
);
1088 mii_ethtool_gset(&pegasus
->mii
, ecmd
);
1094 pegasus_set_settings(struct net_device
*dev
, struct ethtool_cmd
*ecmd
)
1096 pegasus_t
*pegasus
= netdev_priv(dev
);
1097 return mii_ethtool_sset(&pegasus
->mii
, ecmd
);
1100 static int pegasus_nway_reset(struct net_device
*dev
)
1102 pegasus_t
*pegasus
= netdev_priv(dev
);
1103 return mii_nway_restart(&pegasus
->mii
);
1106 static u32
pegasus_get_link(struct net_device
*dev
)
1108 pegasus_t
*pegasus
= netdev_priv(dev
);
1109 return mii_link_ok(&pegasus
->mii
);
1112 static u32
pegasus_get_msglevel(struct net_device
*dev
)
1114 pegasus_t
*pegasus
= netdev_priv(dev
);
1115 return pegasus
->msg_enable
;
1118 static void pegasus_set_msglevel(struct net_device
*dev
, u32 v
)
1120 pegasus_t
*pegasus
= netdev_priv(dev
);
1121 pegasus
->msg_enable
= v
;
1124 static struct ethtool_ops ops
= {
1125 .get_drvinfo
= pegasus_get_drvinfo
,
1126 .get_settings
= pegasus_get_settings
,
1127 .set_settings
= pegasus_set_settings
,
1128 .nway_reset
= pegasus_nway_reset
,
1129 .get_link
= pegasus_get_link
,
1130 .get_msglevel
= pegasus_get_msglevel
,
1131 .set_msglevel
= pegasus_set_msglevel
,
1132 .get_wol
= pegasus_get_wol
,
1133 .set_wol
= pegasus_set_wol
,
1136 static int pegasus_ioctl(struct net_device
*net
, struct ifreq
*rq
, int cmd
)
1138 __u16
*data
= (__u16
*) & rq
->ifr_ifru
;
1139 pegasus_t
*pegasus
= netdev_priv(net
);
1143 case SIOCDEVPRIVATE
:
1144 data
[0] = pegasus
->phy
;
1145 case SIOCDEVPRIVATE
+ 1:
1146 read_mii_word(pegasus
, data
[0], data
[1] & 0x1f, &data
[3]);
1149 case SIOCDEVPRIVATE
+ 2:
1150 if (!capable(CAP_NET_ADMIN
))
1152 write_mii_word(pegasus
, pegasus
->phy
, data
[1] & 0x1f, data
[2]);
1161 static void pegasus_set_multicast(struct net_device
*net
)
1163 pegasus_t
*pegasus
= netdev_priv(net
);
1165 if (net
->flags
& IFF_PROMISC
) {
1166 pegasus
->eth_regs
[EthCtrl2
] |= RX_PROMISCUOUS
;
1167 if (netif_msg_link(pegasus
))
1168 pr_info("%s: Promiscuous mode enabled.\n", net
->name
);
1169 } else if ((net
->mc_count
> multicast_filter_limit
) ||
1170 (net
->flags
& IFF_ALLMULTI
)) {
1171 pegasus
->eth_regs
[EthCtrl0
] |= RX_MULTICAST
;
1172 pegasus
->eth_regs
[EthCtrl2
] &= ~RX_PROMISCUOUS
;
1173 if (netif_msg_link(pegasus
))
1174 pr_info("%s: set allmulti\n", net
->name
);
1176 pegasus
->eth_regs
[EthCtrl0
] &= ~RX_MULTICAST
;
1177 pegasus
->eth_regs
[EthCtrl2
] &= ~RX_PROMISCUOUS
;
1180 pegasus
->flags
|= ETH_REGS_CHANGE
;
1181 ctrl_callback(pegasus
->ctrl_urb
, NULL
);
1184 static __u8
mii_phy_probe(pegasus_t
* pegasus
)
1189 for (i
= 0; i
< 32; i
++) {
1190 read_mii_word(pegasus
, i
, MII_BMSR
, &tmp
);
1191 if (tmp
== 0 || tmp
== 0xffff || (tmp
& BMSR_MEDIA
) == 0)
1200 static inline void setup_pegasus_II(pegasus_t
* pegasus
)
1205 ret
= set_register(pegasus
, Reg1d
, 0);
1206 ret
= set_register(pegasus
, Reg7b
, 1);
1208 if ((pegasus
->features
& HAS_HOME_PNA
) && mii_mode
)
1209 ret
= set_register(pegasus
, Reg7b
, 0);
1211 ret
= set_register(pegasus
, Reg7b
, 2);
1213 ret
= set_register(pegasus
, 0x83, data
);
1214 ret
= get_registers(pegasus
, 0x83, 1, &data
);
1217 pegasus
->chip
= 0x8513;
1222 ret
= set_register(pegasus
, 0x80, 0xc0);
1223 ret
= set_register(pegasus
, 0x83, 0xff);
1224 ret
= set_register(pegasus
, 0x84, 0x01);
1226 if (pegasus
->features
& HAS_HOME_PNA
&& mii_mode
)
1227 ret
= set_register(pegasus
, Reg81
, 6);
1229 ret
= set_register(pegasus
, Reg81
, 2);
1233 static struct workqueue_struct
*pegasus_workqueue
= NULL
;
1234 #define CARRIER_CHECK_DELAY (2 * HZ)
1236 static void check_carrier(void *data
)
1238 pegasus_t
*pegasus
= data
;
1239 set_carrier(pegasus
->net
);
1240 if (!(pegasus
->flags
& PEGASUS_UNPLUG
)) {
1241 queue_delayed_work(pegasus_workqueue
, &pegasus
->carrier_check
,
1242 CARRIER_CHECK_DELAY
);
1246 static int pegasus_probe(struct usb_interface
*intf
,
1247 const struct usb_device_id
*id
)
1249 struct usb_device
*dev
= interface_to_usbdev(intf
);
1250 struct net_device
*net
;
1252 int dev_index
= id
- pegasus_ids
;
1256 net
= alloc_etherdev(sizeof(struct pegasus
));
1258 dev_err(&intf
->dev
, "can't allocate %s\n", "device");
1262 pegasus
= netdev_priv(net
);
1263 memset(pegasus
, 0, sizeof (struct pegasus
));
1264 pegasus
->dev_index
= dev_index
;
1265 init_waitqueue_head(&pegasus
->ctrl_wait
);
1267 if (!alloc_urbs(pegasus
)) {
1268 dev_err(&intf
->dev
, "can't allocate %s\n", "urbs");
1272 tasklet_init(&pegasus
->rx_tl
, rx_fixup
, (unsigned long) pegasus
);
1274 INIT_WORK(&pegasus
->carrier_check
, check_carrier
, pegasus
);
1276 pegasus
->intf
= intf
;
1279 SET_MODULE_OWNER(net
);
1280 net
->open
= pegasus_open
;
1281 net
->stop
= pegasus_close
;
1282 net
->watchdog_timeo
= PEGASUS_TX_TIMEOUT
;
1283 net
->tx_timeout
= pegasus_tx_timeout
;
1284 net
->do_ioctl
= pegasus_ioctl
;
1285 net
->hard_start_xmit
= pegasus_start_xmit
;
1286 net
->set_multicast_list
= pegasus_set_multicast
;
1287 net
->get_stats
= pegasus_netdev_stats
;
1288 SET_ETHTOOL_OPS(net
, &ops
);
1289 pegasus
->mii
.dev
= net
;
1290 pegasus
->mii
.mdio_read
= mdio_read
;
1291 pegasus
->mii
.mdio_write
= mdio_write
;
1292 pegasus
->mii
.phy_id_mask
= 0x1f;
1293 pegasus
->mii
.reg_num_mask
= 0x1f;
1294 spin_lock_init(&pegasus
->rx_pool_lock
);
1295 pegasus
->msg_enable
= netif_msg_init (msg_level
, NETIF_MSG_DRV
1296 | NETIF_MSG_PROBE
| NETIF_MSG_LINK
);
1298 pegasus
->features
= usb_dev_id
[dev_index
].private;
1299 get_interrupt_interval(pegasus
);
1300 if (reset_mac(pegasus
)) {
1301 dev_err(&intf
->dev
, "can't reset MAC\n");
1305 set_ethernet_addr(pegasus
);
1306 fill_skb_pool(pegasus
);
1307 if (pegasus
->features
& PEGASUS_II
) {
1308 dev_info(&intf
->dev
, "setup Pegasus II specific registers\n");
1309 setup_pegasus_II(pegasus
);
1311 pegasus
->phy
= mii_phy_probe(pegasus
);
1312 if (pegasus
->phy
== 0xff) {
1313 dev_warn(&intf
->dev
, "can't locate MII phy, using default\n");
1316 pegasus
->mii
.phy_id
= pegasus
->phy
;
1317 usb_set_intfdata(intf
, pegasus
);
1318 SET_NETDEV_DEV(net
, &intf
->dev
);
1319 pegasus_reset_wol(net
);
1320 res
= register_netdev(net
);
1323 queue_delayed_work(pegasus_workqueue
, &pegasus
->carrier_check
,
1324 CARRIER_CHECK_DELAY
);
1326 dev_info(&intf
->dev
, "%s, %s, %02x:%02x:%02x:%02x:%02x:%02x\n",
1328 usb_dev_id
[dev_index
].name
,
1329 net
->dev_addr
[0], net
->dev_addr
[1],
1330 net
->dev_addr
[2], net
->dev_addr
[3],
1331 net
->dev_addr
[4], net
->dev_addr
[5]);
1335 usb_set_intfdata(intf
, NULL
);
1336 free_skb_pool(pegasus
);
1338 free_all_urbs(pegasus
);
1346 static void pegasus_disconnect(struct usb_interface
*intf
)
1348 struct pegasus
*pegasus
= usb_get_intfdata(intf
);
1350 usb_set_intfdata(intf
, NULL
);
1352 dev_dbg(&intf
->dev
, "unregistering non-bound device?\n");
1356 pegasus
->flags
|= PEGASUS_UNPLUG
;
1357 cancel_delayed_work(&pegasus
->carrier_check
);
1358 unregister_netdev(pegasus
->net
);
1359 usb_put_dev(interface_to_usbdev(intf
));
1360 free_all_urbs(pegasus
);
1361 free_skb_pool(pegasus
);
1362 if (pegasus
->rx_skb
)
1363 dev_kfree_skb(pegasus
->rx_skb
);
1364 free_netdev(pegasus
->net
);
1367 static int pegasus_suspend (struct usb_interface
*intf
, pm_message_t message
)
1369 struct pegasus
*pegasus
= usb_get_intfdata(intf
);
1371 netif_device_detach (pegasus
->net
);
1372 if (netif_running(pegasus
->net
)) {
1373 cancel_delayed_work(&pegasus
->carrier_check
);
1375 usb_kill_urb(pegasus
->rx_urb
);
1376 usb_kill_urb(pegasus
->intr_urb
);
1378 intf
->dev
.power
.power_state
= PMSG_SUSPEND
;
1382 static int pegasus_resume (struct usb_interface
*intf
)
1384 struct pegasus
*pegasus
= usb_get_intfdata(intf
);
1386 intf
->dev
.power
.power_state
= PMSG_ON
;
1387 netif_device_attach (pegasus
->net
);
1388 if (netif_running(pegasus
->net
)) {
1389 pegasus
->rx_urb
->status
= 0;
1390 pegasus
->rx_urb
->actual_length
= 0;
1391 read_bulk_callback(pegasus
->rx_urb
, NULL
);
1393 pegasus
->intr_urb
->status
= 0;
1394 pegasus
->intr_urb
->actual_length
= 0;
1395 intr_callback(pegasus
->intr_urb
, NULL
);
1397 queue_delayed_work(pegasus_workqueue
, &pegasus
->carrier_check
,
1398 CARRIER_CHECK_DELAY
);
1403 static struct usb_driver pegasus_driver
= {
1404 .name
= driver_name
,
1405 .probe
= pegasus_probe
,
1406 .disconnect
= pegasus_disconnect
,
1407 .id_table
= pegasus_ids
,
1408 .suspend
= pegasus_suspend
,
1409 .resume
= pegasus_resume
,
1412 static int __init
pegasus_init(void)
1414 pr_info("%s: %s, " DRIVER_DESC
"\n", driver_name
, DRIVER_VERSION
);
1415 pegasus_workqueue
= create_singlethread_workqueue("pegasus");
1416 if (!pegasus_workqueue
)
1418 return usb_register(&pegasus_driver
);
1421 static void __exit
pegasus_exit(void)
1423 destroy_workqueue(pegasus_workqueue
);
1424 usb_deregister(&pegasus_driver
);
1427 module_init(pegasus_init
);
1428 module_exit(pegasus_exit
);