Skip to content

Commit d523347

Browse files
Zhang Zekunkwilczynski
authored andcommitted
PCI: kirin: Tidy up _probe() related function with dev_err_probe()
The combination of dev_err() and the returned error code could be replaced by dev_err_probe() in driver's probe function. Thus, convert the code to use dev_err_probe() to make code simpler. Suggested-by: Jonathan Cameron <[email protected]> Signed-off-by: Zhang Zekun <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Link: https://lore.kernel.org/r/[email protected] [kwilczynski: commit log, return -ETIMEDOUT from hi3660_pcie_phy_start() rather than -EINVAL for when the PIPE clock fails to become stable, drop redundant dev->of_node NULL check] Signed-off-by: Krzysztof Wilczyński <[email protected]>
1 parent 9a0f3c5 commit d523347

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

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

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,9 @@ static int hi3660_pcie_phy_start(struct hi3660_pcie_phy *phy)
216216

217217
usleep_range(PIPE_CLK_WAIT_MIN, PIPE_CLK_WAIT_MAX);
218218
reg_val = kirin_apb_phy_readl(phy, PCIE_APB_PHY_STATUS0);
219-
if (reg_val & PIPE_CLK_STABLE) {
220-
dev_err(dev, "PIPE clk is not stable\n");
221-
return -EINVAL;
222-
}
219+
if (reg_val & PIPE_CLK_STABLE)
220+
return dev_err_probe(dev, -ETIMEDOUT,
221+
"PIPE clk is not stable\n");
223222

224223
return 0;
225224
}
@@ -371,10 +370,9 @@ static int kirin_pcie_get_gpio_enable(struct kirin_pcie *pcie,
371370
if (ret < 0)
372371
return 0;
373372

374-
if (ret > MAX_PCI_SLOTS) {
375-
dev_err(dev, "Too many GPIO clock requests!\n");
376-
return -EINVAL;
377-
}
373+
if (ret > MAX_PCI_SLOTS)
374+
return dev_err_probe(dev, -EINVAL,
375+
"Too many GPIO clock requests!\n");
378376

379377
pcie->n_gpio_clkreq = ret;
380378

@@ -420,17 +418,16 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie,
420418
"unable to get a valid reset gpio\n");
421419
}
422420

423-
if (pcie->num_slots + 1 >= MAX_PCI_SLOTS) {
424-
dev_err(dev, "Too many PCI slots!\n");
425-
return -EINVAL;
426-
}
421+
if (pcie->num_slots + 1 >= MAX_PCI_SLOTS)
422+
return dev_err_probe(dev, -EINVAL,
423+
"Too many PCI slots!\n");
424+
427425
pcie->num_slots++;
428426

429427
ret = of_pci_get_devfn(child);
430-
if (ret < 0) {
431-
dev_err(dev, "failed to parse devfn: %d\n", ret);
432-
return ret;
433-
}
428+
if (ret < 0)
429+
return dev_err_probe(dev, ret,
430+
"failed to parse devfn\n");
434431

435432
slot = PCI_SLOT(ret);
436433

@@ -725,16 +722,9 @@ static int kirin_pcie_probe(struct platform_device *pdev)
725722
struct dw_pcie *pci;
726723
int ret;
727724

728-
if (!dev->of_node) {
729-
dev_err(dev, "NULL node\n");
730-
return -EINVAL;
731-
}
732-
733725
data = of_device_get_match_data(dev);
734-
if (!data) {
735-
dev_err(dev, "OF data missing\n");
736-
return -EINVAL;
737-
}
726+
if (!data)
727+
return dev_err_probe(dev, -EINVAL, "OF data missing\n");
738728

739729
kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), GFP_KERNEL);
740730
if (!kirin_pcie)

0 commit comments

Comments
 (0)