[PATCH V2 7/8] scsi: ufs: core: Do not write interrupt enable register unnecessarily

Adrian Hunter
2025-07-23T16:59:26Z

Write a new value to the interrupt enable register only if it is different
from the old value, thereby saving a register write operation.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
drivers/ufs/core/ufshcd.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 1567aba866b5..df475b3fb7c5 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -371,10 +371,11 @@ EXPORT_SYMBOL_GPL(ufshcd_disable_irq);
*/
static void ufshcd_enable_intr(struct ufs_hba *hba, u32 intrs)
{
- u32 set = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+ u32 old_val = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+ u32 new_val = old_val | intrs;

- set |= intrs;
- ufshcd_writel(hba, set, REG_INTERRUPT_ENABLE);
+ if (new_val != old_val)
+ ufshcd_writel(hba, new_val, REG_INTERRUPT_ENABLE);
}

/**
@@ -384,10 +385,11 @@ static void ufshcd_enable_intr(struct ufs_hba *hba, u32 intrs)
*/
static void ufshcd_disable_intr(struct ufs_hba *hba, u32 intrs)
{
- u32 set = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+ u32 old_val = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+ u32 new_val = old_val & ~intrs;

- set &= ~intrs;
- ufshcd_writel(hba, set, REG_INTERRUPT_ENABLE);
+ if (new_val != old_val)
+ ufshcd_writel(hba, new_val, REG_INTERRUPT_ENABLE);
}

static void ufshcd_configure_wb(struct ufs_hba *hba)
--
2.48.1