Skip to content

Commit 44aff8e

Browse files
jhovoldvinodkoul
authored andcommitted
phy: qcom-qmp-combo: 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 <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 6c7c449 commit 44aff8e

File tree

1 file changed

+27
-34
lines changed

1 file changed

+27
-34
lines changed

drivers/phy/qualcomm/phy-qcom-qmp-combo.c

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,9 +2148,10 @@ static const struct dev_pm_ops qmp_combo_pm_ops = {
21482148
qmp_combo_runtime_resume, NULL)
21492149
};
21502150

2151-
static int qmp_combo_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg)
2151+
static int qmp_combo_vreg_init(struct qmp_combo *qmp)
21522152
{
2153-
struct qmp_combo *qmp = dev_get_drvdata(dev);
2153+
const struct qmp_phy_cfg *cfg = qmp->cfg;
2154+
struct device *dev = qmp->dev;
21542155
int num = cfg->num_vregs;
21552156
int ret, i;
21562157

@@ -2180,9 +2181,10 @@ static int qmp_combo_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg
21802181
return 0;
21812182
}
21822183

2183-
static int qmp_combo_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg)
2184+
static int qmp_combo_reset_init(struct qmp_combo *qmp)
21842185
{
2185-
struct qmp_combo *qmp = dev_get_drvdata(dev);
2186+
const struct qmp_phy_cfg *cfg = qmp->cfg;
2187+
struct device *dev = qmp->dev;
21862188
int i;
21872189
int ret;
21882190

@@ -2201,9 +2203,10 @@ static int qmp_combo_reset_init(struct device *dev, const struct qmp_phy_cfg *cf
22012203
return 0;
22022204
}
22032205

2204-
static int qmp_combo_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg)
2206+
static int qmp_combo_clk_init(struct qmp_combo *qmp)
22052207
{
2206-
struct qmp_combo *qmp = dev_get_drvdata(dev);
2208+
const struct qmp_phy_cfg *cfg = qmp->cfg;
2209+
struct device *dev = qmp->dev;
22072210
int num = cfg->num_clks;
22082211
int i;
22092212

@@ -2468,15 +2471,12 @@ static int phy_dp_clks_register(struct qmp_combo *qmp, struct device_node *np)
24682471
return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np);
24692472
}
24702473

2471-
static int qmp_combo_create_dp(struct device *dev, struct device_node *np,
2472-
void __iomem *serdes, const struct qmp_phy_cfg *cfg)
2474+
static int qmp_combo_create_dp(struct qmp_combo *qmp, struct device_node *np)
24732475
{
2474-
struct qmp_combo *qmp = dev_get_drvdata(dev);
2476+
struct device *dev = qmp->dev;
24752477
struct phy *generic_phy;
24762478
int ret;
24772479

2478-
qmp->cfg = cfg;
2479-
qmp->dp_serdes = serdes;
24802480
/*
24812481
* Get memory resources from the DP child node:
24822482
* Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2;
@@ -2509,15 +2509,13 @@ static int qmp_combo_create_dp(struct device *dev, struct device_node *np,
25092509
return 0;
25102510
}
25112511

2512-
static int qmp_combo_create_usb(struct device *dev, struct device_node *np,
2513-
void __iomem *serdes, const struct qmp_phy_cfg *cfg)
2512+
static int qmp_combo_create_usb(struct qmp_combo *qmp, struct device_node *np)
25142513
{
2515-
struct qmp_combo *qmp = dev_get_drvdata(dev);
2514+
const struct qmp_phy_cfg *cfg = qmp->cfg;
2515+
struct device *dev = qmp->dev;
25162516
struct phy *generic_phy;
25172517
int ret;
25182518

2519-
qmp->cfg = cfg;
2520-
qmp->serdes = serdes;
25212519
/*
25222520
* Get memory resources from the USB child node:
25232521
* Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2;
@@ -2577,46 +2575,41 @@ static int qmp_combo_probe(struct platform_device *pdev)
25772575
struct device *dev = &pdev->dev;
25782576
struct device_node *dp_np, *usb_np;
25792577
struct phy_provider *phy_provider;
2580-
void __iomem *serdes;
2581-
void __iomem *usb_serdes;
2582-
void __iomem *dp_serdes = NULL;
2583-
const struct qmp_phy_cfg *cfg = NULL;
25842578
int ret;
25852579

25862580
qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL);
25872581
if (!qmp)
25882582
return -ENOMEM;
25892583

25902584
qmp->dev = dev;
2591-
dev_set_drvdata(dev, qmp);
25922585

2593-
cfg = of_device_get_match_data(dev);
2594-
if (!cfg)
2586+
qmp->cfg = of_device_get_match_data(dev);
2587+
if (!qmp->cfg)
25952588
return -EINVAL;
25962589

2597-
usb_serdes = serdes = devm_platform_ioremap_resource(pdev, 0);
2598-
if (IS_ERR(serdes))
2599-
return PTR_ERR(serdes);
2590+
qmp->serdes = devm_platform_ioremap_resource(pdev, 0);
2591+
if (IS_ERR(qmp->serdes))
2592+
return PTR_ERR(qmp->serdes);
26002593

26012594
qmp->dp_com = devm_platform_ioremap_resource(pdev, 1);
26022595
if (IS_ERR(qmp->dp_com))
26032596
return PTR_ERR(qmp->dp_com);
26042597

2605-
dp_serdes = devm_platform_ioremap_resource(pdev, 2);
2606-
if (IS_ERR(dp_serdes))
2607-
return PTR_ERR(dp_serdes);
2598+
qmp->dp_serdes = devm_platform_ioremap_resource(pdev, 2);
2599+
if (IS_ERR(qmp->dp_serdes))
2600+
return PTR_ERR(qmp->dp_serdes);
26082601

26092602
mutex_init(&qmp->phy_mutex);
26102603

2611-
ret = qmp_combo_clk_init(dev, cfg);
2604+
ret = qmp_combo_clk_init(qmp);
26122605
if (ret)
26132606
return ret;
26142607

2615-
ret = qmp_combo_reset_init(dev, cfg);
2608+
ret = qmp_combo_reset_init(qmp);
26162609
if (ret)
26172610
return ret;
26182611

2619-
ret = qmp_combo_vreg_init(dev, cfg);
2612+
ret = qmp_combo_vreg_init(qmp);
26202613
if (ret)
26212614
return ret;
26222615

@@ -2640,15 +2633,15 @@ static int qmp_combo_probe(struct platform_device *pdev)
26402633
*/
26412634
pm_runtime_forbid(dev);
26422635

2643-
ret = qmp_combo_create_usb(dev, usb_np, usb_serdes, cfg);
2636+
ret = qmp_combo_create_usb(qmp, usb_np);
26442637
if (ret)
26452638
goto err_node_put;
26462639

26472640
ret = phy_pipe_clk_register(qmp, usb_np);
26482641
if (ret)
26492642
goto err_node_put;
26502643

2651-
ret = qmp_combo_create_dp(dev, dp_np, dp_serdes, cfg);
2644+
ret = qmp_combo_create_dp(qmp, dp_np);
26522645
if (ret)
26532646
goto err_node_put;
26542647

0 commit comments

Comments
 (0)