msm: camera: common: Add component helper support in camera
Due to the asynchronous nature of platform probes, inter dependency between drivers needs to be taken care during kernel boot up. Component helper provides the facility of adding matching drivers in a list ordered in the way we want to bind those drivers. The CRM driver acts as component master to make sure all slave drivers are bound before it returns from its own bind call. Add support for serializing platform probes through component framework. CRs-Fixed: 2584631 Change-Id: I345da1d2b9cccf6021ac6fc899143013b7714ec4 Signed-off-by: Mukund Madhusudan Atre <matre@codeaurora.org>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "cam_soc_util.h"
|
||||
#include "cam_cdm_soc.h"
|
||||
#include "cam_cdm_core_common.h"
|
||||
#include "camera_main.h"
|
||||
|
||||
static struct cam_cdm_intf_mgr cdm_mgr;
|
||||
static DEFINE_MUTEX(cam_cdm_mgr_lock);
|
||||
@@ -563,9 +564,11 @@ int cam_cdm_intf_deregister_hw_cdm(struct cam_hw_intf *hw,
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_cdm_intf_probe(struct platform_device *pdev)
|
||||
static int cam_cdm_intf_component_bind(struct device *dev,
|
||||
struct device *master_dev, void *data)
|
||||
{
|
||||
int i, rc;
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
|
||||
rc = cam_cdm_intf_mgr_soc_get_dt_properties(pdev, &cdm_mgr);
|
||||
if (rc) {
|
||||
@@ -599,18 +602,20 @@ static int cam_cdm_intf_probe(struct platform_device *pdev)
|
||||
mutex_unlock(&cam_cdm_mgr_lock);
|
||||
}
|
||||
|
||||
CAM_DBG(CAM_CDM, "CDM Intf probe done");
|
||||
CAM_DBG(CAM_CDM, "CDM Intf component bound successfully");
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_cdm_intf_remove(struct platform_device *pdev)
|
||||
static void cam_cdm_intf_component_unbind(struct device *dev,
|
||||
struct device *master_dev, void *data)
|
||||
{
|
||||
int i, rc = -EBUSY;
|
||||
int i;
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
|
||||
if (get_cdm_mgr_refcount()) {
|
||||
CAM_ERR(CAM_CDM, "CDM intf mgr get refcount failed");
|
||||
return rc;
|
||||
return;
|
||||
}
|
||||
|
||||
if (cam_virtual_cdm_remove(pdev)) {
|
||||
@@ -639,14 +644,35 @@ static int cam_cdm_intf_remove(struct platform_device *pdev)
|
||||
cdm_mgr.nodes[i].refcount = 0;
|
||||
}
|
||||
cdm_mgr.probe_done = false;
|
||||
rc = 0;
|
||||
|
||||
end:
|
||||
mutex_unlock(&cam_cdm_mgr_lock);
|
||||
}
|
||||
|
||||
const static struct component_ops cam_cdm_intf_component_ops = {
|
||||
.bind = cam_cdm_intf_component_bind,
|
||||
.unbind = cam_cdm_intf_component_unbind,
|
||||
};
|
||||
|
||||
static int cam_cdm_intf_probe(struct platform_device *pdev)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
CAM_DBG(CAM_CDM, "Adding CDM INTF component");
|
||||
rc = component_add(&pdev->dev, &cam_cdm_intf_component_ops);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_CDM, "failed to add component rc: %d", rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static struct platform_driver cam_cdm_intf_driver = {
|
||||
static int cam_cdm_intf_remove(struct platform_device *pdev)
|
||||
{
|
||||
component_del(&pdev->dev, &cam_cdm_intf_component_ops);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct platform_driver cam_cdm_intf_driver = {
|
||||
.probe = cam_cdm_intf_probe,
|
||||
.remove = cam_cdm_intf_remove,
|
||||
.driver = {
|
||||
|
Reference in New Issue
Block a user