From patchwork Wed Feb 12 20:58:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan-Simon_M=C3=B6ller?= X-Patchwork-Id: 24562 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1FF3E20143 for ; Wed, 12 Feb 2014 20:59:25 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id wo20sf37285973obc.3 for ; Wed, 12 Feb 2014 12:59:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=6SrKtMTyDPdiyw5VxEi4aiSSJCDGpkZeK54tyvEnFBw=; b=DCOYTklI6R/0GcN59U0LW6Si2wJ/s3E5XAJrAcFVuvEimQVI3FlSqHghnb7crYclAj CANTXpkK1maXTR+Gi8jFRS69xt+0bsaOsqUwAnGIU4f+F+yMCHgybC3mi+umvOSr0L/+ WIxT1vjMXFvC6rJrG7FjKqwgKqwVSAa0c1d85OV0z9nzolCCAKm3e6JrLEvnRskWuluz du40b4BHc90uCJ85Nw7CKFCwFQOg5LgBZJ7iwWzejQBlqvN8UTtNOwruvzsy2R194Vin iJhzXTYFl1gMfacCVzYK907sOjaSL41UBzTdiCn5LR5dDubqf+uquypy+44yvGQ3gXzc qW9w== X-Gm-Message-State: ALoCoQkDBnn6Cwbz6fdHS1Q/knTdcJ/FLikCbV5zIJkyIq10dFuU6oF8WXjnIzsGrNQ7vkbvmLc6 X-Received: by 10.182.60.37 with SMTP id e5mr2527985obr.30.1392238764087; Wed, 12 Feb 2014 12:59:24 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.113 with SMTP id p104ls3146891qga.41.gmail; Wed, 12 Feb 2014 12:59:23 -0800 (PST) X-Received: by 10.58.69.111 with SMTP id d15mr34123405veu.3.1392238763802; Wed, 12 Feb 2014 12:59:23 -0800 (PST) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by mx.google.com with ESMTPS id w14si7783346vco.3.2014.02.12.12.59.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Feb 2014 12:59:23 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.47; Received: by mail-vb0-f47.google.com with SMTP id p6so7494084vbe.34 for ; Wed, 12 Feb 2014 12:59:23 -0800 (PST) X-Received: by 10.52.233.137 with SMTP id tw9mr11293vdc.84.1392238763599; Wed, 12 Feb 2014 12:59:23 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp30095vcz; Wed, 12 Feb 2014 12:59:23 -0800 (PST) X-Received: by 10.68.240.5 with SMTP id vw5mr53506303pbc.34.1392238762739; Wed, 12 Feb 2014 12:59:22 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si23819079pav.190.2014.02.12.12.59.22; Wed, 12 Feb 2014 12:59:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754583AbaBLU7O (ORCPT + 27 others); Wed, 12 Feb 2014 15:59:14 -0500 Received: from mout.gmx.net ([212.227.15.18]:55944 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754342AbaBLU7L (ORCPT ); Wed, 12 Feb 2014 15:59:11 -0500 Received: from aragorn.auenland.lan ([95.90.92.166]) by mail.gmx.com (mrgmx101) with ESMTPSA (Nemesis) id 0McR00-1Vw1WP3mEq-00HhqK for ; Wed, 12 Feb 2014 21:59:10 +0100 From: dl9pf@gmx.de To: dl9pf@gmx.de Cc: Behan Webster , David Woodhouse , Matthew Garrett , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] x86, acpi: LLVMLinux: Remove nested functions from Thinkpad ACPI Date: Wed, 12 Feb 2014 21:58:46 +0100 Message-Id: <1392238726-18787-1-git-send-email-dl9pf@gmx.de> X-Mailer: git-send-email 1.8.4.5 MIME-Version: 1.0 X-Provags-ID: V03:K0:4JMYTbtj0VxfdrlrpwMvhfM8iCgNicyJ7D194lDxQdwyC4eMSX/ 9qwfMC+CKnizNQGrE+c4jTKvO7Vfq6hivRkiHWOX2ZmGfL+VSsLy3EyuzLU5V312XsdHcjN LoPqvb0WXV021bVyKxhLN17x0NB9Pn0jYUZ00d6HMZHEPgfTybDwV0Mwd44hOkc9ItKu7lQ 3NeY2SxvKK0We+prv+CNQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dl9pf@gmx.de X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Behan Webster 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 Signed-off-by: Jan-Simon Möller CC: David Woodhouse CC: Matthew Garrett CC: ibm-acpi-devel@lists.sourceforge.net CC: platform-driver-x86@vger.kernel.org CC: linux-kernel@vger.kernel.org --- 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 defb6af..e6e068e 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) } } -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); @@ -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)