hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/platform/x86/eeepc-laptop.c
....@@ -1,19 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * eeepc-laptop.c - Asus Eee PC extras
34 *
45 * Based on asus_acpi.c as patched for the Eee PC by Asus:
56 * ftp://ftp.asus.com/pub/ASUS/EeePC/701/ASUS_ACPI_071126.rar
67 * 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.
178 */
189
1910 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -177,7 +168,7 @@
177168 struct rfkill *wwan3g_rfkill;
178169 struct rfkill *wimax_rfkill;
179170
180
- struct hotplug_slot *hotplug_slot;
171
+ struct hotplug_slot hotplug_slot;
181172 struct mutex hotplug_lock;
182173
183174 struct led_classdev tpd_led;
....@@ -550,12 +541,10 @@
550541
551542 static void eeepc_led_exit(struct eeepc_laptop *eeepc)
552543 {
553
- if (!IS_ERR_OR_NULL(eeepc->tpd_led.dev))
554
- led_classdev_unregister(&eeepc->tpd_led);
544
+ led_classdev_unregister(&eeepc->tpd_led);
555545 if (eeepc->led_workqueue)
556546 destroy_workqueue(eeepc->led_workqueue);
557547 }
558
-
559548
560549 /*
561550 * PCI hotplug (for wlan rfkill)
....@@ -582,12 +571,12 @@
582571 mutex_lock(&eeepc->hotplug_lock);
583572 pci_lock_rescan_remove();
584573
585
- if (!eeepc->hotplug_slot)
574
+ if (!eeepc->hotplug_slot.ops)
586575 goto out_unlock;
587576
588577 port = acpi_get_pci_dev(handle);
589578 if (!port) {
590
- pr_warning("Unable to find port\n");
579
+ pr_warn("Unable to find port\n");
591580 goto out_unlock;
592581 }
593582
....@@ -715,8 +704,11 @@
715704 static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot,
716705 u8 *value)
717706 {
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);
720712
721713 if (val == 1 || val == 0)
722714 *value = val;
....@@ -726,8 +718,7 @@
726718 return 0;
727719 }
728720
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 = {
731722 .get_adapter_status = eeepc_get_adapter_status,
732723 .get_power_status = eeepc_get_adapter_status,
733724 };
....@@ -742,21 +733,9 @@
742733 return -ENODEV;
743734 }
744735
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;
748737
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");
760739 if (ret) {
761740 pr_err("Unable to register hotplug slot - %d\n", ret);
762741 goto error_register;
....@@ -765,11 +744,7 @@
765744 return 0;
766745
767746 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;
773748 return ret;
774749 }
775750
....@@ -830,11 +805,8 @@
830805 eeepc->wlan_rfkill = NULL;
831806 }
832807
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);
838810
839811 if (eeepc->bluetooth_rfkill) {
840812 rfkill_unregister(eeepc->bluetooth_rfkill);