Skip to content

Commit f46bfb1

Browse files
Hans ZhangMani-Sadhasivam
authored andcommitted
PCI: dwc: Return bool from link up check
PCIe link status check is supposed to return a boolean to indicate whether the link is up or not. So, modify the link_up callbacks and dw_pcie_link_up() function to return bool instead of int. Signed-off-by: Hans Zhang <[email protected]> [mani: commit message reword] Signed-off-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Niklas Cassel <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 286ed19 commit f46bfb1

18 files changed

+33
-43
lines changed

drivers/pci/controller/dwc/pci-dra7xx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ static u64 dra7xx_pcie_cpu_addr_fixup(struct dw_pcie *pci, u64 cpu_addr)
118118
return cpu_addr & DRA7XX_CPU_TO_BUS_ADDR;
119119
}
120120

121-
static int dra7xx_pcie_link_up(struct dw_pcie *pci)
121+
static bool dra7xx_pcie_link_up(struct dw_pcie *pci)
122122
{
123123
struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci);
124124
u32 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_PHY_CS);
125125

126-
return !!(reg & LINK_UP);
126+
return reg & LINK_UP;
127127
}
128128

129129
static void dra7xx_pcie_stop_link(struct dw_pcie *pci)

drivers/pci/controller/dwc/pci-exynos.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ static struct pci_ops exynos_pci_ops = {
209209
.write = exynos_pcie_wr_own_conf,
210210
};
211211

212-
static int exynos_pcie_link_up(struct dw_pcie *pci)
212+
static bool exynos_pcie_link_up(struct dw_pcie *pci)
213213
{
214214
struct exynos_pcie *ep = to_exynos_pcie(pci);
215215
u32 val = exynos_pcie_readl(ep->elbi_base, PCIE_ELBI_RDLH_LINKUP);
216216

217-
return (val & PCIE_ELBI_XMLH_LINKUP);
217+
return val & PCIE_ELBI_XMLH_LINKUP;
218218
}
219219

220220
static int exynos_pcie_host_init(struct dw_pcie_rp *pp)

drivers/pci/controller/dwc/pci-keystone.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,12 @@ static struct pci_ops ks_pcie_ops = {
492492
* @pci: A pointer to the dw_pcie structure which holds the DesignWare PCIe host
493493
* controller driver information.
494494
*/
495-
static int ks_pcie_link_up(struct dw_pcie *pci)
495+
static bool ks_pcie_link_up(struct dw_pcie *pci)
496496
{
497497
u32 val;
498498

499499
val = dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG0);
500-
val &= PORT_LOGIC_LTSSM_STATE_MASK;
501-
return (val == PORT_LOGIC_LTSSM_STATE_L0);
500+
return (val & PORT_LOGIC_LTSSM_STATE_MASK) == PORT_LOGIC_LTSSM_STATE_L0;
502501
}
503502

504503
static void ks_pcie_stop_link(struct dw_pcie *pci)

drivers/pci/controller/dwc/pci-meson.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ static struct pci_ops meson_pci_ops = {
335335
.write = pci_generic_config_write,
336336
};
337337

338-
static int meson_pcie_link_up(struct dw_pcie *pci)
338+
static bool meson_pcie_link_up(struct dw_pcie *pci)
339339
{
340340
struct meson_pcie *mp = to_meson_pcie(pci);
341341
struct device *dev = pci->dev;
@@ -363,15 +363,15 @@ static int meson_pcie_link_up(struct dw_pcie *pci)
363363
dev_dbg(dev, "speed_okay\n");
364364

365365
if (smlh_up && rdlh_up && ltssm_up && speed_okay)
366-
return 1;
366+
return true;
367367

368368
cnt++;
369369

370370
udelay(10);
371371
} while (cnt < WAIT_LINKUP_TIMEOUT);
372372

373373
dev_err(dev, "error: wait linkup timeout\n");
374-
return 0;
374+
return false;
375375
}
376376

377377
static int meson_pcie_host_init(struct dw_pcie_rp *pp)

drivers/pci/controller/dwc/pcie-armada8k.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,18 @@ static int armada8k_pcie_setup_phys(struct armada8k_pcie *pcie)
139139
return ret;
140140
}
141141

142-
static int armada8k_pcie_link_up(struct dw_pcie *pci)
142+
static bool armada8k_pcie_link_up(struct dw_pcie *pci)
143143
{
144144
u32 reg;
145145
u32 mask = PCIE_GLB_STS_RDLH_LINK_UP | PCIE_GLB_STS_PHY_LINK_UP;
146146

147147
reg = dw_pcie_readl_dbi(pci, PCIE_GLOBAL_STATUS_REG);
148148

149149
if ((reg & mask) == mask)
150-
return 1;
150+
return true;
151151

152152
dev_dbg(pci->dev, "No link detected (Global-Status: 0x%08x).\n", reg);
153-
return 0;
153+
return false;
154154
}
155155

