Re: [PATCH v2 1/4] PCI: Add pci_power_t helper functions
From: andriy.shevchenko@xxxxxxxxx
Date: Thu Nov 19 2026 - 11:51:20 EST
On Thu, Nov 19, 2026 at 02:35:46PM +0000, Habil Eren Türker wrote:
> Add helper functions to extract, set and compare PCI power
> states in the Power Management Control/Status register.
>
> This follows the discussion with Andy Shevchenko and
> Bjorn Helgaas in response to:
>
> "[PATCH] x86/quirks: Cast PCI_D0 to u16 in apple_airport_reset()"
> https://lore.kernel.org/lkml/20261118161559.63617-1-habilerenturker@xxxxxxxxxxx/
Make it a Link tag with reference
This follows the discussion with Andy Shevchenko and Bjorn Helgaas in
response to "x86/quirks: Cast PCI_D0 to u16 in apple_airport_reset()" [1].
Link: $URL [1]
> Signed-off-by: Habil Eren Türker <habilerenturker@xxxxxxxxxxx>
...
> +++ b/include/linux/pci.h
> #include <uapi/linux/pci.h>
>
> #include <linux/pci_ids.h>
> +#include <linux/bitfield.h>
Put it upper to the proper group of headers (they are grouped from the generic
to custom).
...
> +/* Helper functions for PCI power management */
> +static inline pci_power_t pci_power_t_get(u32 csr)
Why u32 as it seems the value is 16-bit?
> +{
> + return (pci_power_t __force)FIELD_GET(PCI_PM_CTRL_STATE_MASK, csr);
> +}
> +
> +static inline void pci_power_t_set(u16 *csr, pci_power_t state)
> +{
> + *csr &= ~PCI_PM_CTRL_STATE_MASK;
> + *csr |= FIELD_PREP(PCI_PM_CTRL_STATE_MASK, (__force u32)state);
Why u32 and not u16?
> +}
> +
> +static inline bool pci_power_eq(u32 csr, pci_power_t state)
> +{
> + return pci_power_t_get(csr) == state;
> +}
> +
> +static inline bool pci_power_gt(u32 csr, pci_power_t state)
> +{
> + return pci_power_t_get(csr) > state;
> +}
> +
> +static inline bool pci_power_lt(u32 csr, pci_power_t state)
> +{
> + return pci_power_t_get(csr) < state;
> +}
Same questions.
--
With Best Regards,
Andy Shevchenko