1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2021 pureLiFi
6 #include <linux/kernel.h>
7 #include <linux/init.h>
8 #include <linux/device.h>
9 #include <linux/errno.h>
10 #include <linux/slab.h>
11 #include <linux/skbuff.h>
12 #include <linux/usb.h>
13 #include <linux/workqueue.h>
14 #include <linux/proc_fs.h>
16 #include <linux/string.h>
17 #include <linux/module.h>
18 #include <net/mac80211.h>
19 #include <asm/unaligned.h>
20 #include <linux/sysfs.h>
26 static const struct usb_device_id usb_ids[] = {
27 { USB_DEVICE(PURELIFI_X_VENDOR_ID_0, PURELIFI_X_PRODUCT_ID_0),
28 .driver_info = DEVICE_LIFI_X },
29 { USB_DEVICE(PURELIFI_XC_VENDOR_ID_0, PURELIFI_XC_PRODUCT_ID_0),
30 .driver_info = DEVICE_LIFI_XC },
31 { USB_DEVICE(PURELIFI_XL_VENDOR_ID_0, PURELIFI_XL_PRODUCT_ID_0),
32 .driver_info = DEVICE_LIFI_XL },
36 void plfxlc_send_packet_from_data_queue(struct plfxlc_usb *usb)
38 struct plfxlc_usb_tx *tx = &usb->tx;
39 struct sk_buff *skb = NULL;
43 spin_lock_irqsave(&tx->lock, flags);
44 last_served_sidx = usb->sidx;
46 usb->sidx = (usb->sidx + 1) % MAX_STA_NUM;
47 if (!(tx->station[usb->sidx].flag & STATION_CONNECTED_FLAG))
49 if (!(tx->station[usb->sidx].flag & STATION_FIFO_FULL_FLAG))
50 skb = skb_peek(&tx->station[usb->sidx].data_list);
51 } while ((usb->sidx != last_served_sidx) && (!skb));
54 skb = skb_dequeue(&tx->station[usb->sidx].data_list);
55 plfxlc_usb_wreq_async(usb, skb->data, skb->len, USB_REQ_DATA_TX,
56 plfxlc_tx_urb_complete, skb);
57 if (skb_queue_len(&tx->station[usb->sidx].data_list) <= 60)
58 ieee80211_wake_queues(plfxlc_usb_to_hw(usb));
60 spin_unlock_irqrestore(&tx->lock, flags);
63 static void handle_rx_packet(struct plfxlc_usb *usb, const u8 *buffer,
66 plfxlc_mac_rx(plfxlc_usb_to_hw(usb), buffer, length);
69 static void rx_urb_complete(struct urb *urb)
71 struct plfxlc_usb_tx *tx;
72 struct plfxlc_usb *usb;
80 pr_err("urb is NULL\n");
84 pr_err("urb ctx is NULL\n");
89 if (usb->initialized != 1) {
90 pr_err("usb is not initialized\n");
95 switch (urb->status) {
104 dev_dbg(plfxlc_urb_dev(urb), "urb %p error %d\n", urb, urb->status);
107 dev_dbg(plfxlc_urb_dev(urb), "urb %p error %d\n", urb, urb->status);
108 if (tx->submitted_urbs++ < PURELIFI_URB_RETRY_MAX) {
109 dev_dbg(plfxlc_urb_dev(urb), "urb %p resubmit %d", urb,
110 tx->submitted_urbs++);
113 dev_dbg(plfxlc_urb_dev(urb), "urb %p max resubmits reached", urb);
114 tx->submitted_urbs = 0;
119 buffer = urb->transfer_buffer;
120 length = le32_to_cpu(*(__le32 *)(buffer + sizeof(struct rx_status)))
123 if (urb->actual_length != (PLF_MSG_STATUS_OFFSET + 1)) {
124 if (usb->initialized && usb->link_up)
125 handle_rx_packet(usb, buffer, length);
129 status = buffer[PLF_MSG_STATUS_OFFSET];
132 case STATION_FIFO_ALMOST_FULL_NOT_MESSAGE:
133 dev_dbg(&usb->intf->dev,
134 "FIFO full not packet receipt\n");
135 tx->mac_fifo_full = 1;
136 for (sidx = 0; sidx < MAX_STA_NUM; sidx++)
137 tx->station[sidx].flag |= STATION_FIFO_FULL_FLAG;
139 case STATION_FIFO_ALMOST_FULL_MESSAGE:
140 dev_dbg(&usb->intf->dev, "FIFO full packet receipt\n");
142 for (sidx = 0; sidx < MAX_STA_NUM; sidx++)
143 tx->station[sidx].flag &= STATION_ACTIVE_FLAG;
145 plfxlc_send_packet_from_data_queue(usb);
147 case STATION_CONNECT_MESSAGE:
149 dev_dbg(&usb->intf->dev, "ST_CONNECT_MSG packet receipt\n");
151 case STATION_DISCONNECT_MESSAGE:
153 dev_dbg(&usb->intf->dev, "ST_DISCONN_MSG packet receipt\n");
156 dev_dbg(&usb->intf->dev, "Unknown packet receipt\n");
161 r = usb_submit_urb(urb, GFP_ATOMIC);
163 dev_dbg(plfxlc_urb_dev(urb), "urb %p resubmit fail (%d)\n", urb, r);
166 static struct urb *alloc_rx_urb(struct plfxlc_usb *usb)
168 struct usb_device *udev = plfxlc_usb_to_usbdev(usb);
172 urb = usb_alloc_urb(0, GFP_KERNEL);
176 buffer = usb_alloc_coherent(udev, USB_MAX_RX_SIZE, GFP_KERNEL,
183 usb_fill_bulk_urb(urb, udev, usb_rcvbulkpipe(udev, EP_DATA_IN),
184 buffer, USB_MAX_RX_SIZE,
185 rx_urb_complete, usb);
186 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
191 static void free_rx_urb(struct urb *urb)
195 usb_free_coherent(urb->dev, urb->transfer_buffer_length,
196 urb->transfer_buffer, urb->transfer_dma);
200 static int __lf_x_usb_enable_rx(struct plfxlc_usb *usb)
202 struct plfxlc_usb_rx *rx = &usb->rx;
207 urbs = kcalloc(RX_URBS_COUNT, sizeof(struct urb *), GFP_KERNEL);
211 for (i = 0; i < RX_URBS_COUNT; i++) {
212 urbs[i] = alloc_rx_urb(usb);
217 spin_lock_irq(&rx->lock);
219 dev_dbg(plfxlc_usb_dev(usb), "irq_disabled %d\n", irqs_disabled());
222 spin_unlock_irq(&rx->lock);
227 rx->urbs_count = RX_URBS_COUNT;
228 spin_unlock_irq(&rx->lock);
230 for (i = 0; i < RX_URBS_COUNT; i++) {
231 r = usb_submit_urb(urbs[i], GFP_KERNEL);
239 for (i = 0; i < RX_URBS_COUNT; i++)
240 usb_kill_urb(urbs[i]);
241 spin_lock_irq(&rx->lock);
244 spin_unlock_irq(&rx->lock);
247 for (i = 0; i < RX_URBS_COUNT; i++)
248 free_rx_urb(urbs[i]);
253 int plfxlc_usb_enable_rx(struct plfxlc_usb *usb)
255 struct plfxlc_usb_rx *rx = &usb->rx;
258 mutex_lock(&rx->setup_mutex);
259 r = __lf_x_usb_enable_rx(usb);
261 usb->rx_usb_enabled = 1;
263 mutex_unlock(&rx->setup_mutex);
268 static void __lf_x_usb_disable_rx(struct plfxlc_usb *usb)
270 struct plfxlc_usb_rx *rx = &usb->rx;
276 spin_lock_irqsave(&rx->lock, flags);
278 count = rx->urbs_count;
279 spin_unlock_irqrestore(&rx->lock, flags);
284 for (i = 0; i < count; i++) {
285 usb_kill_urb(urbs[i]);
286 free_rx_urb(urbs[i]);
293 void plfxlc_usb_disable_rx(struct plfxlc_usb *usb)
295 struct plfxlc_usb_rx *rx = &usb->rx;
297 mutex_lock(&rx->setup_mutex);
298 __lf_x_usb_disable_rx(usb);
299 usb->rx_usb_enabled = 0;
300 mutex_unlock(&rx->setup_mutex);
303 void plfxlc_usb_disable_tx(struct plfxlc_usb *usb)
305 struct plfxlc_usb_tx *tx = &usb->tx;
308 clear_bit(PLF_BIT_ENABLED, &tx->enabled);
310 /* kill all submitted tx-urbs */
311 usb_kill_anchored_urbs(&tx->submitted);
313 spin_lock_irqsave(&tx->lock, flags);
314 WARN_ON(!skb_queue_empty(&tx->submitted_skbs));
315 WARN_ON(tx->submitted_urbs != 0);
316 tx->submitted_urbs = 0;
317 spin_unlock_irqrestore(&tx->lock, flags);
319 /* The stopped state is ignored, relying on ieee80211_wake_queues()
320 * in a potentionally following plfxlc_usb_enable_tx().
324 void plfxlc_usb_enable_tx(struct plfxlc_usb *usb)
326 struct plfxlc_usb_tx *tx = &usb->tx;
329 spin_lock_irqsave(&tx->lock, flags);
330 set_bit(PLF_BIT_ENABLED, &tx->enabled);
331 tx->submitted_urbs = 0;
332 ieee80211_wake_queues(plfxlc_usb_to_hw(usb));
334 spin_unlock_irqrestore(&tx->lock, flags);
337 void plfxlc_tx_urb_complete(struct urb *urb)
339 struct ieee80211_tx_info *info;
340 struct plfxlc_usb *usb;
344 info = IEEE80211_SKB_CB(skb);
345 /* grab 'usb' pointer before handing off the skb (since
346 * it might be freed by plfxlc_mac_tx_to_dev or mac80211)
348 usb = &plfxlc_hw_mac(info->rate_driver_data[0])->chip.usb;
350 switch (urb->status) {
359 dev_dbg(plfxlc_urb_dev(urb), "urb %p error %d\n", urb, urb->status);
362 dev_dbg(plfxlc_urb_dev(urb), "urb %p error %d\n", urb, urb->status);
366 plfxlc_mac_tx_to_dev(skb, urb->status);
367 plfxlc_send_packet_from_data_queue(usb);
371 static inline void init_usb_rx(struct plfxlc_usb *usb)
373 struct plfxlc_usb_rx *rx = &usb->rx;
375 spin_lock_init(&rx->lock);
376 mutex_init(&rx->setup_mutex);
378 if (interface_to_usbdev(usb->intf)->speed == USB_SPEED_HIGH)
379 rx->usb_packet_size = 512;
381 rx->usb_packet_size = 64;
383 if (rx->fragment_length != 0)
384 dev_dbg(plfxlc_usb_dev(usb), "fragment_length error\n");
387 static inline void init_usb_tx(struct plfxlc_usb *usb)
389 struct plfxlc_usb_tx *tx = &usb->tx;
391 spin_lock_init(&tx->lock);
392 clear_bit(PLF_BIT_ENABLED, &tx->enabled);
394 skb_queue_head_init(&tx->submitted_skbs);
395 init_usb_anchor(&tx->submitted);
398 void plfxlc_usb_init(struct plfxlc_usb *usb, struct ieee80211_hw *hw,
399 struct usb_interface *intf)
401 memset(usb, 0, sizeof(*usb));
402 usb->intf = usb_get_intf(intf);
403 usb_set_intfdata(usb->intf, hw);
408 void plfxlc_usb_release(struct plfxlc_usb *usb)
410 plfxlc_op_stop(plfxlc_usb_to_hw(usb));
411 plfxlc_usb_disable_tx(usb);
412 plfxlc_usb_disable_rx(usb);
413 usb_set_intfdata(usb->intf, NULL);
414 usb_put_intf(usb->intf);
417 const char *plfxlc_speed(enum usb_device_speed speed)
431 int plfxlc_usb_init_hw(struct plfxlc_usb *usb)
435 r = usb_reset_configuration(plfxlc_usb_to_usbdev(usb));
437 dev_err(plfxlc_usb_dev(usb), "cfg reset failed (%d)\n", r);
443 static void get_usb_req(struct usb_device *udev, void *buffer,
444 u32 buffer_len, enum plf_usb_req_enum usb_req_id,
445 struct plf_usb_req *usb_req)
447 __be32 payload_len_nw = cpu_to_be32(buffer_len + FCS_LEN);
448 const u8 *buffer_src_p = buffer;
449 u8 *buffer_dst = usb_req->buf;
450 u32 temp_usb_len = 0;
452 usb_req->id = cpu_to_be32(usb_req_id);
453 usb_req->len = cpu_to_be32(0);
455 /* Copy buffer length into the transmitted buffer, as it is important
456 * for the Rx MAC to know its exact length.
458 if (usb_req->id == cpu_to_be32(USB_REQ_BEACON_WR)) {
459 memcpy(buffer_dst, &payload_len_nw, sizeof(payload_len_nw));
460 buffer_dst += sizeof(payload_len_nw);
461 temp_usb_len += sizeof(payload_len_nw);
464 memcpy(buffer_dst, buffer_src_p, buffer_len);
465 buffer_dst += buffer_len;
466 buffer_src_p += buffer_len;
467 temp_usb_len += buffer_len;
469 /* Set the FCS_LEN (4) bytes as 0 for CRC checking. */
470 memset(buffer_dst, 0, FCS_LEN);
471 buffer_dst += FCS_LEN;
472 temp_usb_len += FCS_LEN;
474 /* Round the packet to be transmitted to 4 bytes. */
475 if (temp_usb_len % PURELIFI_BYTE_NUM_ALIGNMENT) {
476 memset(buffer_dst, 0, PURELIFI_BYTE_NUM_ALIGNMENT -
478 PURELIFI_BYTE_NUM_ALIGNMENT));
479 buffer_dst += PURELIFI_BYTE_NUM_ALIGNMENT -
481 PURELIFI_BYTE_NUM_ALIGNMENT);
482 temp_usb_len += PURELIFI_BYTE_NUM_ALIGNMENT -
483 (temp_usb_len % PURELIFI_BYTE_NUM_ALIGNMENT);
486 usb_req->len = cpu_to_be32(temp_usb_len);
489 int plfxlc_usb_wreq_async(struct plfxlc_usb *usb, const u8 *buffer,
490 int buffer_len, enum plf_usb_req_enum usb_req_id,
491 usb_complete_t complete_fn,
494 struct usb_device *udev = interface_to_usbdev(usb->ez_usb);
495 struct urb *urb = usb_alloc_urb(0, GFP_ATOMIC);
498 usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, EP_DATA_OUT),
499 (void *)buffer, buffer_len, complete_fn, context);
501 r = usb_submit_urb(urb, GFP_ATOMIC);
503 dev_err(&udev->dev, "Async write submit failed (%d)\n", r);
508 int plfxlc_usb_wreq(struct usb_interface *ez_usb, void *buffer, int buffer_len,
509 enum plf_usb_req_enum usb_req_id)
511 struct usb_device *udev = interface_to_usbdev(ez_usb);
512 unsigned char *dma_buffer = NULL;
513 struct plf_usb_req usb_req;
514 int usb_bulk_msg_len;
518 get_usb_req(udev, buffer, buffer_len, usb_req_id, &usb_req);
519 usb_bulk_msg_len = sizeof(__le32) + sizeof(__le32) +
520 be32_to_cpu(usb_req.len);
522 dma_buffer = kmemdup(&usb_req, usb_bulk_msg_len, GFP_KERNEL);
529 r = usb_bulk_msg(udev,
530 usb_sndbulkpipe(udev, EP_DATA_OUT),
531 dma_buffer, usb_bulk_msg_len,
532 &actual_length, USB_BULK_MSG_TIMEOUT_MS);
537 dev_err(&udev->dev, "usb_bulk_msg failed (%d)\n", r);
543 static void slif_data_plane_sap_timer_callb(struct timer_list *t)
545 struct plfxlc_usb *usb = from_timer(usb, t, tx.tx_retry_timer);
547 plfxlc_send_packet_from_data_queue(usb);
548 timer_setup(&usb->tx.tx_retry_timer,
549 slif_data_plane_sap_timer_callb, 0);
550 mod_timer(&usb->tx.tx_retry_timer, jiffies + TX_RETRY_BACKOFF_JIFF);
553 static void sta_queue_cleanup_timer_callb(struct timer_list *t)
555 struct plfxlc_usb *usb = from_timer(usb, t, sta_queue_cleanup);
556 struct plfxlc_usb_tx *tx = &usb->tx;
559 for (sidx = 0; sidx < MAX_STA_NUM - 1; sidx++) {
560 if (!(tx->station[sidx].flag & STATION_CONNECTED_FLAG))
562 if (tx->station[sidx].flag & STATION_HEARTBEAT_FLAG) {
563 tx->station[sidx].flag ^= STATION_HEARTBEAT_FLAG;
565 memset(tx->station[sidx].mac, 0, ETH_ALEN);
566 tx->station[sidx].flag = 0;
569 timer_setup(&usb->sta_queue_cleanup,
570 sta_queue_cleanup_timer_callb, 0);
571 mod_timer(&usb->sta_queue_cleanup, jiffies + STA_QUEUE_CLEANUP_JIFF);
574 static int probe(struct usb_interface *intf,
575 const struct usb_device_id *id)
577 u8 serial_number[PURELIFI_SERIAL_LEN];
578 struct ieee80211_hw *hw = NULL;
579 struct plfxlc_usb_tx *tx;
580 struct plfxlc_chip *chip;
581 struct plfxlc_usb *usb;
582 u8 hw_address[ETH_ALEN];
586 hw = plfxlc_mac_alloc_hw(intf);
593 chip = &plfxlc_hw_mac(hw)->chip;
598 r = plfxlc_upload_mac_and_serial(intf, hw_address, serial_number);
600 dev_err(&intf->dev, "MAC and Serial upload failed (%d)\n", r);
604 chip->unit_type = STA;
605 dev_err(&intf->dev, "Unit type is station");
607 r = plfxlc_mac_preinit_hw(hw, hw_address);
609 dev_err(&intf->dev, "Init mac failed (%d)\n", r);
613 r = ieee80211_register_hw(hw);
615 dev_err(&intf->dev, "Register device failed (%d)\n", r);
619 if ((le16_to_cpu(interface_to_usbdev(intf)->descriptor.idVendor) ==
620 PURELIFI_XL_VENDOR_ID_0) &&
621 (le16_to_cpu(interface_to_usbdev(intf)->descriptor.idProduct) ==
622 PURELIFI_XL_PRODUCT_ID_0)) {
623 r = plfxlc_download_xl_firmware(intf);
625 r = plfxlc_download_fpga(intf);
628 dev_err(&intf->dev, "FPGA download failed (%d)\n", r);
632 tx->mac_fifo_full = 0;
633 spin_lock_init(&tx->lock);
635 msleep(PLF_MSLEEP_TIME);
636 r = plfxlc_usb_init_hw(usb);
638 dev_err(&intf->dev, "usb_init_hw failed (%d)\n", r);
642 msleep(PLF_MSLEEP_TIME);
643 r = plfxlc_chip_switch_radio(chip, PLFXLC_RADIO_ON);
645 dev_dbg(&intf->dev, "chip_switch_radio_on failed (%d)\n", r);
649 msleep(PLF_MSLEEP_TIME);
650 r = plfxlc_chip_set_rate(chip, 8);
652 dev_dbg(&intf->dev, "chip_set_rate failed (%d)\n", r);
656 msleep(PLF_MSLEEP_TIME);
657 r = plfxlc_usb_wreq(usb->ez_usb,
658 hw_address, ETH_ALEN, USB_REQ_MAC_WR);
660 dev_dbg(&intf->dev, "MAC_WR failure (%d)\n", r);
664 plfxlc_chip_enable_rxtx(chip);
666 /* Initialise the data plane Tx queue */
667 for (i = 0; i < MAX_STA_NUM; i++) {
668 skb_queue_head_init(&tx->station[i].data_list);
669 tx->station[i].flag = 0;
672 tx->station[STA_BROADCAST_INDEX].flag |= STATION_CONNECTED_FLAG;
673 for (i = 0; i < ETH_ALEN; i++)
674 tx->station[STA_BROADCAST_INDEX].mac[i] = 0xFF;
676 timer_setup(&tx->tx_retry_timer, slif_data_plane_sap_timer_callb, 0);
677 tx->tx_retry_timer.expires = jiffies + TX_RETRY_BACKOFF_JIFF;
678 add_timer(&tx->tx_retry_timer);
680 timer_setup(&usb->sta_queue_cleanup,
681 sta_queue_cleanup_timer_callb, 0);
682 usb->sta_queue_cleanup.expires = jiffies + STA_QUEUE_CLEANUP_JIFF;
683 add_timer(&usb->sta_queue_cleanup);
685 plfxlc_mac_init_hw(hw);
686 usb->initialized = true;
690 plfxlc_mac_release(plfxlc_hw_mac(hw));
691 ieee80211_unregister_hw(hw);
692 ieee80211_free_hw(hw);
694 dev_err(&intf->dev, "pureLifi:Device error");
698 static void disconnect(struct usb_interface *intf)
700 struct ieee80211_hw *hw = plfxlc_intf_to_hw(intf);
701 struct plfxlc_mac *mac;
702 struct plfxlc_usb *usb;
704 /* Either something really bad happened, or
705 * we're just dealing with a DEVICE_INSTALLER.
710 mac = plfxlc_hw_mac(hw);
711 usb = &mac->chip.usb;
713 del_timer_sync(&usb->tx.tx_retry_timer);
714 del_timer_sync(&usb->sta_queue_cleanup);
716 ieee80211_unregister_hw(hw);
718 plfxlc_chip_disable_rxtx(&mac->chip);
720 /* If the disconnect has been caused by a removal of the
721 * driver module, the reset allows reloading of the driver. If the
722 * reset will not be executed here, the upload of the firmware in the
723 * probe function caused by the reloading of the driver will fail.
725 usb_reset_device(interface_to_usbdev(intf));
727 plfxlc_mac_release(mac);
728 ieee80211_free_hw(hw);
731 static void plfxlc_usb_resume(struct plfxlc_usb *usb)
733 struct plfxlc_mac *mac = plfxlc_usb_to_mac(usb);
736 r = plfxlc_op_start(plfxlc_usb_to_hw(usb));
738 dev_warn(plfxlc_usb_dev(usb),
739 "Device resume failed (%d)\n", r);
741 if (usb->was_running)
742 set_bit(PURELIFI_DEVICE_RUNNING, &mac->flags);
744 usb_queue_reset_device(usb->intf);
748 if (mac->type != NL80211_IFTYPE_UNSPECIFIED) {
749 r = plfxlc_restore_settings(mac);
751 dev_dbg(plfxlc_usb_dev(usb),
752 "Restore failed (%d)\n", r);
758 static void plfxlc_usb_stop(struct plfxlc_usb *usb)
760 plfxlc_op_stop(plfxlc_usb_to_hw(usb));
761 plfxlc_usb_disable_tx(usb);
762 plfxlc_usb_disable_rx(usb);
764 usb->initialized = false;
767 static int pre_reset(struct usb_interface *intf)
769 struct ieee80211_hw *hw = usb_get_intfdata(intf);
770 struct plfxlc_mac *mac;
771 struct plfxlc_usb *usb;
773 if (!hw || intf->condition != USB_INTERFACE_BOUND)
776 mac = plfxlc_hw_mac(hw);
777 usb = &mac->chip.usb;
779 usb->was_running = test_bit(PURELIFI_DEVICE_RUNNING, &mac->flags);
781 plfxlc_usb_stop(usb);
786 static int post_reset(struct usb_interface *intf)
788 struct ieee80211_hw *hw = usb_get_intfdata(intf);
789 struct plfxlc_mac *mac;
790 struct plfxlc_usb *usb;
792 if (!hw || intf->condition != USB_INTERFACE_BOUND)
795 mac = plfxlc_hw_mac(hw);
796 usb = &mac->chip.usb;
798 if (usb->was_running)
799 plfxlc_usb_resume(usb);
806 static struct plfxlc_usb *get_plfxlc_usb(struct usb_interface *intf)
808 struct ieee80211_hw *hw = plfxlc_intf_to_hw(intf);
809 struct plfxlc_mac *mac;
811 /* Either something really bad happened, or
812 * we're just dealing with a DEVICE_INSTALLER.
817 mac = plfxlc_hw_mac(hw);
818 return &mac->chip.usb;
821 static int suspend(struct usb_interface *interface,
822 pm_message_t message)
824 struct plfxlc_usb *pl = get_plfxlc_usb(interface);
825 struct plfxlc_mac *mac = plfxlc_usb_to_mac(pl);
829 if (pl->initialized == 0)
831 pl->was_running = test_bit(PURELIFI_DEVICE_RUNNING, &mac->flags);
836 static int resume(struct usb_interface *interface)
838 struct plfxlc_usb *pl = get_plfxlc_usb(interface);
843 plfxlc_usb_resume(pl);
849 static struct usb_driver driver = {
850 .name = KBUILD_MODNAME,
853 .disconnect = disconnect,
854 .pre_reset = pre_reset,
855 .post_reset = post_reset,
860 .disable_hub_initiated_lpm = 1,
863 static int __init usb_init(void)
867 r = usb_register(&driver);
869 pr_err("%s usb_register() failed %d\n", driver.name, r);
873 pr_debug("Driver initialized :%s\n", driver.name);
877 static void __exit usb_exit(void)
879 usb_deregister(&driver);
880 pr_debug("%s %s\n", driver.name, __func__);
883 MODULE_LICENSE("GPL");
884 MODULE_DESCRIPTION("USB driver for pureLiFi devices");
885 MODULE_AUTHOR("pureLiFi");
886 MODULE_VERSION("1.0");
888 MODULE_DEVICE_TABLE(usb, usb_ids);
890 module_init(usb_init);
891 module_exit(usb_exit);