Message ID | 20231010204436.1000644-8-helgaas@kernel.org (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Bjorn Helgaas |
Headers | show |
Series | PCI: Use FIELD_GET() and FIELD_PREP() | expand |
On Tue, 10 Oct 2023 15:44:33 -0500 Bjorn Helgaas <helgaas@kernel.org> wrote: > From: Bjorn Helgaas <bhelgaas@google.com> > > Use FIELD_GET() to remove dependences on the field position, i.e., the > shift value. No functional change intended. > > Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > --- > drivers/pci/pcie/pme.c | 4 +++- > include/uapi/linux/pci_regs.h | 1 + > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c > index ef8ce436ead9..a2daebd9806c 100644 > --- a/drivers/pci/pcie/pme.c > +++ b/drivers/pci/pcie/pme.c > @@ -9,6 +9,7 @@ > > #define dev_fmt(fmt) "PME: " fmt > > +#include <linux/bitfield.h> > #include <linux/pci.h> > #include <linux/kernel.h> > #include <linux/errno.h> > @@ -235,7 +236,8 @@ static void pcie_pme_work_fn(struct work_struct *work) > pcie_clear_root_pme_status(port); > > spin_unlock_irq(&data->lock); > - pcie_pme_handle_request(port, rtsta & 0xffff); > + pcie_pme_handle_request(port, > + FIELD_GET(PCI_EXP_RTSTA_PME_RQ_ID, rtsta)); > spin_lock_irq(&data->lock); > > continue; > diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h > index e97a06b50f95..9fb8a69241f4 100644 > --- a/include/uapi/linux/pci_regs.h > +++ b/include/uapi/linux/pci_regs.h > @@ -637,6 +637,7 @@ > #define PCI_EXP_RTCAP 0x1e /* Root Capabilities */ > #define PCI_EXP_RTCAP_CRSVIS 0x0001 /* CRS Software Visibility capability */ > #define PCI_EXP_RTSTA 0x20 /* Root Status */ > +#define PCI_EXP_RTSTA_PME_RQ_ID 0x0000ffff /* PME Requester ID */ > #define PCI_EXP_RTSTA_PME 0x00010000 /* PME status */ > #define PCI_EXP_RTSTA_PENDING 0x00020000 /* PME pending */ > /*
On Tue, 10 Oct 2023, Bjorn Helgaas wrote: > From: Bjorn Helgaas <bhelgaas@google.com> > > Use FIELD_GET() to remove dependences on the field position, i.e., the > shift value. No functional change intended. > > Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> > --- > drivers/pci/pcie/pme.c | 4 +++- > include/uapi/linux/pci_regs.h | 1 + > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c > index ef8ce436ead9..a2daebd9806c 100644 > --- a/drivers/pci/pcie/pme.c > +++ b/drivers/pci/pcie/pme.c > @@ -9,6 +9,7 @@ > > #define dev_fmt(fmt) "PME: " fmt > > +#include <linux/bitfield.h> > #include <linux/pci.h> > #include <linux/kernel.h> > #include <linux/errno.h> > @@ -235,7 +236,8 @@ static void pcie_pme_work_fn(struct work_struct *work) > pcie_clear_root_pme_status(port); > > spin_unlock_irq(&data->lock); > - pcie_pme_handle_request(port, rtsta & 0xffff); > + pcie_pme_handle_request(port, > + FIELD_GET(PCI_EXP_RTSTA_PME_RQ_ID, rtsta)); > spin_lock_irq(&data->lock); > > continue; > diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h > index e97a06b50f95..9fb8a69241f4 100644 > --- a/include/uapi/linux/pci_regs.h > +++ b/include/uapi/linux/pci_regs.h > @@ -637,6 +637,7 @@ > #define PCI_EXP_RTCAP 0x1e /* Root Capabilities */ > #define PCI_EXP_RTCAP_CRSVIS 0x0001 /* CRS Software Visibility capability */ > #define PCI_EXP_RTSTA 0x20 /* Root Status */ > +#define PCI_EXP_RTSTA_PME_RQ_ID 0x0000ffff /* PME Requester ID */ > #define PCI_EXP_RTSTA_PME 0x00010000 /* PME status */ > #define PCI_EXP_RTSTA_PENDING 0x00020000 /* PME pending */ Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> (I'd have used REQ myself but it seems both forms are commonly used by the existing defines.)
diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c index ef8ce436ead9..a2daebd9806c 100644 --- a/drivers/pci/pcie/pme.c +++ b/drivers/pci/pcie/pme.c @@ -9,6 +9,7 @@ #define dev_fmt(fmt) "PME: " fmt +#include <linux/bitfield.h> #include <linux/pci.h> #include <linux/kernel.h> #include <linux/errno.h> @@ -235,7 +236,8 @@ static void pcie_pme_work_fn(struct work_struct *work) pcie_clear_root_pme_status(port); spin_unlock_irq(&data->lock); - pcie_pme_handle_request(port, rtsta & 0xffff); + pcie_pme_handle_request(port, + FIELD_GET(PCI_EXP_RTSTA_PME_RQ_ID, rtsta)); spin_lock_irq(&data->lock); continue; diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index e97a06b50f95..9fb8a69241f4 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -637,6 +637,7 @@ #define PCI_EXP_RTCAP 0x1e /* Root Capabilities */ #define PCI_EXP_RTCAP_CRSVIS 0x0001 /* CRS Software Visibility capability */ #define PCI_EXP_RTSTA 0x20 /* Root Status */ +#define PCI_EXP_RTSTA_PME_RQ_ID 0x0000ffff /* PME Requester ID */ #define PCI_EXP_RTSTA_PME 0x00010000 /* PME status */ #define PCI_EXP_RTSTA_PENDING 0x00020000 /* PME pending */ /*