From patchwork Wed Jun 23 02:43:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Davey X-Patchwork-Id: 466420 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24982C2B9F4 for ; Wed, 23 Jun 2021 02:43:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECB9F6128C for ; Wed, 23 Jun 2021 02:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229934AbhFWCpt (ORCPT ); Tue, 22 Jun 2021 22:45:49 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:44267 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229786AbhFWCpt (ORCPT ); Tue, 22 Jun 2021 22:45:49 -0400 Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 297D480719; Wed, 23 Jun 2021 14:43:31 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1624416211; bh=6m75k33uLkoEGCsnXHFsQuSUeJtVMSaMAYRp55SjWOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yGP9CCV5YXeNFYbpHK5sR6rxAR+cT1tIgmtu4NpafVLIOimvL7loJykgaWYolEMsW 5xN+j2k1/WSr16zMnRPevimX+JRHvTsjX+ir5d/Xk8Xi/zJ65i6f+tU/Krl3gRmCeK Oq6ezvGoEXKhQMXdGj002WeJXvn/JSVdtG3wl0atg8STV/6OfXDVmKPP8+h+GEOzB1 4iq8lgG4apYlJWZwVsVBd2BCAKQbwjWs5rjI698WO3WA5jPkLCgv98XdEk7A4CCL/I 4tnir93Abb0mumrSjdXScdxpsYcC+9g+IDR2l54RVNVzEbnP/pqnN0+wgy5OE5Gxn6 R5xcYVNNp3VLg== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8, 2, 6, 11305) id ; Wed, 23 Jun 2021 14:43:30 +1200 Received: from pauld-dl.ws.atlnz.lc (pauld-dl.ws.atlnz.lc [10.33.23.37]) by pat.atlnz.lc (Postfix) with ESMTP id D9EEF13EEB4; Wed, 23 Jun 2021 14:43:30 +1200 (NZST) Received: by pauld-dl.ws.atlnz.lc (Postfix, from userid 1684) id D631D1E0560; Wed, 23 Jun 2021 14:43:30 +1200 (NZST) From: Paul Davey To: Manivannan Sadhasivam Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bhaumik Bhatt , Hemant Kumar , Paul Davey Subject: [PATCH v2 1/2] bus: mhi: Fix pm_state conversion to string Date: Wed, 23 Jun 2021 14:43:26 +1200 Message-Id: <20210623024327.15029-2-paul.davey@alliedtelesis.co.nz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210623024327.15029-1-paul.davey@alliedtelesis.co.nz> References: <20210623024327.15029-1-paul.davey@alliedtelesis.co.nz> MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.3 cv=IOh89TnG c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=r6YtysWOX24A:10 a=xDYxNL215i3Ysd8OqoQA:9 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On big endian architectures the mhi debugfs files which report pm state give "Invalid State" for all states. This is caused by using find_last_bit which takes an unsigned long* while the state is passed in as an enum mhi_pm_state which will be of int size. Fix by using __fls to pass the value of state instead of find_last_bit. Signed-off-by: Paul Davey --- Not adding Tested-by or Reviewed-by tags as this patch has changed substantially from v1. drivers/bus/mhi/core/init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index c81b377fca8f..0706eb046f2a 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -79,9 +79,12 @@ static const char * const mhi_pm_state_str[] = { const char *to_mhi_pm_state_str(enum mhi_pm_state state) { - int index = find_last_bit((unsigned long *)&state, 32); + int index; - if (index >= ARRAY_SIZE(mhi_pm_state_str)) + if (state) + index = __fls(state); + + if (!state || index >= ARRAY_SIZE(mhi_pm_state_str)) return "Invalid State"; return mhi_pm_state_str[index];