Message ID | 20230613085054.10976-3-raag.jadav@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp404304vqr; Tue, 13 Jun 2023 02:12:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73vya2J3ryBgM874KD+2xNv0+c97PyYEHc/iLnsMbau0oT19XLRAbTQVNiv/0EyCW++nli X-Received: by 2002:a05:6402:b38:b0:516:a005:14d with SMTP id bo24-20020a0564020b3800b00516a005014dmr6683668edb.17.1686647552752; Tue, 13 Jun 2023 02:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686647552; cv=none; d=google.com; s=arc-20160816; b=hJzeh6oqP3l2eUT3d3jvRgZqJj7j8Ku5Up/+livm/fhV7GGGBF/nvBYHuurEoVU+Hk GQN3memXWuXTyPCROKbAOJiaxaRneoLIc0kChSva6JZH8Rl8rqqdYuVmVKpNrp4V0PtA nlUco6a3iCkP4fClVPS3y83jnTBr3QIIi7Lpy0Ji8Q4RVjmk1SjcJ7rzQYkX1GQyKdwT zI0zbW+uFC4e4jSJkKJppmLbAyY5fqGKwqybeTNrfpHNbWtflhTYZWWIVdN51vp4rEnu Kr75LgX6/zA/fHHQn02xXCmhk6CNiEWdwIepPM2BCr2h/SuZIzp6x79W0V4NAG5rvrGK CIEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=sqgBTeU+jQkIt9W4/77JEHJiwUCLnL95SwbQbs6vI4c=; b=BRGBvL51GPtetAXTDfwX6iqZk9QucW+Lnbyk2uOpIj/lhp5dBwtSinGy7yT8VtazUb PqyzZx5Z7TYmMnpq1x4SR7wmlaHHhXbhPd2qTboeNAMZTh3nuPcogbTa9jVPiXLBrqRz +ii+g9oFEkAW1c9r6JogOxXzDYGVu6YLw5IAgaWySkFK63O1888BezZ1thCdurmR1ZuN CI6iFx/J1DQtPTHm/O5aQ9qQZ1kAXNGZX9t7BbxlQjPOJx9XJY0YBzlPKSh3s4Cd048E XleJBIeHjg/XWi+eZbxWu3r8ymbh5+vQSIhYheo4lUETa3SzV/ZXqlnPnSlZ/Ly7TtkB dhug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="dd2Zf4/S"; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e6-20020a50fb86000000b00514ae1a2bdasi7174814edq.671.2023.06.13.02.12.06; Tue, 13 Jun 2023 02:12:32 -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=@intel.com header.s=Intel header.b="dd2Zf4/S"; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241780AbjFMIvn (ORCPT <rfc822;rust.linux@gmail.com> + 99 others); Tue, 13 Jun 2023 04:51:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240755AbjFMIve (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 13 Jun 2023 04:51:34 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93A0CC0; Tue, 13 Jun 2023 01:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686646293; x=1718182293; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=QsnfKD0vrMxrGMgDPsYUSV+TjEAJfQkDBuxj7dIOTYA=; b=dd2Zf4/S7gvLJ3WcHarlrFW9x3M0OnUnrd+ExJNjjtxJZfK1iW/D7fYo 6wlMBznzWvAR25rGlUHZh0dheVIzUCE0YOdB5OrZGNA/HZ4TSZyCOgMg2 wzkLmLb7Y/gJk5OT3a5nzfRQWYTnSvGZ+0oD3v9T+ImgNIx7f4S05X1CL wVy1/R6QN8lmTNz4WRfktIhQbdqp7Jm9DC1YtE6KQ5RY693gKM6JJA6qq VS3wcHqbsMZtRzG4be+F8ZV1Uhomd9ZJAw8O39r+8azKl1hLAFImH6mU2 7DhBNmvXkPVpYS3q5mn07YqvNyxM2ZQwEB+DnCLGMIsxLFluGiLehQMWW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="386664947" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="386664947" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 01:51:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="824305096" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="824305096" Received: from inesxmail01.iind.intel.com ([10.223.154.20]) by fmsmga002.fm.intel.com with ESMTP; 13 Jun 2023 01:51:29 -0700 Received: from inlubt0316.iind.intel.com (inlubt0316.iind.intel.com [10.191.20.213]) by inesxmail01.iind.intel.com (Postfix) with ESMTP id 7123C19742; Tue, 13 Jun 2023 14:21:28 +0530 (IST) Received: by inlubt0316.iind.intel.com (Postfix, from userid 12101951) id 6C1E01C6; Tue, 13 Jun 2023 14:21:28 +0530 (IST) From: Raag Jadav <raag.jadav@intel.com> To: linus.walleij@linaro.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, mallikarjunappa.sangannavar@intel.com, pandith.n@intel.com, Raag Jadav <raag.jadav@intel.com> Subject: [PATCH v3 2/3] pinctrl: intel: refine ->irq_set_type() hook Date: Tue, 13 Jun 2023 14:20:53 +0530 Message-Id: <20230613085054.10976-3-raag.jadav@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230613085054.10976-1-raag.jadav@intel.com> References: <20230613085054.10976-1-raag.jadav@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768578144077659646?= X-GMAIL-MSGID: =?utf-8?q?1768578144077659646?= |
Series |
Minor improvements for Intel pinctrl
|
|
Commit Message
Raag Jadav
June 13, 2023, 8:50 a.m. UTC
Utilize a temporary variable for common shift operation
in ->irq_set_type() hook and improve readability.
While at it, simplify if-else-if chain and save a few bytes.
add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-16 (-16)
Function old new delta
intel_gpio_irq_type 317 301 -16
Total: Before=10469, After=10453, chg -0.15%
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
drivers/pinctrl/intel/pinctrl-intel.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
Comments
On Tue, Jun 13, 2023 at 02:20:53PM +0530, Raag Jadav wrote: > Utilize a temporary variable for common shift operation > in ->irq_set_type() hook and improve readability. > While at it, simplify if-else-if chain and save a few bytes. > > add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-16 (-16) > Function old new delta > intel_gpio_irq_type 317 301 -16 > Total: Before=10469, After=10453, chg -0.15% ... > value = readl(reg); > - > value &= ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV); > > if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { > - value |= PADCFG0_RXEVCFG_EDGE_BOTH << PADCFG0_RXEVCFG_SHIFT; > + rxevcfg = PADCFG0_RXEVCFG_EDGE_BOTH; > } else if (type & IRQ_TYPE_EDGE_FALLING) { > - value |= PADCFG0_RXEVCFG_EDGE << PADCFG0_RXEVCFG_SHIFT; > - value |= PADCFG0_RXINV; > + rxevcfg = PADCFG0_RXEVCFG_EDGE; > } else if (type & IRQ_TYPE_EDGE_RISING) { > - value |= PADCFG0_RXEVCFG_EDGE << PADCFG0_RXEVCFG_SHIFT; > + rxevcfg = PADCFG0_RXEVCFG_EDGE; > } else if (type & IRQ_TYPE_LEVEL_MASK) { > - if (type & IRQ_TYPE_LEVEL_LOW) > - value |= PADCFG0_RXINV; > + rxevcfg = PADCFG0_RXEVCFG_LEVEL; > } else { > - value |= PADCFG0_RXEVCFG_DISABLED << PADCFG0_RXEVCFG_SHIFT; > + rxevcfg = PADCFG0_RXEVCFG_DISABLED; > } > > + if (type == IRQ_TYPE_EDGE_FALLING || type == IRQ_TYPE_LEVEL_LOW) > + value |= PADCFG0_RXINV; > + > + value |= rxevcfg << PADCFG0_RXEVCFG_SHIFT; > writel(value, reg); Looking at this I realized that entire temporary variable assignments can be done outside of spin lock. You probably would need another one for keeping rxinv value. Will it give us any memory reduction in comparison to the current code?
> On Tue, Jun 13, 2023 at 02:20:53PM +0530, Raag Jadav wrote: > > Utilize a temporary variable for common shift operation in > > ->irq_set_type() hook and improve readability. > > While at it, simplify if-else-if chain and save a few bytes. > > > > add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-16 (-16) > > Function old new delta > > intel_gpio_irq_type 317 301 -16 > > Total: Before=10469, After=10453, chg -0.15% > > ... > > > value = readl(reg); > > - > > value &= ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV); > > > > if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { > > - value |= PADCFG0_RXEVCFG_EDGE_BOTH << > PADCFG0_RXEVCFG_SHIFT; > > + rxevcfg = PADCFG0_RXEVCFG_EDGE_BOTH; > > } else if (type & IRQ_TYPE_EDGE_FALLING) { > > - value |= PADCFG0_RXEVCFG_EDGE << > PADCFG0_RXEVCFG_SHIFT; > > - value |= PADCFG0_RXINV; > > + rxevcfg = PADCFG0_RXEVCFG_EDGE; > > } else if (type & IRQ_TYPE_EDGE_RISING) { > > - value |= PADCFG0_RXEVCFG_EDGE << > PADCFG0_RXEVCFG_SHIFT; > > + rxevcfg = PADCFG0_RXEVCFG_EDGE; > > } else if (type & IRQ_TYPE_LEVEL_MASK) { > > - if (type & IRQ_TYPE_LEVEL_LOW) > > - value |= PADCFG0_RXINV; > > + rxevcfg = PADCFG0_RXEVCFG_LEVEL; > > } else { > > - value |= PADCFG0_RXEVCFG_DISABLED << > PADCFG0_RXEVCFG_SHIFT; > > + rxevcfg = PADCFG0_RXEVCFG_DISABLED; > > } > > > > + if (type == IRQ_TYPE_EDGE_FALLING || type == > IRQ_TYPE_LEVEL_LOW) > > + value |= PADCFG0_RXINV; > > + > > + value |= rxevcfg << PADCFG0_RXEVCFG_SHIFT; > > writel(value, reg); > > Looking at this I realized that entire temporary variable assignments can be > done outside of spin lock. You probably would need another one for keeping > rxinv value. Something like this? u32 value, rxevcfg; u32 rxinv = 0; if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { rxevcfg = PADCFG0_RXEVCFG_EDGE_BOTH; } else if (type & IRQ_TYPE_EDGE_FALLING) { rxevcfg = PADCFG0_RXEVCFG_EDGE; } else if (type & IRQ_TYPE_EDGE_RISING) { rxevcfg = PADCFG0_RXEVCFG_EDGE; } else if (type & IRQ_TYPE_LEVEL_MASK) { rxevcfg = PADCFG0_RXEVCFG_LEVEL; } else { rxevcfg = PADCFG0_RXEVCFG_DISABLED; } if (type == IRQ_TYPE_EDGE_FALLING || type == IRQ_TYPE_LEVEL_LOW) rxinv = PADCFG0_RXINV; raw_spin_lock_irqsave(&pctrl->lock, flags); intel_gpio_set_gpio_mode(reg); value = readl(reg); value &= ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV); value |= rxinv; value |= rxevcfg << PADCFG0_RXEVCFG_SHIFT; writel(value, reg); > Will it give us any memory reduction in comparison to the current code? add/remove: 0/0 grow/shrink: 1/0 up/down: 4/0 (4) Function old new delta intel_gpio_irq_type 317 321 +4 Total: Before=10469, After=10473, chg +0.04% Unfortunately gcc doesn't seem to consider this as best of the sequence, and I'm not entirely sure why.
On Thu, Jun 15, 2023 at 09:48:12AM +0000, Jadav, Raag wrote: > > On Tue, Jun 13, 2023 at 02:20:53PM +0530, Raag Jadav wrote: > > > Utilize a temporary variable for common shift operation in > > > ->irq_set_type() hook and improve readability. > > > While at it, simplify if-else-if chain and save a few bytes. > > > > > > add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-16 (-16) > > > Function old new delta > > > intel_gpio_irq_type 317 301 -16 > > > Total: Before=10469, After=10453, chg -0.15% > > > > ... > > > > > value = readl(reg); > > > - > > > value &= ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV); > > > > > > if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { > > > - value |= PADCFG0_RXEVCFG_EDGE_BOTH << > > PADCFG0_RXEVCFG_SHIFT; > > > + rxevcfg = PADCFG0_RXEVCFG_EDGE_BOTH; > > > } else if (type & IRQ_TYPE_EDGE_FALLING) { > > > - value |= PADCFG0_RXEVCFG_EDGE << > > PADCFG0_RXEVCFG_SHIFT; > > > - value |= PADCFG0_RXINV; > > > + rxevcfg = PADCFG0_RXEVCFG_EDGE; > > > } else if (type & IRQ_TYPE_EDGE_RISING) { > > > - value |= PADCFG0_RXEVCFG_EDGE << > > PADCFG0_RXEVCFG_SHIFT; > > > + rxevcfg = PADCFG0_RXEVCFG_EDGE; > > > } else if (type & IRQ_TYPE_LEVEL_MASK) { > > > - if (type & IRQ_TYPE_LEVEL_LOW) > > > - value |= PADCFG0_RXINV; > > > + rxevcfg = PADCFG0_RXEVCFG_LEVEL; > > > } else { > > > - value |= PADCFG0_RXEVCFG_DISABLED << > > PADCFG0_RXEVCFG_SHIFT; > > > + rxevcfg = PADCFG0_RXEVCFG_DISABLED; > > > } > > > > > > + if (type == IRQ_TYPE_EDGE_FALLING || type == > > IRQ_TYPE_LEVEL_LOW) > > > + value |= PADCFG0_RXINV; > > > + > > > + value |= rxevcfg << PADCFG0_RXEVCFG_SHIFT; > > > writel(value, reg); > > > > Looking at this I realized that entire temporary variable assignments can be > > done outside of spin lock. You probably would need another one for keeping > > rxinv value. > > Something like this? > > u32 value, rxevcfg; > u32 rxinv = 0; > > if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { > rxevcfg = PADCFG0_RXEVCFG_EDGE_BOTH; > } else if (type & IRQ_TYPE_EDGE_FALLING) { > rxevcfg = PADCFG0_RXEVCFG_EDGE; > } else if (type & IRQ_TYPE_EDGE_RISING) { > rxevcfg = PADCFG0_RXEVCFG_EDGE; > } else if (type & IRQ_TYPE_LEVEL_MASK) { > rxevcfg = PADCFG0_RXEVCFG_LEVEL; > } else { > rxevcfg = PADCFG0_RXEVCFG_DISABLED; > } > > if (type == IRQ_TYPE_EDGE_FALLING || type == IRQ_TYPE_LEVEL_LOW) > rxinv = PADCFG0_RXINV; > > raw_spin_lock_irqsave(&pctrl->lock, flags); > > intel_gpio_set_gpio_mode(reg); > > value = readl(reg); > > value &= ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV); > value |= rxinv; > value |= rxevcfg << PADCFG0_RXEVCFG_SHIFT; > > writel(value, reg); This one looks better. > > Will it give us any memory reduction in comparison to the current code? > > add/remove: 0/0 grow/shrink: 1/0 up/down: 4/0 (4) > Function old new delta > intel_gpio_irq_type 317 321 +4 > Total: Before=10469, After=10473, chg +0.04% > > Unfortunately gcc doesn't seem to consider this as best of the sequence, > and I'm not entirely sure why. It's fine as is, readability counts more than few bytes here.
On Thu, Jun 15, 2023 at 12:55:17PM +0300, mika.westerberg@linux.intel.com wrote: > On Thu, Jun 15, 2023 at 09:48:12AM +0000, Jadav, Raag wrote: > > > On Tue, Jun 13, 2023 at 02:20:53PM +0530, Raag Jadav wrote: ... > > > Looking at this I realized that entire temporary variable assignments can be > > > done outside of spin lock. You probably would need another one for keeping > > > rxinv value. > > > > Something like this? Almost, see below. > > u32 value, rxevcfg; > > u32 rxinv = 0; No assignment here. u32 rxinv, rxevcfg; u32 value; > > if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { > > rxevcfg = PADCFG0_RXEVCFG_EDGE_BOTH; > > } else if (type & IRQ_TYPE_EDGE_FALLING) { > > rxevcfg = PADCFG0_RXEVCFG_EDGE; > > } else if (type & IRQ_TYPE_EDGE_RISING) { > > rxevcfg = PADCFG0_RXEVCFG_EDGE; > > } else if (type & IRQ_TYPE_LEVEL_MASK) { > > rxevcfg = PADCFG0_RXEVCFG_LEVEL; > > } else { > > rxevcfg = PADCFG0_RXEVCFG_DISABLED; > > } Now, if it's fully included in the diff (even with --patience parameter), then you may drop {}. > > if (type == IRQ_TYPE_EDGE_FALLING || type == IRQ_TYPE_LEVEL_LOW) > > rxinv = PADCFG0_RXINV; else rxinv = 0; > > raw_spin_lock_irqsave(&pctrl->lock, flags); > > > > intel_gpio_set_gpio_mode(reg); > > > > value = readl(reg); > > > > value &= ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV); > > value |= rxinv; > > value |= rxevcfg << PADCFG0_RXEVCFG_SHIFT; And I would rewrite these to the standard patterns: value = (value & ~PADCFG0_RXINV) | rxinv; value = (value & ~PADCFG0_RXEVCFG_MASK) | (rxevcfg << PADCFG0_RXEVCFG_SHIFT); And looking at this, perhaps do shift also outside the lock: } else { rxevcfg = PADCFG0_RXEVCFG_DISABLED; } rxevcfg <<= PADCFG0_RXEVCFG_SHIFT; But, taking into account scope of the _RXEVCFG_*, I would add shift directly to the definitions and kill that SHIFT entirely: #define PADCFG0_RXEVCFG_LEVEL (0 << 25) #define PADCFG0_RXEVCFG_EDGE (1 << 25) #define PADCFG0_RXEVCFG_DISABLED (2 << 25) #define PADCFG0_RXEVCFG_EDGE_BOTH (3 << 25) ... value = (value & ~PADCFG0_RXINV) | rxinv; value = (value & ~PADCFG0_RXEVCFG_MASK) | rxevcfg; Try that one and look if it looks better. It might even save bytes after all. > > writel(value, reg); > > This one looks better. > > > > Will it give us any memory reduction in comparison to the current code? > > > > add/remove: 0/0 grow/shrink: 1/0 up/down: 4/0 (4) > > Function old new delta > > intel_gpio_irq_type 317 321 +4 > > Total: Before=10469, After=10473, chg +0.04% > > > > Unfortunately gcc doesn't seem to consider this as best of the sequence, > > and I'm not entirely sure why. > > It's fine as is, readability counts more than few bytes here.
> On Thu, Jun 15, 2023 at 12:55:17PM +0300, > mika.westerberg@linux.intel.com wrote: > > On Thu, Jun 15, 2023 at 09:48:12AM +0000, Jadav, Raag wrote: > > > > On Tue, Jun 13, 2023 at 02:20:53PM +0530, Raag Jadav wrote: > > ... > > > > > Looking at this I realized that entire temporary variable > > > > assignments can be done outside of spin lock. You probably would > > > > need another one for keeping rxinv value. > > > > > > Something like this? > > Almost, see below. > > > > u32 value, rxevcfg; > > > u32 rxinv = 0; > > No assignment here. > > u32 rxinv, rxevcfg; > u32 value; > > > > if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { > > > rxevcfg = PADCFG0_RXEVCFG_EDGE_BOTH; > > > } else if (type & IRQ_TYPE_EDGE_FALLING) { > > > rxevcfg = PADCFG0_RXEVCFG_EDGE; > > > } else if (type & IRQ_TYPE_EDGE_RISING) { > > > rxevcfg = PADCFG0_RXEVCFG_EDGE; > > > } else if (type & IRQ_TYPE_LEVEL_MASK) { > > > rxevcfg = PADCFG0_RXEVCFG_LEVEL; > > > } else { > > > rxevcfg = PADCFG0_RXEVCFG_DISABLED; > > > } > > Now, if it's fully included in the diff (even with --patience parameter), then > you may drop {}. > > > > if (type == IRQ_TYPE_EDGE_FALLING || type == > IRQ_TYPE_LEVEL_LOW) > > > rxinv = PADCFG0_RXINV; > > else > rxinv = 0; > > > > raw_spin_lock_irqsave(&pctrl->lock, flags); > > > > > > intel_gpio_set_gpio_mode(reg); > > > > > > value = readl(reg); > > > > > > value &= ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV); > > > value |= rxinv; > > > value |= rxevcfg << PADCFG0_RXEVCFG_SHIFT; > > And I would rewrite these to the standard patterns: > > value = (value & ~PADCFG0_RXINV) | rxinv; > value = (value & ~PADCFG0_RXEVCFG_MASK) | (rxevcfg << > PADCFG0_RXEVCFG_SHIFT); > > And looking at this, perhaps do shift also outside the lock: > > } else { > rxevcfg = PADCFG0_RXEVCFG_DISABLED; > } > rxevcfg <<= PADCFG0_RXEVCFG_SHIFT; > > But, taking into account scope of the _RXEVCFG_*, I would add shift directly > to the definitions and kill that SHIFT entirely: > > #define PADCFG0_RXEVCFG_LEVEL (0 << 25) > #define PADCFG0_RXEVCFG_EDGE (1 << 25) > #define PADCFG0_RXEVCFG_DISABLED (2 << 25) > #define PADCFG0_RXEVCFG_EDGE_BOTH (3 << 25) > > ... > > value = (value & ~PADCFG0_RXINV) | rxinv; > value = (value & ~PADCFG0_RXEVCFG_MASK) | rxevcfg; > > Try that one and look if it looks better. It might even save bytes after all. Should I add all of this in original patch or send this as a separate patch on top this series?
On Thu, Jun 15, 2023 at 11:08:38AM +0000, Jadav, Raag wrote: ... > Should I add all of this in original patch or send this as a separate patch > on top this series? Always base the changes on the respective subsystem tree, don't forget to use --base when formatting patch with Git tools. Then send it separately. The 3rd patch in the series is questionable to me. I would like to look into it later on separately. (The first implies that there is no changes as per this series in that function).
diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index e8adf2580321..3f78066b1837 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -1128,8 +1128,8 @@ static int intel_gpio_irq_type(struct irq_data *d, unsigned int type) struct intel_pinctrl *pctrl = gpiochip_get_data(gc); unsigned int pin = intel_gpio_to_pin(pctrl, irqd_to_hwirq(d), NULL, NULL); unsigned long flags; + u32 value, rxevcfg; void __iomem *reg; - u32 value; reg = intel_get_padcfg(pctrl, pin, PADCFG0); if (!reg) @@ -1150,23 +1150,24 @@ static int intel_gpio_irq_type(struct irq_data *d, unsigned int type) intel_gpio_set_gpio_mode(reg); value = readl(reg); - value &= ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV); if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { - value |= PADCFG0_RXEVCFG_EDGE_BOTH << PADCFG0_RXEVCFG_SHIFT; + rxevcfg = PADCFG0_RXEVCFG_EDGE_BOTH; } else if (type & IRQ_TYPE_EDGE_FALLING) { - value |= PADCFG0_RXEVCFG_EDGE << PADCFG0_RXEVCFG_SHIFT; - value |= PADCFG0_RXINV; + rxevcfg = PADCFG0_RXEVCFG_EDGE; } else if (type & IRQ_TYPE_EDGE_RISING) { - value |= PADCFG0_RXEVCFG_EDGE << PADCFG0_RXEVCFG_SHIFT; + rxevcfg = PADCFG0_RXEVCFG_EDGE; } else if (type & IRQ_TYPE_LEVEL_MASK) { - if (type & IRQ_TYPE_LEVEL_LOW) - value |= PADCFG0_RXINV; + rxevcfg = PADCFG0_RXEVCFG_LEVEL; } else { - value |= PADCFG0_RXEVCFG_DISABLED << PADCFG0_RXEVCFG_SHIFT; + rxevcfg = PADCFG0_RXEVCFG_DISABLED; } + if (type == IRQ_TYPE_EDGE_FALLING || type == IRQ_TYPE_LEVEL_LOW) + value |= PADCFG0_RXINV; + + value |= rxevcfg << PADCFG0_RXEVCFG_SHIFT; writel(value, reg); if (type & IRQ_TYPE_EDGE_BOTH)