[PATCH v4 4/6] memory: mediatek: Add SMI driver

Yong Wu yong.wu at mediatek.com
Wed Aug 12 05:39:34 PDT 2015


On Tue, 2015-08-11 at 16:56 +0200, Joerg Roedel wrote:
> On Mon, Aug 03, 2015 at 06:21:17PM +0800, Yong Wu wrote:
> > +static int mtk_smi_common_get(struct device *smidev)
> > +{
> > +	struct mtk_smi_common *smipriv = dev_get_drvdata(smidev);
> > +	int ret;
> > +
> > +	ret = pm_runtime_get_sync(smidev);
> > +	if (ret < 0)
> > +		return ret;
> > +
> > +	ret = clk_prepare_enable(smipriv->clk_apb);
> > +	if (ret) {
> > +		dev_err(smidev, "Failed to enable the apb clock\n");
> > +		goto err_put_pm;
> > +	}
> > +	ret = clk_prepare_enable(smipriv->clk_smi);
> > +	if (ret) {
> > +		dev_err(smidev, "Failed to enable the smi clock\n");
> > +		goto err_disable_apb;
> > +	}
> > +	return ret;
> > +
> > +err_disable_apb:
> > +	clk_disable_unprepare(smipriv->clk_apb);
> > +err_put_pm:
> > +	pm_runtime_put(smidev);
> > +	return ret;
> > +}
> 
> [...]
> 
> > +int mtk_smi_larb_get(struct device *larbdev)
> > +{
> > +	struct mtk_smi_larb *larbpriv = dev_get_drvdata(larbdev);
> > +	struct mtk_larb_mmu *mmucfg = larbdev->archdata.iommu;
> > +	int ret;
> > +
> > +	ret = mtk_smi_common_get(larbpriv->smi);
> > +	if (ret)
> > +		return ret;
> > +
> > +	ret = pm_runtime_get_sync(larbdev);
> > +	if (ret < 0)
> > +		goto err_put_smicommon;
> > +
> > +	ret = clk_prepare_enable(larbpriv->clk_apb);
> > +	if (ret) {
> > +		dev_err(larbdev, "Failed to enable the apb clock\n");
> > +		goto err_put_pm;
> > +	}
> > +
> > +	ret = clk_prepare_enable(larbpriv->clk_smi);
> > +	if (ret) {
> > +		dev_err(larbdev, "Failed to enable the smi clock\n");
> > +		goto err_disable_apb;
> > +	}
> 
> The clock enablement looks similar to the function above, maybe move it
> to a helper function?

Thanks. I will improve it in next version.

> 
> 
> 	Joerg
> 





More information about the Linux-mediatek mailing list