[PATCH 04/10] phy: qcom-qmp-ufs: clean up probe initialisation

From: Johan Hovold
Date: Mon Oct 24 2022 - 05:02:04 EST


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

Signed-off-by: Johan Hovold <johan+linaro@xxxxxxxxxx>
---
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 37 ++++++++++++-------------
1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c
index 25744b3576f3..057f9a3fdd6d 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c
@@ -945,9 +945,10 @@ static int qmp_ufs_disable(struct phy *phy)
return qmp_ufs_exit(phy);
}

-static int qmp_ufs_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg)
+static int qmp_ufs_vreg_init(struct qmp_ufs *qmp)
{
- struct qmp_ufs *qmp = dev_get_drvdata(dev);
+ const struct qmp_phy_cfg *cfg = qmp->cfg;
+ struct device *dev = qmp->dev;
int num = cfg->num_vregs;
int i;

@@ -961,9 +962,10 @@ static int qmp_ufs_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg)
return devm_regulator_bulk_get(dev, num, qmp->vregs);
}

-static int qmp_ufs_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg)
+static int qmp_ufs_clk_init(struct qmp_ufs *qmp)
{
- struct qmp_ufs *qmp = dev_get_drvdata(dev);
+ const struct qmp_phy_cfg *cfg = qmp->cfg;
+ struct device *dev = qmp->dev;
int num = cfg->num_clks;
int i;

@@ -983,15 +985,13 @@ static const struct phy_ops qcom_qmp_ufs_ops = {
.owner = THIS_MODULE,
};

-static int qmp_ufs_create(struct device *dev, struct device_node *np,
- void __iomem *serdes, const struct qmp_phy_cfg *cfg)
+static int qmp_ufs_create(struct qmp_ufs *qmp, struct device_node *np)
{
- struct qmp_ufs *qmp = dev_get_drvdata(dev);
+ const struct qmp_phy_cfg *cfg = qmp->cfg;
+ struct device *dev = qmp->dev;
struct phy *generic_phy;
int ret;

- qmp->cfg = cfg;
- qmp->serdes = serdes;
/*
* Get memory resources for the PHY:
* Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2.
@@ -1045,8 +1045,6 @@ static int qmp_ufs_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct device_node *child;
struct phy_provider *phy_provider;
- void __iomem *serdes;
- const struct qmp_phy_cfg *cfg = NULL;
struct qmp_ufs *qmp;
int ret;

@@ -1055,21 +1053,20 @@ static int qmp_ufs_probe(struct platform_device *pdev)
return -ENOMEM;

qmp->dev = dev;
- dev_set_drvdata(dev, qmp);

- cfg = of_device_get_match_data(dev);
- if (!cfg)
+ qmp->cfg = of_device_get_match_data(dev);
+ if (!qmp->cfg)
return -EINVAL;

- serdes = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(serdes))
- return PTR_ERR(serdes);
+ qmp->serdes = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(qmp->serdes))
+ return PTR_ERR(qmp->serdes);

- ret = qmp_ufs_clk_init(dev, cfg);
+ ret = qmp_ufs_clk_init(qmp);
if (ret)
return ret;

- ret = qmp_ufs_vreg_init(dev, cfg);
+ ret = qmp_ufs_vreg_init(qmp);
if (ret)
return ret;

@@ -1077,7 +1074,7 @@ static int qmp_ufs_probe(struct platform_device *pdev)
if (!child)
return -EINVAL;

- ret = qmp_ufs_create(dev, child, serdes, cfg);
+ ret = qmp_ufs_create(qmp, child);
if (ret)
goto err_node_put;

--
2.37.3