aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorBehan Webster <behanw@converseincode.com>2014-02-12 15:58:46 -0500
committerMatthew Garrett <matthew.garrett@nebula.com>2014-04-06 12:58:15 -0400
commita4d44ba1266a04cdfda4b2c4ee496d684a47f567 (patch)
tree8bed762872da77b0ba74867fc53727bd7a37edb5 /drivers/platform
parent330947b84382479459e5296a0024c670367b0b57 (diff)
x86, acpi: LLVMLinux: Remove nested functions from Thinkpad ACPI
The only real change is passing in event_mask to the formerly nested functions. Otherwise it's just moving around function and macro code. This is the only place in the Linux kernel where nested functions are still in use. Nested functions aren't part of the C standards, and complicate the generated code. Although the Linux Kernel has never set out to be entirely C standard compliant, it is increasingly compliant to the standard which is supported by other compilers such as Clang. The LLVMLinux project is working on being able to compile the Linux kernel with Clang. The use of nested functions blocks this effort. Signed-off-by: Behan Webster <behanw@converseincode.com> Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de> CC: David Woodhouse <David.Woodhouse@intel.com> CC: Matthew Garrett <matthew.garrett@nebula.com> CC: ibm-acpi-devel@lists.sourceforge.net CC: platform-driver-x86@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c86
1 files changed, 45 insertions, 41 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 18c9862dd932..15e61c16736e 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -2321,53 +2321,55 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
2321 } 2321 }
2322} 2322}
2323 2323
2324static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
2325 struct tp_nvram_state *newn,
2326 const u32 event_mask)
2327{
2328
2329#define TPACPI_COMPARE_KEY(__scancode, __member) \ 2324#define TPACPI_COMPARE_KEY(__scancode, __member) \
2330 do { \ 2325do { \
2331 if ((event_mask & (1 << __scancode)) && \ 2326 if ((event_mask & (1 << __scancode)) && \
2332 oldn->__member != newn->__member) \ 2327 oldn->__member != newn->__member) \
2333 tpacpi_hotkey_send_key(__scancode); \ 2328 tpacpi_hotkey_send_key(__scancode); \
2334 } while (0) 2329} while (0)
2335 2330
2336#define TPACPI_MAY_SEND_KEY(__scancode) \ 2331#define TPACPI_MAY_SEND_KEY(__scancode) \
2337 do { \ 2332do { \
2338 if (event_mask & (1 << __scancode)) \ 2333 if (event_mask & (1 << __scancode)) \
2339 tpacpi_hotkey_send_key(__scancode); \ 2334 tpacpi_hotkey_send_key(__scancode); \
2340 } while (0) 2335} while (0)
2341 2336
2342 void issue_volchange(const unsigned int oldvol, 2337static void issue_volchange(const unsigned int oldvol,
2343 const unsigned int newvol) 2338 const unsigned int newvol,
2344 { 2339 const u32 event_mask)
2345 unsigned int i = oldvol; 2340{
2341 unsigned int i = oldvol;
2346 2342
2347 while (i > newvol) { 2343 while (i > newvol) {
2348 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN); 2344 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
2349 i--; 2345 i--;
2350 } 2346 }
2351 while (i < newvol) { 2347 while (i < newvol) {
2352 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP); 2348 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
2353 i++; 2349 i++;
2354 }
2355 } 2350 }
2351}
2356 2352
2357 void issue_brightnesschange(const unsigned int oldbrt, 2353static void issue_brightnesschange(const unsigned int oldbrt,
2358 const unsigned int newbrt) 2354 const unsigned int newbrt,
2359 { 2355 const u32 event_mask)
2360 unsigned int i = oldbrt; 2356{
2357 unsigned int i = oldbrt;
2361 2358
2362 while (i > newbrt) { 2359 while (i > newbrt) {
2363 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND); 2360 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
2364 i--; 2361 i--;
2365 }
2366 while (i < newbrt) {
2367 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
2368 i++;
2369 }
2370 } 2362 }
2363 while (i < newbrt) {
2364 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
2365 i++;
2366 }
2367}
2368
2369static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
2370 struct tp_nvram_state *newn,
2371 const u32 event_mask)
2372{
2371 2373
2372 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle); 2374 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
2373 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle); 2375 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
@@ -2402,7 +2404,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
2402 oldn->volume_level != newn->volume_level) { 2404 oldn->volume_level != newn->volume_level) {
2403 /* recently muted, or repeated mute keypress, or 2405 /* recently muted, or repeated mute keypress, or
2404 * multiple presses ending in mute */ 2406 * multiple presses ending in mute */
2405 issue_volchange(oldn->volume_level, newn->volume_level); 2407 issue_volchange(oldn->volume_level, newn->volume_level,
2408 event_mask);
2406 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE); 2409 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
2407 } 2410 }
2408 } else { 2411 } else {
@@ -2412,7 +2415,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
2412 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP); 2415 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
2413 } 2416 }
2414 if (oldn->volume_level != newn->volume_level) { 2417 if (oldn->volume_level != newn->volume_level) {
2415 issue_volchange(oldn->volume_level, newn->volume_level); 2418 issue_volchange(oldn->volume_level, newn->volume_level,
2419 event_mask);
2416 } else if (oldn->volume_toggle != newn->volume_toggle) { 2420 } else if (oldn->volume_toggle != newn->volume_toggle) {
2417 /* repeated vol up/down keypress at end of scale ? */ 2421 /* repeated vol up/down keypress at end of scale ? */
2418 if (newn->volume_level == 0) 2422 if (newn->volume_level == 0)
@@ -2425,7 +2429,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
2425 /* handle brightness */ 2429 /* handle brightness */
2426 if (oldn->brightness_level != newn->brightness_level) { 2430 if (oldn->brightness_level != newn->brightness_level) {
2427 issue_brightnesschange(oldn->brightness_level, 2431 issue_brightnesschange(oldn->brightness_level,
2428 newn->brightness_level); 2432 newn->brightness_level, event_mask);
2429 } else if (oldn->brightness_toggle != newn->brightness_toggle) { 2433 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
2430 /* repeated key presses that didn't change state */ 2434 /* repeated key presses that didn't change state */
2431 if (newn->brightness_level == 0) 2435 if (newn->brightness_level == 0)