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:
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/device.h>
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "cam_lrme_context.h"
|
||||
#include "cam_lrme_hw_mgr.h"
|
||||
#include "cam_lrme_hw_mgr_intf.h"
|
||||
#include "camera_main.h"
|
||||
|
||||
#define CAM_LRME_DEV_NAME "cam-lrme"
|
||||
|
||||
@@ -110,12 +111,14 @@ static const struct v4l2_subdev_internal_ops cam_lrme_subdev_internal_ops = {
|
||||
.close = cam_lrme_dev_close,
|
||||
};
|
||||
|
||||
static int cam_lrme_dev_probe(struct platform_device *pdev)
|
||||
static int cam_lrme_component_bind(struct device *dev,
|
||||
struct device *master_dev, void *data)
|
||||
{
|
||||
int rc;
|
||||
int i;
|
||||
struct cam_hw_mgr_intf hw_mgr_intf;
|
||||
struct cam_node *node;
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
|
||||
g_lrme_dev = kzalloc(sizeof(struct cam_lrme_dev), GFP_KERNEL);
|
||||
if (!g_lrme_dev) {
|
||||
@@ -157,7 +160,7 @@ static int cam_lrme_dev_probe(struct platform_device *pdev)
|
||||
goto deinit_ctx;
|
||||
}
|
||||
|
||||
CAM_DBG(CAM_LRME, "%s probe complete", g_lrme_dev->sd.name);
|
||||
CAM_DBG(CAM_LRME, "Component bound successfully");
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -175,7 +178,8 @@ free_mem:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_lrme_dev_remove(struct platform_device *pdev)
|
||||
static void cam_lrme_component_unbind(struct device *dev,
|
||||
struct device *master_dev, void *data)
|
||||
{
|
||||
int i;
|
||||
int rc = 0;
|
||||
@@ -192,15 +196,36 @@ static int cam_lrme_dev_remove(struct platform_device *pdev)
|
||||
|
||||
rc = cam_subdev_remove(&g_lrme_dev->sd);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_LRME, "Unregister failed");
|
||||
CAM_ERR(CAM_LRME, "Unregister failed rc: %d", rc);
|
||||
|
||||
mutex_destroy(&g_lrme_dev->lock);
|
||||
kfree(g_lrme_dev);
|
||||
g_lrme_dev = NULL;
|
||||
}
|
||||
|
||||
const static struct component_ops cam_lrme_component_ops = {
|
||||
.bind = cam_lrme_component_bind,
|
||||
.unbind = cam_lrme_component_unbind,
|
||||
};
|
||||
|
||||
static int cam_lrme_dev_probe(struct platform_device *pdev)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
CAM_DBG(CAM_LRME, "Adding LRME component");
|
||||
rc = component_add(&pdev->dev, &cam_lrme_component_ops);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_LRME, "failed to add component rc: %d", rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_lrme_dev_remove(struct platform_device *pdev)
|
||||
{
|
||||
component_del(&pdev->dev, &cam_lrme_component_ops);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id cam_lrme_dt_match[] = {
|
||||
{
|
||||
.compatible = "qcom,cam-lrme"
|
||||
@@ -208,7 +233,7 @@ static const struct of_device_id cam_lrme_dt_match[] = {
|
||||
{}
|
||||
};
|
||||
|
||||
static struct platform_driver cam_lrme_driver = {
|
||||
struct platform_driver cam_lrme_driver = {
|
||||
.probe = cam_lrme_dev_probe,
|
||||
.remove = cam_lrme_dev_remove,
|
||||
.driver = {
|
||||
|
Reference in New Issue
Block a user