diff options
Diffstat (limited to 'drivers/net/usb/hso.c')
-rw-r--r-- | drivers/net/usb/hso.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 837135f0390a..5ddd8c4f9019 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c | |||
@@ -2481,10 +2481,10 @@ static int add_net_device(struct hso_device *hso_dev) | |||
2481 | return 0; | 2481 | return 0; |
2482 | } | 2482 | } |
2483 | 2483 | ||
2484 | static int hso_radio_toggle(void *data, enum rfkill_state state) | 2484 | static int hso_rfkill_set_block(void *data, bool blocked) |
2485 | { | 2485 | { |
2486 | struct hso_device *hso_dev = data; | 2486 | struct hso_device *hso_dev = data; |
2487 | int enabled = (state == RFKILL_STATE_UNBLOCKED); | 2487 | int enabled = !blocked; |
2488 | int rv; | 2488 | int rv; |
2489 | 2489 | ||
2490 | mutex_lock(&hso_dev->mutex); | 2490 | mutex_lock(&hso_dev->mutex); |
@@ -2498,6 +2498,10 @@ static int hso_radio_toggle(void *data, enum rfkill_state state) | |||
2498 | return rv; | 2498 | return rv; |
2499 | } | 2499 | } |
2500 | 2500 | ||
2501 | static const struct rfkill_ops hso_rfkill_ops = { | ||
2502 | .set_block = hso_rfkill_set_block, | ||
2503 | }; | ||
2504 | |||
2501 | /* Creates and sets up everything for rfkill */ | 2505 | /* Creates and sets up everything for rfkill */ |
2502 | static void hso_create_rfkill(struct hso_device *hso_dev, | 2506 | static void hso_create_rfkill(struct hso_device *hso_dev, |
2503 | struct usb_interface *interface) | 2507 | struct usb_interface *interface) |
@@ -2506,29 +2510,25 @@ static void hso_create_rfkill(struct hso_device *hso_dev, | |||
2506 | struct device *dev = &hso_net->net->dev; | 2510 | struct device *dev = &hso_net->net->dev; |
2507 | char *rfkn; | 2511 | char *rfkn; |
2508 | 2512 | ||
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); | 2513 | rfkn = kzalloc(20, GFP_KERNEL); |
2516 | if (!rfkn) { | 2514 | if (!rfkn) |
2517 | rfkill_free(hso_net->rfkill); | ||
2518 | hso_net->rfkill = NULL; | ||
2519 | dev_err(dev, "%s - Out of memory\n", __func__); | 2515 | dev_err(dev, "%s - Out of memory\n", __func__); |
2520 | return; | 2516 | |
2521 | } | ||
2522 | snprintf(rfkn, 20, "hso-%d", | 2517 | snprintf(rfkn, 20, "hso-%d", |
2523 | interface->altsetting->desc.bInterfaceNumber); | 2518 | interface->altsetting->desc.bInterfaceNumber); |
2524 | hso_net->rfkill->name = rfkn; | 2519 | |
2525 | hso_net->rfkill->state = RFKILL_STATE_UNBLOCKED; | 2520 | hso_net->rfkill = rfkill_alloc(rfkn, |
2526 | hso_net->rfkill->data = hso_dev; | 2521 | &interface_to_usbdev(interface)->dev, |
2527 | hso_net->rfkill->toggle_radio = hso_radio_toggle; | 2522 | RFKILL_TYPE_WWAN, |
2523 | &hso_rfkill_ops, hso_dev); | ||
2524 | if (!hso_net->rfkill) { | ||
2525 | dev_err(dev, "%s - Out of memory\n", __func__); | ||
2526 | kfree(rfkn); | ||
2527 | return; | ||
2528 | } | ||
2528 | if (rfkill_register(hso_net->rfkill) < 0) { | 2529 | if (rfkill_register(hso_net->rfkill) < 0) { |
2530 | rfkill_destroy(hso_net->rfkill); | ||
2529 | kfree(rfkn); | 2531 | kfree(rfkn); |
2530 | hso_net->rfkill->name = NULL; | ||
2531 | rfkill_free(hso_net->rfkill); | ||
2532 | hso_net->rfkill = NULL; | 2532 | hso_net->rfkill = NULL; |
2533 | dev_err(dev, "%s - Failed to register rfkill\n", __func__); | 2533 | dev_err(dev, "%s - Failed to register rfkill\n", __func__); |
2534 | return; | 2534 | return; |
@@ -3165,8 +3165,10 @@ static void hso_free_interface(struct usb_interface *interface) | |||
3165 | hso_stop_net_device(network_table[i]); | 3165 | hso_stop_net_device(network_table[i]); |
3166 | cancel_work_sync(&network_table[i]->async_put_intf); | 3166 | cancel_work_sync(&network_table[i]->async_put_intf); |
3167 | cancel_work_sync(&network_table[i]->async_get_intf); | 3167 | cancel_work_sync(&network_table[i]->async_get_intf); |
3168 | if (rfk) | 3168 | if (rfk) { |
3169 | rfkill_unregister(rfk); | 3169 | rfkill_unregister(rfk); |
3170 | rfkill_destroy(rfk); | ||
3171 | } | ||
3170 | hso_free_net_device(network_table[i]); | 3172 | hso_free_net_device(network_table[i]); |
3171 | } | 3173 | } |
3172 | } | 3174 | } |