Re: [PATCH 3/5] PCI: pci-bridge-emul: Convert to GENMASK and BIT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2020-04-16 at 00:30 -0700, Christoph Hellwig wrote:
> On Tue, Apr 14, 2020 at 04:30:03PM -0400, Jon Derrick wrote:
> > In order to make pci-bridge-emul easier to keep up-to-date with new PCIe
> > features, convert all named register bits to GENMASK and BIT pairs. This
> > patch doesn't alter any of the PCI configuration space as these bits are
> > fully defined.
> > 
> > Signed-off-by: Jon Derrick <jonathan.derrick@xxxxxxxxx>
> > ---
> >  drivers/pci/pci-bridge-emul.c | 17 ++++++-----------
> >  1 file changed, 6 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/pci/pci-bridge-emul.c b/drivers/pci/pci-bridge-emul.c
> > index c00c30ffb198..bbcccadca85e 100644
> > --- a/drivers/pci/pci-bridge-emul.c
> > +++ b/drivers/pci/pci-bridge-emul.c
> > @@ -221,11 +221,8 @@ static const struct pci_bridge_reg_behavior pcie_cap_regs_behavior[] = {
> >  		 * as reserved bits.
> >  		 */
> >  		.rw = GENMASK(12, 0),
> > -		.w1c = (PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD |
> > -			PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC |
> > -			PCI_EXP_SLTSTA_CC | PCI_EXP_SLTSTA_DLLSC) << 16,
> > -		.ro = (PCI_EXP_SLTSTA_MRLSS | PCI_EXP_SLTSTA_PDS |
> > -		       PCI_EXP_SLTSTA_EIS) << 16,
> > +		.w1c = (BIT(8) | GENMASK(4, 0)) << 16,
> > +		.ro = GENMASK(7, 5) << 16,
> 
> FYI, I find the previous version a lot more readable.  Or rather I find
> it readable while the new one looks like intentionally obsfucated
> garbage to me.

Well I guess that's entirely subjective. But I do think if all the
existing BIT and GENMASK were converted to named registers instead, it
would be a lot easier to overlook mistakes.




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux