phy: qcom-qmp-usb: clean up probe initialisation

Stop abusing the driver data pointer and instead pass the driver state
structure directly to the initialisation helpers during probe.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20221028160435.26948-8-johan+linaro@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
Johan Hovold 2022-10-28 18:04:29 +02:00 committed by Vinod Koul
parent 8ec02ba849
commit 413db06c05

View File

@ -2250,9 +2250,10 @@ static const struct dev_pm_ops qmp_usb_pm_ops = {
qmp_usb_runtime_resume, NULL) qmp_usb_runtime_resume, NULL)
}; };
static int qmp_usb_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) static int qmp_usb_vreg_init(struct qmp_usb *qmp)
{ {
struct qmp_usb *qmp = dev_get_drvdata(dev); const struct qmp_phy_cfg *cfg = qmp->cfg;
struct device *dev = qmp->dev;
int num = cfg->num_vregs; int num = cfg->num_vregs;
int i; int i;
@ -2266,9 +2267,10 @@ static int qmp_usb_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg)
return devm_regulator_bulk_get(dev, num, qmp->vregs); return devm_regulator_bulk_get(dev, num, qmp->vregs);
} }
static int qmp_usb_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) static int qmp_usb_reset_init(struct qmp_usb *qmp)
{ {
struct qmp_usb *qmp = dev_get_drvdata(dev); const struct qmp_phy_cfg *cfg = qmp->cfg;
struct device *dev = qmp->dev;
int i; int i;
int ret; int ret;
@ -2287,9 +2289,10 @@ static int qmp_usb_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg)
return 0; return 0;
} }
static int qmp_usb_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) static int qmp_usb_clk_init(struct qmp_usb *qmp)
{ {
struct qmp_usb *qmp = dev_get_drvdata(dev); const struct qmp_phy_cfg *cfg = qmp->cfg;
struct device *dev = qmp->dev;
int num = cfg->num_clks; int num = cfg->num_clks;
int i; int i;
@ -2385,10 +2388,10 @@ static void __iomem *qmp_usb_iomap(struct device *dev, struct device_node *np,
return devm_of_iomap(dev, np, index, NULL); return devm_of_iomap(dev, np, index, NULL);
} }
static int qmp_usb_create(struct device *dev, struct device_node *np, static int qmp_usb_create(struct qmp_usb *qmp, struct device_node *np)
void __iomem *serdes, const struct qmp_phy_cfg *cfg)
{ {
struct qmp_usb *qmp = dev_get_drvdata(dev); const struct qmp_phy_cfg *cfg = qmp->cfg;
struct device *dev = qmp->dev;
struct phy *generic_phy; struct phy *generic_phy;
bool exclusive = true; bool exclusive = true;
int ret; int ret;
@ -2402,8 +2405,6 @@ static int qmp_usb_create(struct device *dev, struct device_node *np,
if (of_device_is_compatible(dev->of_node, "qcom,sm8350-qmp-usb3-uni-phy")) if (of_device_is_compatible(dev->of_node, "qcom,sm8350-qmp-usb3-uni-phy"))
exclusive = false; exclusive = false;
qmp->cfg = cfg;
qmp->serdes = serdes;
/* /*
* Get memory resources for the PHY: * Get memory resources for the PHY:
* Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2.
@ -2468,8 +2469,6 @@ static int qmp_usb_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *child; struct device_node *child;
struct phy_provider *phy_provider; struct phy_provider *phy_provider;
void __iomem *serdes;
const struct qmp_phy_cfg *cfg = NULL;
struct qmp_usb *qmp; struct qmp_usb *qmp;
int ret; int ret;
@ -2478,31 +2477,30 @@ static int qmp_usb_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
qmp->dev = dev; qmp->dev = dev;
dev_set_drvdata(dev, qmp);
cfg = of_device_get_match_data(dev); qmp->cfg = of_device_get_match_data(dev);
if (!cfg) if (!qmp->cfg)
return -EINVAL; return -EINVAL;
serdes = devm_platform_ioremap_resource(pdev, 0); qmp->serdes = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(serdes)) if (IS_ERR(qmp->serdes))
return PTR_ERR(serdes); return PTR_ERR(qmp->serdes);
if (cfg->has_phy_dp_com_ctrl) { if (qmp->cfg->has_phy_dp_com_ctrl) {
qmp->dp_com = devm_platform_ioremap_resource(pdev, 1); qmp->dp_com = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(qmp->dp_com)) if (IS_ERR(qmp->dp_com))
return PTR_ERR(qmp->dp_com); return PTR_ERR(qmp->dp_com);
} }
ret = qmp_usb_clk_init(dev, cfg); ret = qmp_usb_clk_init(qmp);
if (ret) if (ret)
return ret; return ret;
ret = qmp_usb_reset_init(dev, cfg); ret = qmp_usb_reset_init(qmp);
if (ret) if (ret)
return ret; return ret;
ret = qmp_usb_vreg_init(dev, cfg); ret = qmp_usb_vreg_init(qmp);
if (ret) if (ret)
return ret; return ret;
@ -2520,7 +2518,7 @@ static int qmp_usb_probe(struct platform_device *pdev)
*/ */
pm_runtime_forbid(dev); pm_runtime_forbid(dev);
ret = qmp_usb_create(dev, child, serdes, cfg); ret = qmp_usb_create(qmp, child);
if (ret) if (ret)
goto err_node_put; goto err_node_put;