On Mon, 11 Sep 2023 15:14:54 +0300 Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx> wrote: > Use FIELD_GET() to extract PCIe Negotiated Link Width field instead of > custom masking and shifting. > > While at it, also fix function's comment. > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx> > --- > drivers/infiniband/hw/hfi1/pcie.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c > index 08732e1ac966..d497e4c623c1 100644 > --- a/drivers/infiniband/hw/hfi1/pcie.c > +++ b/drivers/infiniband/hw/hfi1/pcie.c > @@ -3,6 +3,7 @@ > * Copyright(c) 2015 - 2019 Intel Corporation. > */ > > +#include <linux/bitfield.h> > #include <linux/pci.h> > #include <linux/io.h> > #include <linux/delay.h> > @@ -210,10 +211,10 @@ static u32 extract_speed(u16 linkstat) > return speed; > } > > -/* return the PCIe link speed from the given link status */ > +/* return the PCIe Link Width from the given link status */ > static u32 extract_width(u16 linkstat) > { > - return (linkstat & PCI_EXP_LNKSTA_NLW) >> PCI_EXP_LNKSTA_NLW_SHIFT; > + return FIELD_GET(PCI_EXP_LNKSTA_NLW, linkstat); The helper seems like overkill now. Maybe just push this code inline and drop the wrapper. I don't think the comment is necessary after that as we are putting it in a bus_width field and the register is obviously link status from the naming. dd->lbus_width = FIELD_GET(PCI_EXP_LINKSTA_NLW, linkstat); > } > > /* read the link status and set dd->{lbus_width,lbus_speed,lbus_info} */