lkml.org 
[lkml]   [2014]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 4/8] eeepc-laptop: pull out eeepc_destroy_rfkill
Date
In eeepc_rfkill_exit, we implement the same code four times. Pull out a
function that cleans up an rfkill object to get rid of the duplication.

Signed-off-by: Frans Klaver <fransklaver@gmail.com>
---
drivers/platform/x86/eeepc-laptop.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index e92ea41..73e8d39 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -823,35 +823,29 @@ static char EEEPC_RFKILL_NODE_1[] = "\\_SB.PCI0.P0P5";
static char EEEPC_RFKILL_NODE_2[] = "\\_SB.PCI0.P0P6";
static char EEEPC_RFKILL_NODE_3[] = "\\_SB.PCI0.P0P7";

+static inline void eeepc_destroy_rfkill(struct rfkill **rfkill)
+{
+ if (!*rfkill)
+ return;
+ rfkill_unregister(*rfkill);
+ rfkill_destroy(*rfkill);
+ *rfkill = NULL;
+}
+
static void eeepc_rfkill_exit(struct eeepc_laptop *eeepc)
{
eeepc_unregister_rfkill_notifier(eeepc, EEEPC_RFKILL_NODE_1);
eeepc_unregister_rfkill_notifier(eeepc, EEEPC_RFKILL_NODE_2);
eeepc_unregister_rfkill_notifier(eeepc, EEEPC_RFKILL_NODE_3);
- if (eeepc->wlan_rfkill) {
- rfkill_unregister(eeepc->wlan_rfkill);
- rfkill_destroy(eeepc->wlan_rfkill);
- eeepc->wlan_rfkill = NULL;
- }
+
+ eeepc_destroy_rfkill(&eeepc->wlan_rfkill);

if (eeepc->hotplug_slot)
pci_hp_deregister(eeepc->hotplug_slot);

- if (eeepc->bluetooth_rfkill) {
- rfkill_unregister(eeepc->bluetooth_rfkill);
- rfkill_destroy(eeepc->bluetooth_rfkill);
- eeepc->bluetooth_rfkill = NULL;
- }
- if (eeepc->wwan3g_rfkill) {
- rfkill_unregister(eeepc->wwan3g_rfkill);
- rfkill_destroy(eeepc->wwan3g_rfkill);
- eeepc->wwan3g_rfkill = NULL;
- }
- if (eeepc->wimax_rfkill) {
- rfkill_unregister(eeepc->wimax_rfkill);
- rfkill_destroy(eeepc->wimax_rfkill);
- eeepc->wimax_rfkill = NULL;
- }
+ eeepc_destroy_rfkill(&eeepc->bluetooth_rfkill);
+ eeepc_destroy_rfkill(&eeepc->wwan3g_rfkill);
+ eeepc_destroy_rfkill(&eeepc->wimax_rfkill);
}

static int eeepc_rfkill_init(struct eeepc_laptop *eeepc)
--
2.1.0


\
 
 \ /
  Last update: 2014-10-22 21:41    [W:0.148 / U:1.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site