From patchwork Sun Apr 23 09:06:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Wang X-Patchwork-Id: 677025 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 690ACC77B76 for ; Sun, 23 Apr 2023 09:07:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229491AbjDWJHZ (ORCPT ); Sun, 23 Apr 2023 05:07:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjDWJHY (ORCPT ); Sun, 23 Apr 2023 05:07:24 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01olkn2053.outbound.protection.outlook.com [40.92.53.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26AD010D9; Sun, 23 Apr 2023 02:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rg2ye70yGuR0ol1gEPqmKHvKMcJ3StHTCGNd6zXd3+n3rFWOHoqc5e1UkYrdncJibhUe/vKAoWmErSqlXZmrw8DPO5eLIaFkBnSFixsGm9ZDuaqRRGY/cv2e+IP/dD5CUkuYvhIMo37qFnjGmKS++JLKVDM1iVk3PqqmjwhkCnewBorPr0tdUp6bKB+mDhOJeTVbUhgb4X+0h3KKSkTonfcWdgcYDFsu4gwnoCwv36pgxRJiDbLaLfdCWTy11DxfDrdwb35HlubS9en9/2JhJ3eHqGTXBhJCt7SaQpnEaAm9cGg3FpAy7NM3tcRUtEQoTy/zlpx6xisc62jRny3bYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7ajPr7tZ7gzOL2AAofFKGLkONv5fpHrXV9pX+0gP42s=; b=ZHiu5pGuWItqIoqsX/drQhQxvAoooRiaQmj8BfqU4OP1OObXp3sTTuE+fbUO9JEcRE6oytVwfSZuKgC/Yrc+jf7wnL1AEsR+fs8ohZVg6FFsLWXnVbXNjw5JJW3+Z62cDqrfGGfqX8rASKXzXi/VZPP9X6WbtixBLkr5aX7slnTb1OjkD6rxGhX/vjGtNNX8oN1QkVvP/4Q0BnkTdd7AaGpH3CNuP/SRnfvRzoCSv7soAucvDPfr1ax5XF6/IyoXd66gRINTUPlGDZPPfcQalrZNzy0NKnfojRUDg0fx5nJy5NByKILkkdi249ETWHamogH4/Fw1RDBU/VWgLrNQPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7ajPr7tZ7gzOL2AAofFKGLkONv5fpHrXV9pX+0gP42s=; b=u9aijyhFNDJujuROu98qoBRkHzIwymV/GJYk8ich5dr5bBbzuuJdyTLotwZtCHZspU4oLGpRHuS5rkNZuEZ82w4gP1PtwwymJ9LKb79HbPUoNSVoXGIJZ43ijHIP0ItejWeEGyxHsBGccqF2iXf06NkIfwUBjqRDclDYOmTa/4FeXwkAb3+5RaF7q6zobuL+wgNO+xw/M9QzMBu8CpQGxfXZqBhaNOdoAuOEjtJStINWnoVnbG9j5QnXLqeFChKxKZ7phPIcNJ6Y8s5g/buMUmMHL+cuVT0PTaWVx2YuSb/pgzrXRBQ6+JdNLAtKGM0kF17AEMu/SwjX/nVtY6dq/g== Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) by SEYPR01MB5076.apcprd01.prod.exchangelabs.com (2603:1096:101:d1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.11; Sun, 23 Apr 2023 09:07:17 +0000 Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com ([fe80::5bff:fd7e:ec7c:e9d3]) by KL1PR01MB5448.apcprd01.prod.exchangelabs.com ([fe80::5bff:fd7e:ec7c:e9d3%5]) with mapi id 15.20.6340.018; Sun, 23 Apr 2023 09:07:17 +0000 From: Yan Wang To: linus.walleij@linaro.org, brgl@bgdev.pl Cc: Yan Wang , Andy Shevchenko , linux-gpio@vger.kernel.org (open list:GPIO SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1] gpio: mmio: restroe get multiple gpio mask Date: Sun, 23 Apr 2023 17:06:48 +0800 Message-ID: X-Mailer: git-send-email 2.17.1 X-TMN: [fhe4TsjhD8S/2z2nNncUhHci38xkQjQYa+UPKqAQ9zw=] X-ClientProxiedBy: SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) To KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) X-Microsoft-Original-Message-ID: <20230423090648.20882-1-rk.code@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR01MB5448:EE_|SEYPR01MB5076:EE_ X-MS-Office365-Filtering-Correlation-Id: a549ac5a-8928-45d5-52d5-08db43da2312 X-MS-Exchange-SLBlob-MailProps: 70qbaZjg4mut0ZTEc/+RhwzsFjQD3otITfzPgwyCuh3DXz2qZZ6IBn1SP72dI6E6t9fdYxuEdZ7617P3ZbTzk/OpEuBrRoQtedzx591hTrW/KUdpUINc6ZLcigV6Z+TxPigBSpPZdNX47KLla6VgH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VIqR6GyVBXVtbJWGqD0f25OeIk8rFxC1UPEyrDmD6nxFn0DZmXIPj3ikXnuGz6DQx4YhKmrrvBQAqTCA9IEriC5vsxikNWY+i25Gy6wESgqFn12VAG6hFC4o2AySORwA/zidStE9Tpu0OEvhs38f9TAqO0+Sw3QA4B1BBqr7T6GrvBzHObBMVrGD3i7xjJ41jgm7Lbb+GTPeLbXpMMwoU44xKQkdLXOpyqWmRZKc0Sk1YIaIe0JGpFRNAUsFG4HVHaVHBFWWRBuik/xqljXZhXtJgS/RndZMJbAkknNe5tHPOEsjH9V9LywgzyZHcatE2RcgHNHmXzN5Hue+Hph3Az+lEA9fIZVZwuexVVZLNj6Fp4nBWYcaaZc8Cd+LbZxdqjWE85o0Q4A/gno1onA5plNqBGEvxhlGyV/ixMKbwjsjP6EA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a549ac5a-8928-45d5-52d5-08db43da2312 X-MS-Exchange-CrossTenant-AuthSource: KL1PR01MB5448.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2023 09:07:17.5956 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR01MB5076 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Simplify the code,should not modify its logic. 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_chip *gc, *clear_mask = 0; for_each_set_bit(i, mask, gc->bgpio_bits) { - if (test_bit(i, bits)) - *set_mask |= bgpio_line2mask(gc, i); - else - *clear_mask |= bgpio_line2mask(gc, i); + if (*mask == 0) + break; + if (__test_and_clear_bit(i, mask)) { + if (test_bit(i, bits)) + *set_mask |= bgpio_line2mask(gc, i); + else + *clear_mask |= bgpio_line2mask(gc, i); + } } }