Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5207640rwr; Mon, 24 Apr 2023 00:02:02 -0700 (PDT) X-Google-Smtp-Source: AKy350aQVnQQQnhcnIhtKK+sGzJRDlBRFNStVUAR/5rtc4S8Z5ElsFucK6yJKeVOufYF0stEwesG X-Received: by 2002:a17:903:25d1:b0:1a6:3e45:8df with SMTP id jc17-20020a17090325d100b001a63e4508dfmr16614371plb.33.1682319722578; Mon, 24 Apr 2023 00:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682319722; cv=none; d=google.com; s=arc-20160816; b=Qpcu04j+48FSukp2efqN0+I2d0HY+tfiUXD7e7oknl76nODRpKjcAr+H5Vk05bEpEQ uPWbKEj+89bNvK6igBeVeV5OidYR5EtRf2VUVWIfHlgpelSbitipyPQm7vof7mnY17tO 89GOU2t+aUNlfNIUWYa77v+oA9yemsELZF3M7gi1ixyOpjkPs+DwDFhupHNyrI9jYQ1N YPy0QEQkMjShQwFZQpHoPR2vmivi5YvWzQxsy5eHfcjmhy0wAn64nl2tr9VRuEjZ68rH onXE0vr2lRCwDIm/hfROpHivbTVNdjJDZhROfAtYLgBVLbmaQ4AAKX8QEY0kc3mntx9C Cmqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=A4rVcZshumczn0J8QZMiSz4nWQLMGsW4QsA9geh1PPA=; b=e2XwPDTX/vQdexPcVMjWhZ4v7MfjZqc9w1kf4HnmoGnFJTzd7Pyj/jt3OLH8duGsY6 ot9rUKVaja067uQ/RobAp++NY6Z31igvCbcEniQ7xRCtqtcbvtnDg6cLXD5vF3xBOTxd lO55p+yf6Ut92sGCdmWeabZ5cTySNxhQRosMJWkXLcUHQZFLjGpPcsEnFSWxZBxKLzeh tNeZhZ0cX4OLX6QeYR6YmLLN1xWChrU02sSaN3ZCQWtoBn7JhfuJIPtHY31jCR51DF3p wZXm9hjTgxcKgQtQGHfMl2YFMi/WsRHeNRwaaL97Cl0ev7e61aDW3UEpPAqxz8rzqVBw zHAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=buZlt30e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u18-20020a17090341d200b001a97a54c3a2si1584903ple.197.2023.04.24.00.01.49; Mon, 24 Apr 2023 00:02:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=buZlt30e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230467AbjDXG5O (ORCPT + 99 others); Mon, 24 Apr 2023 02:57:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbjDXG5M (ORCPT ); Mon, 24 Apr 2023 02:57:12 -0400 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58CAA2D70 for ; Sun, 23 Apr 2023 23:57:05 -0700 (PDT) Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-b992ed878ebso10973716276.0 for ; Sun, 23 Apr 2023 23:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682319424; x=1684911424; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=A4rVcZshumczn0J8QZMiSz4nWQLMGsW4QsA9geh1PPA=; b=buZlt30e78vPJkSEFmf8lmXCZ1uZX9dH3B5V9mONRspwdpPld+xXEwYDnWh4FRw+dh eE7czF6607e7Zrk47RdSjzH0zBxmjP6kZk6KL7BlIaNkWE3roUolFQd5IuMPQcatsqyf iS+NgU7irDe/Jjfk/721+Mv2JUFHLpfU+/WU7/vbhNhdtRllmyZn3S5wxA2fdnu4FhrQ cLh63TFk8ded/NY9BP5JyVakpP6ywbilYcKGfbCZDvCs7p3IVdDxvW2xeJX+YCcL3thg 1SyEGzIF0JXMTOcXPff7TvAPOi6X+DMPMFLoVjr9+EA47UUPzTBduFwOk5UGY2It5snO Kx5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682319424; x=1684911424; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A4rVcZshumczn0J8QZMiSz4nWQLMGsW4QsA9geh1PPA=; b=enUv7UcS6ZEGEFUsKSz+vqQ85NYAC8/rfYvVnXBM5AJ2FX8eQ2vzxhr7NRZrYuesW7 BEb+1YyXu8BX1wL8iRrnhc3IsgkHD6i+BkTRm3C97MxsLTagwPacrcqzTUhg09bCTsOY WtLLxJBJUapEUy4CHTj7A4sDD5tI/8amKqC/jJTJoLEflxyhjr17VcFj8uBosn4C40j2 EqtNb/9rI4TkSfJ/Et/qENlDcF9D0KQ1eTxN450NljlJknQUVaIrzRlLIiAW6OGYdcbb NqtKSbXVgo3PnlW83c2HYyqOriRuibSf0meoOqHAiCHodGQ5cjRCNi2EzDV37xnrCEUd JWjg== X-Gm-Message-State: AAQBX9dYPb7GJoRSE7BGLTFIpDGVhPnJ4aUVHd5LI/mMYGnNz0A3igGd +bjvpVcbXTQJr7pEYPwefyfAWPDjr4/cvaU1fqJ1wQ== X-Received: by 2002:a0d:cac2:0:b0:544:9b15:e197 with SMTP id m185-20020a0dcac2000000b005449b15e197mr7959752ywd.20.1682319424426; Sun, 23 Apr 2023 23:57:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Walleij Date: Mon, 24 Apr 2023 08:56:52 +0200 Message-ID: Subject: Re: [PATCH v1] gpio: mmio: restroe get multiple gpio mask To: Yan Wang Cc: brgl@bgdev.pl, Andy Shevchenko , "open list:GPIO SUBSYSTEM" , open list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yan, thanks for your patch! On Sun, Apr 23, 2023 at 11:07=E2=80=AFAM Yan Wang wro= te: > Simplify the code,should not modify its logic. I don't see how it simplifies the code, it seems to me that it is making it more complex? > Fixes: 761b5c30c206 ("gpio: mmio: replace open-coded for_each_set_bit()") > Signed-off-by: Yan Wang > --- > drivers/gpio/gpio-mmio.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c > index d9dff3dc92ae..c2347ef3a4df 100644 > --- a/drivers/gpio/gpio-mmio.c > +++ b/drivers/gpio/gpio-mmio.c > @@ -271,10 +271,14 @@ static void bgpio_multiple_get_masks(struct gpio_ch= ip *gc, > *clear_mask =3D 0; > > for_each_set_bit(i, mask, gc->bgpio_bits) { > - if (test_bit(i, bits)) > - *set_mask |=3D bgpio_line2mask(gc, i); > - else > - *clear_mask |=3D bgpio_line2mask(gc, i); > + if (*mask =3D=3D 0) > + break; > + if (__test_and_clear_bit(i, mask)) { > + if (test_bit(i, bits)) > + *set_mask |=3D bgpio_line2mask(gc, i); > + else > + *clear_mask |=3D bgpio_line2mask(gc, i); > + } The intention of the change seems to be to break out of the loop when all set bits are handled, by successively masking off one bit at a time from mask. So this is intended as an optimization, not a simplification. I think for_each_set_bit() is already skipping over every bit that is zero, see include/linux/find.h. So this optimization gains us nothing. Yours, Linus Walleij