Skip to content

Commit b5e4417

Browse files
jamesequinlankwilczynski
authored andcommitted
PCI: brcmstb: Do not assume that register field starts at LSB
When setting the LNKCAP and LNKCTL2 register fields, it was assumed that the field started at the LSB of the register. Although the masks do indeed start at the LSB, and this will probably not change, it is prudent to use a method that makes no assumption about the mask's placement in the register. Thus, use the u{16,32}p_replace_bits() helpers since they are already wildly used in this driver. Signed-off-by: Jim Quinlan <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] [kwilczynski: commit log] Signed-off-by: Krzysztof Wilczyński <[email protected]>
1 parent 0c97321 commit b5e4417

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/pci/controller/pcie-brcmstb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,10 @@ static void brcm_pcie_set_gen(struct brcm_pcie *pcie, int gen)
415415
u16 lnkctl2 = readw(pcie->base + BRCM_PCIE_CAP_REGS + PCI_EXP_LNKCTL2);
416416
u32 lnkcap = readl(pcie->base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
417417

418-
lnkcap = (lnkcap & ~PCI_EXP_LNKCAP_SLS) | gen;
418+
u32p_replace_bits(&lnkcap, gen, PCI_EXP_LNKCAP_SLS);
419419
writel(lnkcap, pcie->base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
420420

421-
lnkctl2 = (lnkctl2 & ~0xf) | gen;
421+
u16p_replace_bits(&lnkctl2, gen, PCI_EXP_LNKCTL2_TLS);
422422
writew(lnkctl2, pcie->base + BRCM_PCIE_CAP_REGS + PCI_EXP_LNKCTL2);
423423
}
424424

0 commit comments

Comments
 (0)