Remove the use of nested functions from the Thinkpad ACPI driver.

Signed-off-by: Behan Webster <beh...@converseincode.com>
Signed-off-by: Jan-Simon Möller <dl9pf at gmx.de>
---
 drivers/platform/x86/thinkpad_acpi.c |   86 ++++++++++++++++++----------------
 1 file changed, 45 insertions(+), 41 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c 
b/drivers/platform/x86/thinkpad_acpi.c
index f946ca7..b85fec0 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -2328,53 +2328,55 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, 
const u32 m)
        }
 }
 
-static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
-                                          struct tp_nvram_state *newn,
-                                          const u32 event_mask)
-{
-
 #define TPACPI_COMPARE_KEY(__scancode, __member) \
-       do { \
-               if ((event_mask & (1 << __scancode)) && \
-                   oldn->__member != newn->__member) \
-                       tpacpi_hotkey_send_key(__scancode); \
-       } while (0)
+do { \
+       if ((event_mask & (1 << __scancode)) && \
+           oldn->__member != newn->__member) \
+               tpacpi_hotkey_send_key(__scancode); \
+} while (0)
 
 #define TPACPI_MAY_SEND_KEY(__scancode) \
-       do { \
-               if (event_mask & (1 << __scancode)) \
-                       tpacpi_hotkey_send_key(__scancode); \
-       } while (0)
+do { \
+       if (event_mask & (1 << __scancode)) \
+               tpacpi_hotkey_send_key(__scancode); \
+} while (0)
 
-       void issue_volchange(const unsigned int oldvol,
-                            const unsigned int newvol)
-       {
-               unsigned int i = oldvol;
+static void issue_volchange(const unsigned int oldvol,
+                           const unsigned int newvol,
+                           const u32 event_mask)
+{
+       unsigned int i = oldvol;
 
-               while (i > newvol) {
-                       TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
-                       i--;
-               }
-               while (i < newvol) {
-                       TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
-                       i++;
-               }
+       while (i > newvol) {
+               TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
+               i--;
+       }
+       while (i < newvol) {
+               TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
+               i++;
        }
+}
 
-       void issue_brightnesschange(const unsigned int oldbrt,
-                                   const unsigned int newbrt)
-       {
-               unsigned int i = oldbrt;
+static void issue_brightnesschange(const unsigned int oldbrt,
+                                  const unsigned int newbrt,
+                                  const u32 event_mask)
+{
+       unsigned int i = oldbrt;
 
-               while (i > newbrt) {
-                       TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
-                       i--;
-               }
-               while (i < newbrt) {
-                       TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
-                       i++;
-               }
+       while (i > newbrt) {
+               TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
+               i--;
        }
+       while (i < newbrt) {
+               TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
+               i++;
+       }
+}
+
+static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
+                                          struct tp_nvram_state *newn,
+                                          const u32 event_mask)
+{
 
        TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
        TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
@@ -2409,7 +2411,8 @@ static void hotkey_compare_and_issue_event(struct 
tp_nvram_state *oldn,
                    oldn->volume_level != newn->volume_level) {
                        /* recently muted, or repeated mute keypress, or
                         * multiple presses ending in mute */
-                       issue_volchange(oldn->volume_level, newn->volume_level);
+                       issue_volchange(oldn->volume_level, newn->volume_level,
+                               event_mask);
                        TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
                }
        } else {
@@ -2419,7 +2422,8 @@ static void hotkey_compare_and_issue_event(struct 
tp_nvram_state *oldn,
                        TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
                }
                if (oldn->volume_level != newn->volume_level) {
-                       issue_volchange(oldn->volume_level, newn->volume_level);
+                       issue_volchange(oldn->volume_level, newn->volume_level,
+                               event_mask);
                } else if (oldn->volume_toggle != newn->volume_toggle) {
                        /* repeated vol up/down keypress at end of scale ? */
                        if (newn->volume_level == 0)
@@ -2432,7 +2436,7 @@ static void hotkey_compare_and_issue_event(struct 
tp_nvram_state *oldn,
        /* handle brightness */
        if (oldn->brightness_level != newn->brightness_level) {
                issue_brightnesschange(oldn->brightness_level,
-                                      newn->brightness_level);
+                                      newn->brightness_level, event_mask);
        } else if (oldn->brightness_toggle != newn->brightness_toggle) {
                /* repeated key presses that didn't change state */
                if (newn->brightness_level == 0)
-- 
1.7.10.4


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel

Reply via email to