Am Sonntag, den 31.03.2019, 21:25 -0700 schrieb Andrey Smirnov: > Simplify the code by incorporating left shifts into constant > defnitions as well as using FIELD_PREP/GENMASK. No functional change > intended. > > > Cc: Lorenzo Pieralisi <lorenzo.pieralisi@xxxxxxx> > > Cc: Bjorn Helgaas <bhelgaas@xxxxxxxxxx> > > Cc: Fabio Estevam <fabio.estevam@xxxxxxx> > > Cc: Chris Healy <cphealy@xxxxxxxxx> > > Cc: Lucas Stach <l.stach@xxxxxxxxxxxxxx> > > Cc: Leonard Crestez <leonard.crestez@xxxxxxx> > > Cc: "A.s. Dong" <aisheng.dong@xxxxxxx> > > Cc: Richard Zhu <hongxing.zhu@xxxxxxx> > Cc: linux-imx@xxxxxxx > Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx > Cc: linux-kernel@xxxxxxxxxxxxxxx > Cc: linux-pci@xxxxxxxxxxxxxxx > Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx> Reviewed-by: Lucas Stach <l.stach@xxxxxxxxxxxxxx> > --- > drivers/pci/controller/dwc/pci-imx6.c | 28 +++++++++++++-------------- > 1 file changed, 14 insertions(+), 14 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index b1f30b94fb30..a49e5e491e12 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -105,11 +105,11 @@ struct imx6_pcie { > #define PL_OFFSET 0x700 > > #define PCIE_PHY_CTRL (PL_OFFSET + 0x114) > -#define PCIE_PHY_CTRL_DATA_LOC 0 > -#define PCIE_PHY_CTRL_CAP_ADR_LOC 16 > -#define PCIE_PHY_CTRL_CAP_DAT_LOC 17 > -#define PCIE_PHY_CTRL_WR_LOC 18 > -#define PCIE_PHY_CTRL_RD_LOC 19 > > +#define PCIE_PHY_CTRL_DATA(x) FIELD_PREP(GENMASK(15, 0), (x)) > > +#define PCIE_PHY_CTRL_CAP_ADR BIT(16) > > +#define PCIE_PHY_CTRL_CAP_DAT BIT(17) > > +#define PCIE_PHY_CTRL_WR BIT(18) > > +#define PCIE_PHY_CTRL_RD BIT(19) > > #define PCIE_PHY_STAT (PL_OFFSET + 0x110) > #define PCIE_PHY_STAT_ACK_LOC 16 > @@ -178,17 +178,17 @@ static int pcie_phy_wait_ack(struct imx6_pcie *imx6_pcie, int addr) > > u32 val; > > int ret; > > > - val = addr << PCIE_PHY_CTRL_DATA_LOC; > > + val = PCIE_PHY_CTRL_DATA(addr); > > dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, val); > > > - val |= (0x1 << PCIE_PHY_CTRL_CAP_ADR_LOC); > > + val |= PCIE_PHY_CTRL_CAP_ADR; > > dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, val); > > > ret = pcie_phy_poll_ack(imx6_pcie, 1); > > if (ret) > > return ret; > > > - val = addr << PCIE_PHY_CTRL_DATA_LOC; > > + val = PCIE_PHY_CTRL_DATA(addr); > > dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, val); > > > return pcie_phy_poll_ack(imx6_pcie, 0); > @@ -206,7 +206,7 @@ static int pcie_phy_read(struct imx6_pcie *imx6_pcie, int addr, int *data) > > return ret; > > > /* assert Read signal */ > > - phy_ctl = 0x1 << PCIE_PHY_CTRL_RD_LOC; > > + phy_ctl = PCIE_PHY_CTRL_RD; > > dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, phy_ctl); > > > ret = pcie_phy_poll_ack(imx6_pcie, 1); > @@ -234,11 +234,11 @@ static int pcie_phy_write(struct imx6_pcie *imx6_pcie, int addr, int data) > > if (ret) > > return ret; > > > - var = data << PCIE_PHY_CTRL_DATA_LOC; > > + var = PCIE_PHY_CTRL_DATA(data); > > dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, var); > > > /* capture data */ > > - var |= (0x1 << PCIE_PHY_CTRL_CAP_DAT_LOC); > > + var |= PCIE_PHY_CTRL_CAP_DAT; > > dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, var); > > > ret = pcie_phy_poll_ack(imx6_pcie, 1); > @@ -246,7 +246,7 @@ static int pcie_phy_write(struct imx6_pcie *imx6_pcie, int addr, int data) > > return ret; > > > /* deassert cap data */ > > - var = data << PCIE_PHY_CTRL_DATA_LOC; > > + var = PCIE_PHY_CTRL_DATA(data); > > dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, var); > > > /* wait for ack de-assertion */ > @@ -255,7 +255,7 @@ static int pcie_phy_write(struct imx6_pcie *imx6_pcie, int addr, int data) > > return ret; > > > /* assert wr signal */ > > - var = 0x1 << PCIE_PHY_CTRL_WR_LOC; > > + var = PCIE_PHY_CTRL_WR; > > dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, var); > > > /* wait for ack */ > @@ -264,7 +264,7 @@ static int pcie_phy_write(struct imx6_pcie *imx6_pcie, int addr, int data) > > return ret; > > > /* deassert wr signal */ > > - var = data << PCIE_PHY_CTRL_DATA_LOC; > > + var = PCIE_PHY_CTRL_DATA(data); > > dw_pcie_writel_dbi(pci, PCIE_PHY_CTRL, var); > > > /* wait for ack de-assertion */