Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1003561pxv; Thu, 15 Jul 2021 22:36:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydILFcwn0MNoFFFRqnq/x21Q09Qpsn0ezyuADMiQ4p/U3neV0N2lZVWfQ/ktaPV4vhL2vi X-Received: by 2002:a92:d4c4:: with SMTP id o4mr4920412ilm.39.1626413775141; Thu, 15 Jul 2021 22:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626413775; cv=none; d=google.com; s=arc-20160816; b=nhGgnhtMSIS1Is+Bu3UwU1gKI1Rf/SQbB05cAVMCW1VdHFaxCaO9pDVI1PG+XKVSTK qJFlz4BGhZKyLrl4VTcaWkF4RJmORG2ySDmQ+3hKzUR/euJbHpEyjfc7TOOgSnb6kJoe xP4Jv8wiMUqvBVhtuAX6d3XOW/np1m+jZ5CV/j5jlyYbJPcUS4H3NO1A0LioCNidHXpV PosPmX9BxD29H7gcY8uf9lV77mf+aQUKi9iw8cOztFc3kOYJeNah3z6Zl8ULdfoW3h6g F1R6MpvI+fydL50sQHq1Dxg8IETmLjc1QcKHmKSaiyvSz8TToYYKFKeNXZdZAP5UufoR O5Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=8BtAHa+q/TF8hhu0N480/79hjv/fIbA3t2AzlSuRjSY=; b=qWhf/MIZ/pfvT3pCMs3QHVr06+wlQnhkdfcDo4GrB6ZaieTyzU+GFkTZBd+6taQiKa FMpedQ54TCuIp4V5FMRf/NeCUcgvi9BCt8e+lI7TA3265KyI7EfLmTXXek3HPWntiKCw tB82RqEDo6W9xqbzWZKbmGXvN1bjGUe8JrqpAjPVxDbj5aQvz4uCrFgkZGsA8aJCnImK +ilgbBLHCPFj7HWw2mp0CLYMOMv1xQYEjzWwNKmg4Oor2fCZl/NvTgvnWhUH44yN1vYd zsczZ/DFmuuXwF5xziklVIvXZtMiRjqJbkK4dzFCRw1VuY41NtzBG00EYR5GvuPL9dPm 3ZPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Im09OP2r; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si1561839ilq.107.2021.07.15.22.36.02; Thu, 15 Jul 2021 22:36:15 -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=@kernel.org header.s=k20201202 header.b=Im09OP2r; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234183AbhGPFiN (ORCPT + 99 others); Fri, 16 Jul 2021 01:38:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:34382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234174AbhGPFiM (ORCPT ); Fri, 16 Jul 2021 01:38:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 48472613CC; Fri, 16 Jul 2021 05:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626413717; bh=bLl2ek/Iz6k79psgxdxnjSxBYO7VD1ncmUurpZkR8Nw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Im09OP2rEzXbCm7kGeQRSYGCQr4ysGGF3PCOlQGds3wll9MASqe4AwzOBnT0gUU1i Npt0UBRCVHGHvuBIcAOG+gu9Dzy7CaWADLApTAMNMo4Jv1qY3Yq04qxDCyWw5AIKPJ TObj+dxWu1yF3nYWlIUcPGq7ES57RLfDaLxGkogAH6hBKrVPueAI5vLvImXnNmZh+F n6n/l8lpdoWFFO93HRbNmXhGFtaIVGK7WbAjgfSyOtmNrNCioipUckfjxxAB5linNZ ul3G19f5jOmRstpyTK96YscPHfWBri2782nJJTnocrgWJNdAE4OsWrpMRE8IIjxvuD yHrC/iRqMZDyQ== Date: Fri, 16 Jul 2021 11:05:11 +0530 From: Manivannan Sadhasivam To: Paul Davey Cc: Hemant Kumar , Bhaumik Bhatt , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] bus: mhi: Fix pm_state conversion to string Message-ID: <20210716053511.GA3323@workstation> References: <20210629035357.11091-1-paul.davey@alliedtelesis.co.nz> <20210629035357.11091-2-paul.davey@alliedtelesis.co.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210629035357.11091-2-paul.davey@alliedtelesis.co.nz> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 29, 2021 at 03:53:56PM +1200, Paul Davey wrote: > 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 Reviewed-by: Manivannan Sadhasivam Thanks, Mani > --- > 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]; > -- > 2.32.0 >