Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp476085imm; Wed, 13 Jun 2018 03:39:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIlg6L/tuefVGrGVvC5mN+PlSW+JchgTr2pfo0bgQw2oCugfok0Xgusn1xfZ5+QvwgF0QFM X-Received: by 2002:a17:902:3081:: with SMTP id v1-v6mr4727314plb.266.1528886351055; Wed, 13 Jun 2018 03:39:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528886351; cv=none; d=google.com; s=arc-20160816; b=ukPW9J87E0YHJLQRDrf/ey4+oxBORDB/oHYt4kP1AISdA98w4q0pAB9nFWmG0j/msT osq4uqvxir2D7JF/3k5xunFOEZOEegF58OnOytcWxDOT0ksV3mecE4dL9bKPTo0az+9U VraQlFv7i6jvr4RfZywuEMHbPGNkfb7hTu0IuHeQ5KjL8JyEqst6p4AEaI4Le4DRztyL Mehk2XqQQg778YubyZXiAe5HOdXaAmq+AmEolIDpXTYLyj77yB2SZaO7+652i6LZvtDQ LBozSr2wrxKzDtcuBuXPZ7Q796B3m2lrkR8Ca16P5Y6EYzyrnEEQO/QZ+sok5GHk0pSs 3rzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:from:references:in-reply-to :message-id:cc:to:arc-authentication-results; bh=rmfTL5tFm+FYrxF2wYmzBt2LgEIoZy54/1vBtEYGeBw=; b=oXO6ZQoLBaKFxTmnEGGM4Rz6OfIV1ZPG9C0+bv4cUIr3CJEFefIDRIVIzG8YMN7/Rv GI/Ua890b8eF9+AE8Erf2MTx4GA3vaFomLNu2OpBy9nByh6tV/LgwgH7W4A660sOZMTk NI5jXjGeAZNyB7DjVE547i3ZD99GR2lrP1p1lW5ShkH/z0mMcZ4BeiZlgXx1+eZvP3yD w3l52++fqROvsoFA2F3V/sGfcJQH8XhLTKNwCMuBhNAm/ZfDGBE0AvEbU1tuP2QpQ+Wj DESu371Kl4AhiSvX2K0wBsCwew4V20YB1F4UNcrDNbPN8Uk52VD6Eq7JS722WfMBgDkl xtXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1-v6si2452697plt.276.2018.06.13.03.38.56; Wed, 13 Jun 2018 03:39:11 -0700 (PDT) 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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935349AbeFMKiT (ORCPT + 99 others); Wed, 13 Jun 2018 06:38:19 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:48016 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935271AbeFMKiG (ORCPT ); Wed, 13 Jun 2018 06:38:06 -0400 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 9B2C2285D6; Wed, 13 Jun 2018 06:38:02 -0400 (EDT) To: Benjamin Herrenschmidt Cc: Michael Schmitz , , , Message-Id: <69d26b5276c349749737d47860b9257daa79cbeb.1528885172.git.fthain@telegraphics.com.au> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 11/12] macintosh/via-pmu: Clean up interrupt statistics Date: Wed, 13 Jun 2018 06:38:02 -0400 (EDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace an open-coded ffs() with the function call. Simplify an if-else cascade using a switch statement. Correct a typo and an indentation issue. Tested-by: Stan Johnson Signed-off-by: Finn Thain Reviewed-by: Geert Uytterhoeven --- drivers/macintosh/via-pmu.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 38d7dd0bdb28..730c10f7fbb7 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c @@ -1392,7 +1392,8 @@ pmu_resume(void) static void pmu_handle_data(unsigned char *data, int len) { - unsigned char ints, pirq; + unsigned char ints; + int idx; int i = 0; asleep = 0; @@ -1414,25 +1415,24 @@ pmu_handle_data(unsigned char *data, int len) ints &= ~(PMU_INT_ADB_AUTO | PMU_INT_AUTO_SRQ_POLL); next: - if (ints == 0) { if (i > pmu_irq_stats[10]) pmu_irq_stats[10] = i; return; } - - for (pirq = 0; pirq < 8; pirq++) - if (ints & (1 << pirq)) - break; - pmu_irq_stats[pirq]++; i++; - ints &= ~(1 << pirq); + + idx = ffs(ints) - 1; + ints &= ~BIT(idx); + + pmu_irq_stats[idx]++; /* Note: for some reason, we get an interrupt with len=1, * data[0]==0 after each normal ADB interrupt, at least * on the Pismo. Still investigating... --BenH */ - if ((1 << pirq) & PMU_INT_ADB) { + switch (BIT(idx)) { + case PMU_INT_ADB: if ((data[0] & PMU_INT_ADB_AUTO) == 0) { struct adb_request *req = req_awaiting_reply; if (req == 0) { @@ -1470,25 +1470,28 @@ pmu_handle_data(unsigned char *data, int len) adb_input(data+1, len-1, 1); #endif /* CONFIG_ADB */ } - } + break; + /* Sound/brightness button pressed */ - else if ((1 << pirq) & PMU_INT_SNDBRT) { + case PMU_INT_SNDBRT: #ifdef CONFIG_PMAC_BACKLIGHT if (len == 3) pmac_backlight_set_legacy_brightness_pmu(data[1] >> 4); #endif - } + break; + /* Tick interrupt */ - else if ((1 << pirq) & PMU_INT_TICK) { - /* Environement or tick interrupt, query batteries */ + case PMU_INT_TICK: + /* Environment or tick interrupt, query batteries */ if (pmu_battery_count) { if ((--query_batt_timer) == 0) { query_battery_state(); query_batt_timer = BATTERY_POLLING_COUNT; } } - } - else if ((1 << pirq) & PMU_INT_ENVIRONMENT) { + break; + + case PMU_INT_ENVIRONMENT: if (pmu_battery_count) query_battery_state(); pmu_pass_intr(data, len); @@ -1498,7 +1501,9 @@ pmu_handle_data(unsigned char *data, int len) via_pmu_event(PMU_EVT_POWER, !!(data[1]&8)); via_pmu_event(PMU_EVT_LID, data[1]&1); } - } else { + break; + + default: pmu_pass_intr(data, len); } goto next; -- 2.16.4