Commit 018dfc99 authored by Johan Hovold's avatar Johan Hovold Committed by Vinod Koul
Browse files

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



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

Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20221024090041.19574-5-johan+linaro@kernel.org


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent cb2c3d2e
Loading
Loading
Loading
Loading
+17 −20
Original line number Diff line number Diff line
@@ -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;