Skip to contentSkip to conversation

rt2x00: Put Hardware button in generic header

PATCH In review Ivo van Doorn 1 participant 1 message Apr 27, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 27/32 rt2x00: Put Hardware button in generic header

From: Ivo van Doorn <[email protected]>

Put the hardware button handling as much as possible in the new generic header for PCI.
The individial .c files should now only contain
the polling function to check the state of the hardware button.

drivers/net/wireless/d80211/rt2x00/rt2400pci.c +23 -60
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c
@@ -38,10 +38,6 @@
 #include <net/iw_handler.h>
 #include <net/d80211.h>
 
-#ifdef CONFIG_RT2400PCI_BUTTON
-#include <acpi/acpi_bus.h>
-#endif /* CONFIG_RT2400PCI_BUTTON */
-
 #include <asm/io.h>
 
 /*
@@ -364,6 +360,24 @@ rt2x00_eeprom_multiread(
 		rt2x00_eeprom_read(rt2x00pci, word + counter, data++);
 }
 
+#ifdef CONFIG_RT2400PCI_BUTTON
+/*
+ * Hardware button poll handler.
+ */
+static void
+rt2400pci_button_poll(unsigned long data)
+{
+	struct rt2x00_pci	*rt2x00pci = (struct rt2x00_pci*)data;
+	u32			reg;
+
+	rt2x00_register_read(rt2x00pci, GPIOCSR, &reg);
+	rt2x00pci_button_status(
+		rt2x00pci, rt2x00_get_field32(reg, GPIOCSR_BIT0));
+}
+#else /* CONFIG_RT2400PCI_BUTTON */
+static void rt2400pci_button_poll(struct rt2x00_pci *rt2x00pci){}
+#endif /* CONFIG_RT2400PCI_BUTTON */
+
 /*
  * Configuration handlers.
  */
@@ -2258,24 +2272,10 @@ rt2400pci_initialize(struct pci_dev *pci
 	|| rt2400pci_init_hw(rt2x00pci))
 		goto exit_destroy_workqueue;
 
-#ifdef CONFIG_RT2400PCI_BUTTON
-	strcpy(acpi_device_class(&rt2x00pci->acpi_dev), DRV_NAME "_button");
-	strcpy(acpi_device_bid(&rt2x00pci->acpi_dev), DRV_NAME);
-	strcpy(acpi_device_name(&rt2x00pci->acpi_dev), DRV_NAME);
-
-	init_timer(&rt2x00pci->poll_timer);
-
-	if (rt2x00_poll_delay
-	&& rt2x00pci->button_status != BUTTON_STATUS_UNAVAILABLE) {
-		rt2x00pci->button_status = rt2400pci_poll(rt2x00pci);
-		rt2x00pci->poll_delay = rt2x00_poll_delay * (HZ / 10);
-		rt2x00pci->poll_timer.function = rt2400pci_poll_expire;
-		rt2x00pci->poll_timer.data = (unsigned long)rt2x00pci;
-		rt2x00pci->poll_timer.expires =
-			jiffies + rt2x00pci->poll_delay;
-		add_timer(&rt2x00pci->poll_timer);
-	};
-#endif /* CONFIG_RT2400PCI_BUTTON */
+	/*
+	 * If required start hardware button polling.
+	 */
+	rt2x00pci_button_start(rt2x00pci, rt2400pci_button_poll);
 
 	return 0;
 
@@ -2294,13 +2294,10 @@ rt2400pci_uninitialize(struct net_device
 {
 	struct rt2x00_pci	*rt2x00pci = ieee80211_dev_hw_data(net_dev);
 
-#ifdef CONFIG_RT2400PCI_BUTTON
 	/*
 	 * Shutdown poll_timer for hardware button.
 	 */
-	rt2x00pci->button_status = BUTTON_STATUS_UNAVAILABLE;
-	del_timer_sync(&rt2x00pci->poll_timer);
-#endif /* CONFIG_RT2400PCI_BUTTON */
+	rt2x00pci_button_stop(rt2x00pci);
 
 	kfree(rt2x00pci->eeprom);
 
@@ -2506,40 +2503,6 @@ rt2400pci_resume(struct pci_dev *pci_dev
 }
 #endif /* CONFIG_PM */
 
-#ifdef CONFIG_RT2400PCI_BUTTON
-static int
-rt2400pci_poll(struct rt2x00_pci *rt2x00pci)
-{
-	u32			reg;
-
-	rt2x00_register_read(rt2x00pci, GPIOCSR, &reg);
-	return rt2x00_get_field32(reg, GPIOCSR_BIT0);
-}
-
-static void
-rt2400pci_poll_expire(unsigned long data)
-{
-	struct rt2x00_pci	*rt2x00pci = (struct rt2x00_pci*)data;
-	u16			status;
-
-	status = rt2400pci_poll(rt2x00pci);
-
-	if (rt2x00pci->button_status != BUTTON_STATUS_UNAVAILABLE)
-		return;
-
-	if (status != rt2x00pci->button_status) {
-		rt2x00pci->button_status = status;
-		acpi_bus_generate_event(&rt2x00pci->acpi_dev,
-			ACPI_TYPE_EVENT, rt2x00pci->button_status);
-	}
-
-	rt2x00pci->poll_timer.expires = jiffies + rt2x00pci->poll_delay;
-
-	if (rt2x00pci->button_status != BUTTON_STATUS_UNAVAILABLE)
-		add_timer(&rt2x00pci->poll_timer);
-}
-#endif /* CONFIG_RT2400PCI_BUTTON */
-
 /*
  * RT2400pci module information.
  */
drivers/net/wireless/d80211/rt2x00/rt2400pci.h +0 -17
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.h wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.h
@@ -863,21 +863,4 @@ static int rt2400pci_beacon_update(struc
 	struct sk_buff *skb, struct ieee80211_tx_control *control);
 static int rt2400pci_tx_last_beacon(struct net_device *net_dev);
 
-/*
- * HW button support structures and variables.
- * The delay between each poll is set by the module parameter.
- */
-#ifdef CONFIG_RT2400PCI_BUTTON
-/*
- * Module parameter.
- */
-static int rt2x00_poll_delay = 100;
-
-/*
- * Declaration of several required functions.
- */
-static int rt2400pci_poll(struct rt2x00_pci *rt2x00pci);
-static void rt2400pci_poll_expire(unsigned long data);
-#endif /* CONFIG_RT2400PCI_BUTTON */
-
 #endif /* RT2400PCI_H */
drivers/net/wireless/d80211/rt2x00/rt2500pci.c +23 -60

116 lines not on this page · raw message

drivers/net/wireless/d80211/rt2x00/rt2500pci.h +0 -17
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.h wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.h
@@ -1132,21 +1132,4 @@ static int rt2500pci_beacon_update(struc
 	struct sk_buff *skb, struct ieee80211_tx_control *control);
 static int rt2500pci_tx_last_beacon(struct net_device *net_dev);
 
-/*
- * HW button support structures and variables.
- * The delay between each poll is set by the module parameter.
- */
-#ifdef CONFIG_RT2500PCI_BUTTON
-/*
- * Module parameter.
- */
-static int rt2x00_poll_delay = 100;
-
-/*
- * Declaration of several required functions.
- */
-static int rt2500pci_poll(struct rt2x00_pci *rt2x00pci);
-static void rt2500pci_poll_expire(unsigned long data);
-#endif /* CONFIG_RT2500PCI_BUTTON */
-
 #endif /* RT2500PCI_H */
drivers/net/wireless/d80211/rt2x00/rt2x00pci.h +113 -22

151 lines not on this page · raw message