Re: [PATCH v2 2/4] PCI: Convert pci.c to pci_power_t helpers

From: andriy.shevchenko@xxxxxxxxx

Date: Thu Nov 19 2026 - 12:11:29 EST


On Thu, Nov 19, 2026 at 02:35:48PM +0000, Habil Eren Türker wrote:
> Convert PCI core code to use the pci_power_t helper functions
> when accessing the Power Management Control/Status register.
>
> Keep comparisons between values already typed as pci_power_t
> as direct typed comparisons.

Please, add a couple of examples of the sparse warnings.

...

> - state = pmcsr & PCI_PM_CTRL_STATE_MASK;
> -
> - need_restore = (state == PCI_D3hot || dev->current_state >= PCI_D3hot) &&
> + need_restore = (pci_power_eq(pmcsr, PCI_D3hot) ||
> + dev->current_state >= PCI_D3hot) &&
> !(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET);

Please, fix indentation.

need_restore = !(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET) &&
(pci_power_eq(pmcsr, PCI_D3hot) || dev->current_state >= PCI_D3hot);

Or create an additional temporary variable.

in_d3 = pci_power_eq(pmcsr, PCI_D3hot) || dev->current_state >= PCI_D3hot;
need_restore = in_d3 && !(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET);

> - if (state == PCI_D0)
> + if (pci_power_eq(pmcsr, PCI_D0))
> goto end;

--
With Best Regards,
Andy Shevchenko