[PATCH] PCI/AER: Use pci_clear_and_set_config_dword() to simplify mask updates
Replace the manual read-modify-write sequences in pci_aer_unmask_internal_errors()with pci_clear_and_set_config_dword(). This function performs the read/write operations atomically and reduces code duplication. Signed-off-by: Hans Zhang <18255117...@163.com> --- drivers/pci/pcie/aer.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index a1cf8c7ef628..20d2d7419fa4 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -953,15 +953,12 @@ static bool find_source_device(struct pci_dev *parent, static void pci_aer_unmask_internal_errors(struct pci_dev *dev) { int aer = dev->aer_cap; - u32 mask; - pci_read_config_dword(dev, aer + PCI_ERR_UNCOR_MASK, &mask); - mask &= ~PCI_ERR_UNC_INTN; - pci_write_config_dword(dev, aer + PCI_ERR_UNCOR_MASK, mask); + pci_clear_and_set_config_dword(dev, aer + PCI_ERR_UNCOR_MASK, + PCI_ERR_UNC_INTN, 0); - pci_read_config_dword(dev, aer + PCI_ERR_COR_MASK, &mask); - mask &= ~PCI_ERR_COR_INTERNAL; - pci_write_config_dword(dev, aer + PCI_ERR_COR_MASK, mask); + pci_clear_and_set_config_dword(dev, aer + PCI_ERR_COR_MASK, + PCI_ERR_COR_INTERNAL, 0); } static bool is_cxl_mem_dev(struct pci_dev *dev) base-commit: ca91b9500108d4cf083a635c2e11c884d5dd20ea -- 2.25.1
Re: [PATCH v2 6/6] powerpc: sysdev: use lock guard for mutex
Hi On 4/30/25 18:40, Srikar Dronamraju wrote: * Shrikanth Hegde [2025-03-14 17:15:02]: Hi Srikar. use guard(mutex) for scope based resource management of mutex This would make the code simpler and easier to maintain. More details on lock guards can be found at https://lore.kernel.org/all/20230612093537.614161...@infradead.org/T/#u Signed-off-by: Shrikanth Hegde --- arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c b/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c index ce6c739c51e5..bbfc7c39b957 100644 --- a/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c +++ b/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c @@ -75,7 +75,7 @@ static ssize_t fsl_timer_wakeup_store(struct device *dev, if (kstrtoll(buf, 0, &interval)) return -EINVAL; - mutex_lock(&sysfs_lock); + guard(mutex)(&sysfs_lock); if (fsl_wakeup->timer) { disable_irq_wake(fsl_wakeup->timer->irq); @@ -84,14 +84,12 @@ static ssize_t fsl_timer_wakeup_store(struct device *dev, } if (!interval) { - mutex_unlock(&sysfs_lock); return count; } Nit: Here and the next change, due to the current change, there is no need for curly braces. Ok. will fix it next version. Other than this nit looks good to me. Reviewed-by: Srikar Dronamraju Thanks for the reviews.