156156
static int armada8k_pcie_start_link(struct dw_pcie *pci)

drivers/pci/controller/dwc/pcie-designware.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci)
711711
}
712712
EXPORT_SYMBOL_GPL(dw_pcie_wait_for_link);
713713

714-
int dw_pcie_link_up(struct dw_pcie *pci)
714+
bool dw_pcie_link_up(struct dw_pcie *pci)
715715
{
716716
u32 val;
717717

drivers/pci/controller/dwc/pcie-designware.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ struct dw_pcie_ops {
462462
size_t size, u32 val);
463463
void (*write_dbi2)(struct dw_pcie *pcie, void __iomem *base, u32 reg,
464464
size_t size, u32 val);
465-
int (*link_up)(struct dw_pcie *pcie);
465+
bool (*link_up)(struct dw_pcie *pcie);
466466
enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie);
467467
int (*start_link)(struct dw_pcie *pcie);
468468
void (*stop_link)(struct dw_pcie *pcie);
@@ -537,7 +537,7 @@ int dw_pcie_write(void __iomem *addr, int size, u32 val);
537537
u32 dw_pcie_read_dbi(struct dw_pcie *pci, u32 reg, size_t size);
538538
void dw_pcie_write_dbi(struct dw_pcie *pci, u32 reg, size_t size, u32 val);
539539
void dw_pcie_write_dbi2(struct dw_pcie *pci, u32 reg, size_t size, u32 val);
540-
int dw_pcie_link_up(struct dw_pcie *pci);
540+
bool dw_pcie_link_up(struct dw_pcie *pci);
541541
void dw_pcie_upconfig_setup(struct dw_pcie *pci);
542542
int dw_pcie_wait_for_link(struct dw_pcie *pci);
543543
int dw_pcie_prog_outbound_atu(struct dw_pcie *pci,

drivers/pci/controller/dwc/pcie-dw-rockchip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void rockchip_pcie_disable_ltssm(struct rockchip_pcie *rockchip)
183183
PCIE_CLIENT_GENERAL_CON);
184184
}
185185

186-
static int rockchip_pcie_link_up(struct dw_pcie *pci)
186+
static bool rockchip_pcie_link_up(struct dw_pcie *pci)
187187
{
188188
struct rockchip_pcie *rockchip = to_rockchip_pcie(pci);
189189
u32 val = rockchip_pcie_get_ltssm(rockchip);

drivers/pci/controller/dwc/pcie-histb.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static struct pci_ops histb_pci_ops = {
151151
.write = histb_pcie_wr_own_conf,
152152
};
153153

154-
static int histb_pcie_link_up(struct dw_pcie *pci)
154+
static bool histb_pcie_link_up(struct dw_pcie *pci)
155155
{
156156
struct histb_pcie *hipcie = to_histb_pcie(pci);
157157
u32 regval;
@@ -160,11 +160,8 @@ static int histb_pcie_link_up(struct dw_pcie *pci)
160160
regval = histb_pcie_readl(hipcie, PCIE_SYS_STAT0);
161161
status = histb_pcie_readl(hipcie, PCIE_SYS_STAT4);
162162
status &= PCIE_LTSSM_STATE_MASK;
163-
if ((regval & PCIE_XMLH_LINK_UP) && (regval & PCIE_RDLH_LINK_UP) &&
164-
(status == PCIE_LTSSM_STATE_ACTIVE))
165-
return 1;
166-
167-
return 0;
163+
return ((regval & PCIE_XMLH_LINK_UP) && (regval & PCIE_RDLH_LINK_UP) &&
164+
(status == PCIE_LTSSM_STATE_ACTIVE));
168165
}
169166

170167
static int histb_pcie_start_link(struct dw_pcie *pci)

drivers/pci/controller/dwc/pcie-keembay.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void keembay_pcie_ltssm_set(struct keembay_pcie *pcie, bool enable)
101101
writel(val, pcie->apb_base + PCIE_REGS_PCIE_APP_CNTRL);
102102
}
103103

104-
static int keembay_pcie_link_up(struct dw_pcie *pci)
104+
static bool keembay_pcie_link_up(struct dw_pcie *pci)
105105
{
106106
struct keembay_pcie *pcie = dev_get_drvdata(pci->dev);
107107
u32 val;

0 commit comments

Comments
 (0)