aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb/hso.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/usb/hso.c')
-rw-r--r--drivers/net/usb/hso.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 837135f0390a..e3580f42c899 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -899,15 +899,14 @@ static void packetizeRx(struct hso_net *odev, unsigned char *ip_pkt,
899 continue; 899 continue;
900 } 900 }
901 /* Allocate an sk_buff */ 901 /* Allocate an sk_buff */
902 odev->skb_rx_buf = dev_alloc_skb(frame_len); 902 odev->skb_rx_buf = netdev_alloc_skb(odev->net,
903 frame_len);
903 if (!odev->skb_rx_buf) { 904 if (!odev->skb_rx_buf) {
904 /* We got no receive buffer. */ 905 /* We got no receive buffer. */
905 D1("could not allocate memory"); 906 D1("could not allocate memory");
906 odev->rx_parse_state = WAIT_SYNC; 907 odev->rx_parse_state = WAIT_SYNC;
907 return; 908 return;
908 } 909 }
909 /* Here's where it came from */
910 odev->skb_rx_buf->dev = odev->net;
911 910
912 /* Copy what we got so far. make room for iphdr 911 /* Copy what we got so far. make room for iphdr
913 * after tail. */ 912 * after tail. */
@@ -2481,10 +2480,10 @@ static int add_net_device(struct hso_device *hso_dev)
2481 return 0; 2480 return 0;
2482} 2481}
2483 2482
2484static int hso_radio_toggle(void *data, enum rfkill_state state) 2483static int hso_rfkill_set_block(void *data, bool blocked)
2485{ 2484{
2486 struct hso_device *hso_dev = data; 2485 struct hso_device *hso_dev = data;
2487 int enabled = (state == RFKILL_STATE_UNBLOCKED); 2486 int enabled = !blocked;
2488 int rv; 2487 int rv;
2489 2488
2490 mutex_lock(&hso_dev->mutex); 2489 mutex_lock(&hso_dev->mutex);
@@ -2498,6 +2497,10 @@ static int hso_radio_toggle(void *data, enum rfkill_state state)
2498 return rv; 2497 return rv;
2499} 2498}
2500 2499
2500static const struct rfkill_ops hso_rfkill_ops = {
2501 .set_block = hso_rfkill_set_block,
2502};
2503
2501/* Creates and sets up everything for rfkill */ 2504/* Creates and sets up everything for rfkill */
2502static void hso_create_rfkill(struct hso_device *hso_dev, 2505static void hso_create_rfkill(struct hso_device *hso_dev,
2503 struct usb_interface *interface) 2506 struct usb_interface *interface)
@@ -2506,29 +2509,25 @@ static void hso_create_rfkill(struct hso_device *hso_dev,
2506 struct device *dev = &hso_net->net->dev; 2509 struct device *dev = &hso_net->net->dev;
2507 char *rfkn; 2510 char *rfkn;
2508 2511
2509 hso_net->rfkill = rfkill_allocate(&interface_to_usbdev(interface)->dev,
2510 RFKILL_TYPE_WWAN);
2511 if (!hso_net->rfkill) {
2512 dev_err(dev, "%s - Out of memory\n", __func__);
2513 return;
2514 }
2515 rfkn = kzalloc(20, GFP_KERNEL); 2512 rfkn = kzalloc(20, GFP_KERNEL);
2516 if (!rfkn) { 2513 if (!rfkn)
2517 rfkill_free(hso_net->rfkill);
2518 hso_net->rfkill = NULL;
2519 dev_err(dev, "%s - Out of memory\n", __func__); 2514 dev_err(dev, "%s - Out of memory\n", __func__);
2520 return; 2515
2521 }
2522 snprintf(rfkn, 20, "hso-%d", 2516 snprintf(rfkn, 20, "hso-%d",
2523 interface->altsetting->desc.bInterfaceNumber); 2517 interface->altsetting->desc.bInterfaceNumber);
2524 hso_net->rfkill->name = rfkn; 2518
2525 hso_net->rfkill->state = RFKILL_STATE_UNBLOCKED; 2519 hso_net->rfkill = rfkill_alloc(rfkn,
2526 hso_net->rfkill->data = hso_dev; 2520 &interface_to_usbdev(interface)->dev,
2527 hso_net->rfkill->toggle_radio = hso_radio_toggle; 2521 RFKILL_TYPE_WWAN,
2522 &hso_rfkill_ops, hso_dev);
2523 if (!hso_net->rfkill) {
2524 dev_err(dev, "%s - Out of memory\n", __func__);
2525 kfree(rfkn);
2526 return;
2527 }
2528 if (rfkill_register(hso_net->rfkill) < 0) { 2528 if (rfkill_register(hso_net->rfkill) < 0) {
2529 rfkill_destroy(hso_net->rfkill);
2529 kfree(rfkn); 2530 kfree(rfkn);
2530 hso_net->rfkill->name = NULL;
2531 rfkill_free(hso_net->rfkill);
2532 hso_net->rfkill = NULL; 2531 hso_net->rfkill = NULL;
2533 dev_err(dev, "%s - Failed to register rfkill\n", __func__); 2532 dev_err(dev, "%s - Failed to register rfkill\n", __func__);
2534 return; 2533 return;
@@ -3165,8 +3164,10 @@ static void hso_free_interface(struct usb_interface *interface)
3165 hso_stop_net_device(network_table[i]); 3164 hso_stop_net_device(network_table[i]);
3166 cancel_work_sync(&network_table[i]->async_put_intf); 3165 cancel_work_sync(&network_table[i]->async_put_intf);
3167 cancel_work_sync(&network_table[i]->async_get_intf); 3166 cancel_work_sync(&network_table[i]->async_get_intf);
3168 if (rfk) 3167 if (rfk) {
3169 rfkill_unregister(rfk); 3168 rfkill_unregister(rfk);
3169 rfkill_destroy(rfk);
3170 }
3170 hso_free_net_device(network_table[i]); 3171 hso_free_net_device(network_table[i]);
3171 } 3172 }
3172 } 3173 }