Merge "icnss2: Add code to handle vreg and clk resources"

This commit is contained in:
qctecmdr 2020-06-12 13:41:27 -07:00 committed by Gerrit - the friendly Code Review server
commit 01944e4a8a
2 changed files with 13 additions and 46 deletions

View file

@ -2870,7 +2870,7 @@ static int icnss_probe(struct platform_device *pdev)
if (!of_id || !of_id->data) {
icnss_pr_err("Failed to find of match device!\n");
ret = -ENODEV;
goto out;
goto out_reset_drvdata;
}
device_id = of_id->data;
@ -2894,15 +2894,15 @@ static int icnss_probe(struct platform_device *pdev)
ret = icnss_resource_parse(priv);
if (ret)
goto out;
goto out_reset_drvdata;
ret = icnss_msa_dt_parse(priv);
if (ret)
goto out;
goto out_free_resources;
ret = icnss_smmu_dt_parse(priv);
if (ret)
goto out;
goto out_free_resources;
spin_lock_init(&priv->event_lock);
spin_lock_init(&priv->on_off_lock);
@ -2965,9 +2965,10 @@ static int icnss_probe(struct platform_device *pdev)
destroy_workqueue(priv->event_wq);
smmu_cleanup:
priv->iommu_domain = NULL;
out:
out_free_resources:
icnss_put_resources(priv);
out_reset_drvdata:
dev_set_drvdata(dev, NULL);
return ret;
}
@ -3004,6 +3005,8 @@ static int icnss_remove(struct platform_device *pdev)
icnss_hw_power_off(priv);
icnss_put_resources(priv);
dev_set_drvdata(&pdev->dev, NULL);
return 0;

View file

@ -138,16 +138,6 @@ static int icnss_get_vreg_single(struct icnss_priv *priv,
return ret;
}
static void icnss_put_vreg_single(struct icnss_priv *priv,
struct icnss_vreg_info *vreg)
{
struct device *dev = &priv->pdev->dev;
icnss_pr_dbg("Put regulator: %s\n", vreg->cfg.name);
devm_regulator_put(vreg->reg);
devm_kfree(dev, vreg);
}
static int icnss_vreg_on_single(struct icnss_vreg_info *vreg)
{
int ret = 0;
@ -309,13 +299,10 @@ int icnss_get_vreg(struct icnss_priv *priv)
memcpy(&vreg->cfg, &vreg_cfg[i], sizeof(vreg->cfg));
ret = icnss_get_vreg_single(priv, vreg);
if (ret != 0) {
if (ret == -ENODEV) {
devm_kfree(dev, vreg);
if (ret == -ENODEV)
continue;
} else {
devm_kfree(dev, vreg);
else
return ret;
}
}
list_add_tail(&vreg->list, vreg_list);
}
@ -332,9 +319,6 @@ void icnss_put_vreg(struct icnss_priv *priv)
vreg = list_first_entry(vreg_list,
struct icnss_vreg_info, list);
list_del(&vreg->list);
if (IS_ERR_OR_NULL(vreg->reg))
continue;
icnss_put_vreg_single(priv, vreg);
}
}
@ -422,15 +406,6 @@ int icnss_get_clk_single(struct icnss_priv *priv,
return 0;
}
static void icnss_put_clk_single(struct icnss_priv *priv,
struct icnss_clk_info *clk_info)
{
struct device *dev = &priv->pdev->dev;
icnss_pr_dbg("Put clock: %s\n", clk_info->cfg.name);
devm_clk_put(dev, clk_info->clk);
}
static int icnss_clk_on_single(struct icnss_clk_info *clk_info)
{
int ret;
@ -520,13 +495,10 @@ int icnss_get_clk(struct icnss_priv *priv)
sizeof(clk_info->cfg));
ret = icnss_get_clk_single(priv, clk_info);
if (ret != 0) {
if (clk_info->cfg.required) {
devm_kfree(dev, clk_info);
if (clk_info->cfg.required)
goto cleanup;
} else {
devm_kfree(dev, clk_info);
else
continue;
}
}
list_add_tail(&clk_info->list, clk_list);
}
@ -538,10 +510,6 @@ int icnss_get_clk(struct icnss_priv *priv)
clk_info = list_first_entry(clk_list, struct icnss_clk_info,
list);
list_del(&clk_info->list);
if (IS_ERR_OR_NULL(clk_info->clk))
continue;
icnss_put_clk_single(priv, clk_info);
devm_kfree(dev, clk_info);
}
return ret;
@ -563,10 +531,6 @@ void icnss_put_clk(struct icnss_priv *priv)
clk_info = list_first_entry(clk_list, struct icnss_clk_info,
list);
list_del(&clk_info->list);
if (IS_ERR_OR_NULL(clk_info->clk))
continue;
icnss_put_clk_single(priv, clk_info);
devm_kfree(dev, clk_info);
}
}