mirror of https://github.com/torvalds/linux.git
PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional()
Replace manual get/enable logic with devm_regulator_get_enable_optional() to reduce boilerplate and improve error handling. This devm helper ensures the regulator is enabled during probe and automatically disabled when the platform device is freed. Also drop the redundant 'rockchip_pcie::vpcie3v3' pointer. Signed-off-by: Anand Moon <linux.amoon@gmail.com> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Link: https://patch.msgid.link/20250905112736.6401-1-linux.amoon@gmail.com
This commit is contained in:
parent
3a86608788
commit
c930b10f17
|
|
@ -82,7 +82,6 @@ struct rockchip_pcie {
|
||||||
unsigned int clk_cnt;
|
unsigned int clk_cnt;
|
||||||
struct reset_control *rst;
|
struct reset_control *rst;
|
||||||
struct gpio_desc *rst_gpio;
|
struct gpio_desc *rst_gpio;
|
||||||
struct regulator *vpcie3v3;
|
|
||||||
struct irq_domain *irq_domain;
|
struct irq_domain *irq_domain;
|
||||||
const struct rockchip_pcie_of_data *data;
|
const struct rockchip_pcie_of_data *data;
|
||||||
};
|
};
|
||||||
|
|
@ -652,22 +651,15 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* DON'T MOVE ME: must be enable before PHY init */
|
/* DON'T MOVE ME: must be enable before PHY init */
|
||||||
rockchip->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3");
|
ret = devm_regulator_get_enable_optional(dev, "vpcie3v3");
|
||||||
if (IS_ERR(rockchip->vpcie3v3)) {
|
if (ret < 0 && ret != -ENODEV)
|
||||||
if (PTR_ERR(rockchip->vpcie3v3) != -ENODEV)
|
return dev_err_probe(dev, ret,
|
||||||
return dev_err_probe(dev, PTR_ERR(rockchip->vpcie3v3),
|
"failed to enable vpcie3v3 regulator\n");
|
||||||
"failed to get vpcie3v3 regulator\n");
|
|
||||||
rockchip->vpcie3v3 = NULL;
|
|
||||||
} else {
|
|
||||||
ret = regulator_enable(rockchip->vpcie3v3);
|
|
||||||
if (ret)
|
|
||||||
return dev_err_probe(dev, ret,
|
|
||||||
"failed to enable vpcie3v3 regulator\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = rockchip_pcie_phy_init(rockchip);
|
ret = rockchip_pcie_phy_init(rockchip);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto disable_regulator;
|
return dev_err_probe(dev, ret,
|
||||||
|
"failed to initialize the phy\n");
|
||||||
|
|
||||||
ret = reset_control_deassert(rockchip->rst);
|
ret = reset_control_deassert(rockchip->rst);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
@ -700,9 +692,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
|
||||||
clk_bulk_disable_unprepare(rockchip->clk_cnt, rockchip->clks);
|
clk_bulk_disable_unprepare(rockchip->clk_cnt, rockchip->clks);
|
||||||
deinit_phy:
|
deinit_phy:
|
||||||
rockchip_pcie_phy_deinit(rockchip);
|
rockchip_pcie_phy_deinit(rockchip);
|
||||||
disable_regulator:
|
|
||||||
if (rockchip->vpcie3v3)
|
|
||||||
regulator_disable(rockchip->vpcie3v3);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue