| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * eeepc-laptop.c - Asus Eee PC extras |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Based on asus_acpi.c as patched for the Eee PC by Asus: |
|---|
| 5 | 6 | * ftp://ftp.asus.com/pub/ASUS/EeePC/701/ASUS_ACPI_071126.rar |
|---|
| 6 | 7 | * Based on eee.c from eeepc-linux |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 10 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 11 | | - * (at your option) any later version. |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | | - * GNU General Public License for more details. |
|---|
| 17 | 8 | */ |
|---|
| 18 | 9 | |
|---|
| 19 | 10 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 177 | 168 | struct rfkill *wwan3g_rfkill; |
|---|
| 178 | 169 | struct rfkill *wimax_rfkill; |
|---|
| 179 | 170 | |
|---|
| 180 | | - struct hotplug_slot *hotplug_slot; |
|---|
| 171 | + struct hotplug_slot hotplug_slot; |
|---|
| 181 | 172 | struct mutex hotplug_lock; |
|---|
| 182 | 173 | |
|---|
| 183 | 174 | struct led_classdev tpd_led; |
|---|
| .. | .. |
|---|
| 550 | 541 | |
|---|
| 551 | 542 | static void eeepc_led_exit(struct eeepc_laptop *eeepc) |
|---|
| 552 | 543 | { |
|---|
| 553 | | - if (!IS_ERR_OR_NULL(eeepc->tpd_led.dev)) |
|---|
| 554 | | - led_classdev_unregister(&eeepc->tpd_led); |
|---|
| 544 | + led_classdev_unregister(&eeepc->tpd_led); |
|---|
| 555 | 545 | if (eeepc->led_workqueue) |
|---|
| 556 | 546 | destroy_workqueue(eeepc->led_workqueue); |
|---|
| 557 | 547 | } |
|---|
| 558 | | - |
|---|
| 559 | 548 | |
|---|
| 560 | 549 | /* |
|---|
| 561 | 550 | * PCI hotplug (for wlan rfkill) |
|---|
| .. | .. |
|---|
| 582 | 571 | mutex_lock(&eeepc->hotplug_lock); |
|---|
| 583 | 572 | pci_lock_rescan_remove(); |
|---|
| 584 | 573 | |
|---|
| 585 | | - if (!eeepc->hotplug_slot) |
|---|
| 574 | + if (!eeepc->hotplug_slot.ops) |
|---|
| 586 | 575 | goto out_unlock; |
|---|
| 587 | 576 | |
|---|
| 588 | 577 | port = acpi_get_pci_dev(handle); |
|---|
| 589 | 578 | if (!port) { |
|---|
| 590 | | - pr_warning("Unable to find port\n"); |
|---|
| 579 | + pr_warn("Unable to find port\n"); |
|---|
| 591 | 580 | goto out_unlock; |
|---|
| 592 | 581 | } |
|---|
| 593 | 582 | |
|---|
| .. | .. |
|---|
| 715 | 704 | static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot, |
|---|
| 716 | 705 | u8 *value) |
|---|
| 717 | 706 | { |
|---|
| 718 | | - struct eeepc_laptop *eeepc = hotplug_slot->private; |
|---|
| 719 | | - int val = get_acpi(eeepc, CM_ASL_WLAN); |
|---|
| 707 | + struct eeepc_laptop *eeepc; |
|---|
| 708 | + int val; |
|---|
| 709 | + |
|---|
| 710 | + eeepc = container_of(hotplug_slot, struct eeepc_laptop, hotplug_slot); |
|---|
| 711 | + val = get_acpi(eeepc, CM_ASL_WLAN); |
|---|
| 720 | 712 | |
|---|
| 721 | 713 | if (val == 1 || val == 0) |
|---|
| 722 | 714 | *value = val; |
|---|
| .. | .. |
|---|
| 726 | 718 | return 0; |
|---|
| 727 | 719 | } |
|---|
| 728 | 720 | |
|---|
| 729 | | -static struct hotplug_slot_ops eeepc_hotplug_slot_ops = { |
|---|
| 730 | | - .owner = THIS_MODULE, |
|---|
| 721 | +static const struct hotplug_slot_ops eeepc_hotplug_slot_ops = { |
|---|
| 731 | 722 | .get_adapter_status = eeepc_get_adapter_status, |
|---|
| 732 | 723 | .get_power_status = eeepc_get_adapter_status, |
|---|
| 733 | 724 | }; |
|---|
| .. | .. |
|---|
| 742 | 733 | return -ENODEV; |
|---|
| 743 | 734 | } |
|---|
| 744 | 735 | |
|---|
| 745 | | - eeepc->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); |
|---|
| 746 | | - if (!eeepc->hotplug_slot) |
|---|
| 747 | | - goto error_slot; |
|---|
| 736 | + eeepc->hotplug_slot.ops = &eeepc_hotplug_slot_ops; |
|---|
| 748 | 737 | |
|---|
| 749 | | - eeepc->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info), |
|---|
| 750 | | - GFP_KERNEL); |
|---|
| 751 | | - if (!eeepc->hotplug_slot->info) |
|---|
| 752 | | - goto error_info; |
|---|
| 753 | | - |
|---|
| 754 | | - eeepc->hotplug_slot->private = eeepc; |
|---|
| 755 | | - eeepc->hotplug_slot->ops = &eeepc_hotplug_slot_ops; |
|---|
| 756 | | - eeepc_get_adapter_status(eeepc->hotplug_slot, |
|---|
| 757 | | - &eeepc->hotplug_slot->info->adapter_status); |
|---|
| 758 | | - |
|---|
| 759 | | - ret = pci_hp_register(eeepc->hotplug_slot, bus, 0, "eeepc-wifi"); |
|---|
| 738 | + ret = pci_hp_register(&eeepc->hotplug_slot, bus, 0, "eeepc-wifi"); |
|---|
| 760 | 739 | if (ret) { |
|---|
| 761 | 740 | pr_err("Unable to register hotplug slot - %d\n", ret); |
|---|
| 762 | 741 | goto error_register; |
|---|
| .. | .. |
|---|
| 765 | 744 | return 0; |
|---|
| 766 | 745 | |
|---|
| 767 | 746 | error_register: |
|---|
| 768 | | - kfree(eeepc->hotplug_slot->info); |
|---|
| 769 | | -error_info: |
|---|
| 770 | | - kfree(eeepc->hotplug_slot); |
|---|
| 771 | | - eeepc->hotplug_slot = NULL; |
|---|
| 772 | | -error_slot: |
|---|
| 747 | + eeepc->hotplug_slot.ops = NULL; |
|---|
| 773 | 748 | return ret; |
|---|
| 774 | 749 | } |
|---|
| 775 | 750 | |
|---|
| .. | .. |
|---|
| 830 | 805 | eeepc->wlan_rfkill = NULL; |
|---|
| 831 | 806 | } |
|---|
| 832 | 807 | |
|---|
| 833 | | - if (eeepc->hotplug_slot) { |
|---|
| 834 | | - pci_hp_deregister(eeepc->hotplug_slot); |
|---|
| 835 | | - kfree(eeepc->hotplug_slot->info); |
|---|
| 836 | | - kfree(eeepc->hotplug_slot); |
|---|
| 837 | | - } |
|---|
| 808 | + if (eeepc->hotplug_slot.ops) |
|---|
| 809 | + pci_hp_deregister(&eeepc->hotplug_slot); |
|---|
| 838 | 810 | |
|---|
| 839 | 811 | if (eeepc->bluetooth_rfkill) { |
|---|
| 840 | 812 | rfkill_unregister(eeepc->bluetooth_rfkill); |
|---|