diff --git a/drivers/video/rockchip/mpp/mpp_common.c b/drivers/video/rockchip/mpp/mpp_common.c index da2435f3e76e..ef4d2abb3ea0 100644 --- a/drivers/video/rockchip/mpp/mpp_common.c +++ b/drivers/video/rockchip/mpp/mpp_common.c @@ -602,17 +602,19 @@ static int mpp_attach_service(struct mpp_dev *mpp, struct device *dev) } pdev = of_find_device_by_node(np); + of_node_put(np); if (!pdev) { dev_err(dev, "failed to get mpp service from node\n"); ret = -ENODEV; - goto fail; + goto err_put_pdev; } + mpp->pdev_srv = pdev; mpp->srv = platform_get_drvdata(pdev); if (!mpp->srv) { dev_err(&pdev->dev, "failed attach service\n"); ret = -EINVAL; - goto fail; + goto err_put_pdev; } of_property_read_u32(dev->of_node, @@ -621,7 +623,7 @@ static int mpp_attach_service(struct mpp_dev *mpp, struct device *dev) dev_err(dev, "rockchip,taskqueue-node %d must less than %d\n", taskqueue_node, mpp->srv->taskqueue_cnt); ret = -ENODEV; - goto fail; + goto err_put_pdev; } of_property_read_u32(dev->of_node, @@ -630,7 +632,7 @@ static int mpp_attach_service(struct mpp_dev *mpp, struct device *dev) dev_err(dev, "rockchip,resetgroup-node %d must less than %d\n", reset_group_node, mpp->srv->reset_group_cnt); ret = -ENODEV; - goto fail; + goto err_put_pdev; } device_lock(&pdev->dev); @@ -642,10 +644,12 @@ static int mpp_attach_service(struct mpp_dev *mpp, struct device *dev) mpp->reset_group = mpp->srv->reset_groups[reset_group_node]; mpp->srv->hw_support |= BIT(mpp->var->device_type); device_unlock(&pdev->dev); - put_device(&pdev->dev); -fail: - of_node_put(np); + return 0; + +err_put_pdev: + platform_device_put(pdev); + return ret; } @@ -1523,6 +1527,7 @@ int mpp_dev_remove(struct mpp_dev *mpp) mpp->hw_ops->exit(mpp); mpp_iommu_remove(mpp->iommu_info); + platform_device_put(mpp->pdev_srv); if (mpp->workq) { destroy_workqueue(mpp->workq); diff --git a/drivers/video/rockchip/mpp/mpp_common.h b/drivers/video/rockchip/mpp/mpp_common.h index d54c190bb9c7..ae22bdf7472a 100644 --- a/drivers/video/rockchip/mpp/mpp_common.h +++ b/drivers/video/rockchip/mpp/mpp_common.h @@ -200,6 +200,7 @@ struct mpp_dev { struct mpp_taskqueue *queue; struct mpp_reset_group *reset_group; /* point to MPP Service */ + struct platform_device *pdev_srv; struct mpp_service *srv; };