From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48E74C7EE23 for ; Fri, 26 May 2023 22:22:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237297AbjEZWWh (ORCPT ); Fri, 26 May 2023 18:22:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236735AbjEZWWg (ORCPT ); Fri, 26 May 2023 18:22:36 -0400 Received: from fgw23-7.mail.saunalahti.fi (fgw23-7.mail.saunalahti.fi [62.142.5.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04DBE9E for ; Fri, 26 May 2023 15:22:22 -0700 (PDT) Received: from localhost (88-113-26-95.elisa-laajakaista.fi [88.113.26.95]) by fgw23.mail.saunalahti.fi (Halon) with ESMTP id c6010c4f-fc10-11ed-b972-005056bdfda7; Sat, 27 May 2023 01:00:49 +0300 (EEST) From: andy.shevchenko@gmail.com Date: Sat, 27 May 2023 01:00:48 +0300 To: Mukesh Ojha Cc: agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, linus.walleij@linaro.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Subject: Re: [PATCH v6 1/5] firmware: qcom_scm: provide a read-modify-write function Message-ID: References: <1680076012-10785-1-git-send-email-quic_mojha@quicinc.com> <1680076012-10785-2-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1680076012-10785-2-git-send-email-quic_mojha@quicinc.com> Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Wed, Mar 29, 2023 at 01:16:48PM +0530, Mukesh Ojha kirjoitti: > It was realized by Srinivas K. that there is a need of > read-modify-write scm exported function so that it can > be used by multiple clients. > > Let's introduce qcom_scm_io_update_field() which masks > out the bits and write the passed value to that > bit-offset. Subsequent patch will use this function. ... > + new = (old & ~mask) | val << (ffs(mask) - 1); It's a bit non-standard to see left shift here instead of masking. new = (old & ~mask) | (val & mask); is usual pattern. Note as well that your code is prone to subtle mistakes when overflow may easily override bits outside the mask. > + return qcom_scm_io_writel(addr, new); > +} -- With Best Regards, Andy Shevchenko