Re: [PATCH] PCI: Add PCI_RID_MASK macro

From: Siddharth Vadapalli

Date: Mon Feb 16 2026 - 07:13:34 EST


On Mon, 2026-02-16 at 17:36 +0530, Aksh Garg wrote:
> Routing ID (RID) is a 16-bit value composed of bus number and devfn.

nitpick: "Requester ID" might be a more appropriate description of BDF.

> Add a PCI_RID_MASK macro to eliminate the use of magic number 0xffff
> when masking for RIDs.
>
> This provides a standard way for drivers to extract RIDs without
> resorting to magic numbers.
>
> Signed-off-by: Aksh Garg <a-garg7@xxxxxx>

Reviewed-by: Siddharth Vadapalli <s-vadapalli@xxxxxx>

> ---
> drivers/pci/controller/pcie-apple.c | 2 +-
> include/linux/pci.h | 1 +
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
> index 2d92fc79f6dd..6bf9fe102e2f 100644
> --- a/drivers/pci/controller/pcie-apple.c
> +++ b/drivers/pci/controller/pcie-apple.c
> @@ -802,7 +802,7 @@ static void apple_pcie_disable_device(struct pci_host_bridge *bridge, struct pci
> u32 val;
>
> val = readl_relaxed(port_rid2sid_addr(port, idx));
> - if ((val & 0xffff) == rid) {
> + if ((val & PCI_RID_MASK) == rid) {
> apple_pcie_rid2sid_write(port, idx, 0);
> bitmap_release_region(port->sid_map, idx, 0);
> dev_dbg(&pdev->dev, "Released %x (%d)\n", val, idx);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 864775651c6f..e3d9730121c8 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -71,6 +71,7 @@
> #define PCI_DEVID(bus, devfn) ((((u16)(bus)) << 8) | (devfn))
> /* return bus from PCI devid = ((u16)bus_number) << 8) | devfn */
> #define PCI_BUS_NUM(x) (((x) >> 8) & 0xff)
> +#define PCI_RID_MASK 0xffff
>
> /* pci_slot represents a physical slot */
> struct pci_slot {

Regards,
Siddharth.