Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp260028pxt; Wed, 11 Aug 2021 20:31:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwm5R+hPrQmeuRX7e3JB1906pM+alTwdTPy/CgKXv4AhVptJyvjeLpgNqpdSvTNUw8EwHkX X-Received: by 2002:a05:6e02:d03:: with SMTP id g3mr1288741ilj.127.1628739107746; Wed, 11 Aug 2021 20:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628739107; cv=none; d=google.com; s=arc-20160816; b=WTM5D286qN5PJAgLS9BnM+hlohqBJhI8EJ+y3G2pwiRA/jC82kViz5+RkN8Jxk1lx2 vCZYI+zVTxVoNmuUVn+y7W89CJlJUETsPxjMZukmhfU6VSgUKvbo7m7EAeSAznFx9z0c cTI4PTbZ2+jGLMrqwExlZKM1Ajw+01QCCwZ6F2OaH7/qwKW6a2rf6bAdypWf+SpQkSHm iuPZuxv4el4clw/U2bFsYR41/GOUasE/wxyBSRteOlUeicvkE5mr/FnITK5vUXYgN7US wAKE+/sa9i0uoc2KJ8GocMqo/kr6VcYmEiLXMoeBeIOZLMbCGBaTmbSwbhpTVXwnSOft JynA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NeX3WmTZdfb7EA9aTn39dTlE4e9PDnx0Q0e5xdmq7Jo=; b=zsDknZUjHErrvXXkES0ynHWXvHPNiYYdJYva35B+C1Obtj3COMuSKkwpy5uAa08Ho2 slrkBg3mezFrtKkLY8ZHidxJmg9xye2wE/xOb7S5TxaVvHIbYyGS3h43l3a5wPmM+p3A qBS1R7K/+YSjdNfpeuFc5M0hTv/zy++GmMF+lhaNnhdYDk7kdaEvqPlUeLGi81uxmxwh dnZssanUiI+AHus/Gsw6QzA3tpYmPXoFuO0umk5xBXo6OGsAfv9Z0D6kZXkaChqFTKgm FHt3VLGMukjUgNzxjBTObhPOVjHuwUyFGvkiHDzfWQh8DXG1nzj2FBaqKZogf2qTEDJX 3QzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=K1YA4Cbx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alliedtelesis.co.nz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x9si1491352jaf.48.2021.08.11.20.31.36; Wed, 11 Aug 2021 20:31:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=K1YA4Cbx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alliedtelesis.co.nz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233792AbhHLDRf (ORCPT + 99 others); Wed, 11 Aug 2021 23:17:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233724AbhHLDR2 (ORCPT ); Wed, 11 Aug 2021 23:17:28 -0400 Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [IPv6:2001:df5:b000:5::4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 297A4C061765 for ; Wed, 11 Aug 2021 20:17:04 -0700 (PDT) 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 AE520806B6; Thu, 12 Aug 2021 15:17:02 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1628738222; bh=NeX3WmTZdfb7EA9aTn39dTlE4e9PDnx0Q0e5xdmq7Jo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=K1YA4CbxjZB4ftGwrHh2lGK4ZK5Sj0SSAUdKlBDOwZSFPzoG3bu2NPvZEXRK9aCtJ 9En8b/dUDQJfewlCxM7Uq1opTmPPqVZCPL1/sy7Yz3yiSAblRiBB3gEnoq6cCnKu37 VtIq1Ki6Hy6ynDXTsX0GlABBPhByl3KGGu04miy14rVt2Una7OzvQLMN1K8nmAr+1+ jqYG2oOrc2pxr5WcIHbAjT2SqF24UlK7jaR+1AekkFh30SIdfpfvyySCYIk3piv0pB 0vw4tZNVyKBrMJEFyFr4wVpnKmDLKTrQRDhqKzsZqZRtDKOmjgMqQVYUT+SytVSeZf YW3bVzXnEIbaw== 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 ; Thu, 12 Aug 2021 15:17:02 +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 63BAC13EEA2; Thu, 12 Aug 2021 15:17:02 +1200 (NZST) Received: by pauld-dl.ws.atlnz.lc (Postfix, from userid 1684) id 581641E01E6; Thu, 12 Aug 2021 15:17:02 +1200 (NZST) From: Paul Davey To: Manivannan Sadhasivam Cc: Hemant Kumar , Bhaumik Bhatt , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Davey , stable@vger.kernel.org Subject: [PATCH v4 1/2] bus: mhi: Fix pm_state conversion to string Date: Thu, 12 Aug 2021 15:16:59 +1200 Message-Id: <20210812031700.23397-2-paul.davey@alliedtelesis.co.nz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210812031700.23397-1-paul.davey@alliedtelesis.co.nz> References: <20210812031700.23397-1-paul.davey@alliedtelesis.co.nz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SEG-SpamProfiler-Analysis: v=2.3 cv=aqTM9hRV c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=MhDmnRu9jo8A:10 a=VwQbUJbxAAAA:8 a=LpQP-O61AAAA:8 a=xDYxNL215i3Ysd8OqoQA:9 a=AjGcO6oz07-iQ99wixmX:22 a=pioyyrs4ZptJ924tMmac:22 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. Fixes: a6e2e3522f29 ("bus: mhi: core: Add support for PM state transition= s") Cc: stable@vger.kernel.org Reviewed-by: Manivannan Sadhasivam Reviewed-by: Hemant Kumar Signed-off-by: Paul Davey --- 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 5aaca6d0f52b..0d588b60929e 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[] =3D { =20 const char *to_mhi_pm_state_str(enum mhi_pm_state state) { - int index =3D find_last_bit((unsigned long *)&state, 32); + int index; =20 - if (index >=3D ARRAY_SIZE(mhi_pm_state_str)) + if (state) + index =3D __fls(state); + + if (!state || index >=3D ARRAY_SIZE(mhi_pm_state_str)) return "Invalid State"; =20 return mhi_pm_state_str[index]; --=20 2.32.0