Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3621084imm; Mon, 2 Jul 2018 02:27:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKyAEn++6WIGbMItx+nrrEPYmg3lVY9wTffOFvqz84xv3qubvwphbMAJ0r599bodNjONf9G X-Received: by 2002:a65:4d4b:: with SMTP id j11-v6mr21120016pgt.430.1530523670067; Mon, 02 Jul 2018 02:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530523670; cv=none; d=google.com; s=arc-20160816; b=HVULEmLVvJ5PktwxkOwV2domXGjqSagp/gob+u/vU6zqMPjeHt+63lS3PSupscB+yC qSsYo6VnqllspWdjpvgILae/j5zItO0HdBbaQjV/IFjS9EgcJcpUabgGyvVycGa9zR/5 7WYYqgJJsUpgWTp0R0blloBLzudh8US4kmesRWGRouJ23J/g6DXByu3gteLFP6F1A82U Mo7f+sjVXDmEZLDNnigHcTIKjmfKX/D7tPd7QhWUHw+4O0xEUSxW5lT6Es8Vm0VkZXCu CQbbx8sSpMCwtQYJAeOFhHADgDAID2w1BNAYirjvVJ3OQSEj0F2Rvv5beB9LMeCMRkhi HEoA== 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=7qRE4g773IzasWSJxwMl3jZ0mVZdPkk+zGvsOIeW+kI=; b=f51+12mCnMdksdGZNI7wDshon3jI/oBK8frYeVwuRAxm3xqqHmiWEOAb8Raoat2PrX mUAgp/fnjvcSN6ml4Jel+mMwfPfxyc9QFH7vmtmZit8UlfR0L+ipXKjlSCJ1OrrvVq7n EVNuLRNNLZ0eythjyCsRfgWUOZOprMpHSbanXGIN1VlKQMArex6BeS0nFm3IEZRUv1yA XLxupBHo+ofE9k36GlRdJ/aMARNuxlgFIzdAP8jgDuIS+S1FqHZgyEwPXQdIMyQyGZkO SefGuOw/dY91qh2FWQ1/VzJra1gYRYVDADg6sIv6SOsm/EAaYNOSMr7p0BBd6/9LTF2R XfEw== 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 j61-v6si16293554plb.68.2018.07.02.02.27.06; Mon, 02 Jul 2018 02:27:50 -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 S964911AbeGBIWa (ORCPT + 99 others); Mon, 2 Jul 2018 04:22:30 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:48856 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933647AbeGBIVY (ORCPT ); Mon, 2 Jul 2018 04:21:24 -0400 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 760D7293A8; Mon, 2 Jul 2018 04:21:19 -0400 (EDT) To: Benjamin Herrenschmidt Cc: Michael Schmitz , , , Message-Id: <3aaf05c25cc54ee3335bae315ffe181d5c751e55.1530519301.git.fthain@telegraphics.com.au> In-Reply-To: References: From: Finn Thain Subject: [PATCH v4 10/11] macintosh/via-pmu: Clean up interrupt statistics Date: Mon, 2 Jul 2018 04:21:19 -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 a68e7a6f00cc..3da5d40309d4 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c @@ -1355,7 +1355,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; @@ -1377,25 +1378,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) { @@ -1433,25 +1433,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); @@ -1461,7 +1464,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