mirror of
https://github.com/torvalds/linux.git
synced 2024-12-13 14:43:03 +00:00
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>
This commit is contained in:
parent
330947b843
commit
a4d44ba126
@ -2321,54 +2321,56 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
|
||||
}
|
||||
}
|
||||
|
||||
#define TPACPI_COMPARE_KEY(__scancode, __member) \
|
||||
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)
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
#define TPACPI_MAY_SEND_KEY(__scancode) \
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
while (i > newbrt) {
|
||||
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
|
||||
i--;
|
||||
}
|
||||
while (i < newbrt) {
|
||||
TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
|
||||
TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
|
||||
TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
|
||||
@ -2402,7 +2404,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 {
|
||||
@ -2412,7 +2415,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)
|
||||
@ -2425,7 +2429,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)
|
||||
|
Loading…
Reference in New Issue
Block a user