aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/platform
diff options
context:
space:
mode:
authorManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>2018-11-20 14:02:31 +0530
committerManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>2018-11-20 14:07:00 +0530
commit26537050e9c4824a4c18df5ef1114b257d29a3e8 (patch)
tree550c1832276cc88215ed11b985e5f3f29f03395f /drivers/media/platform
parentbf5e4d262fd3d0c08b4b4de8477e3eac171d0ac5 (diff)
download96b-common-26537050e9c4824a4c18df5ef1114b257d29a3e8.tar.gz
HACK: To make the driver work with 4.15 kernel
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r--drivers/media/platform/hisi/isp/isp.c80
1 files changed, 43 insertions, 37 deletions
diff --git a/drivers/media/platform/hisi/isp/isp.c b/drivers/media/platform/hisi/isp/isp.c
index f9650d178cd9..f71fbe6fbaf2 100644
--- a/drivers/media/platform/hisi/isp/isp.c
+++ b/drivers/media/platform/hisi/isp/isp.c
@@ -263,51 +263,61 @@ static int isp_of_parse_endpoint_node(struct device *dev,
*
* Return number of "port" nodes found in "ports" node
*/
-static int isp_of_parse_ports(struct isp *isp)
+
+static int isp_of_parse_ports(struct device *dev,
+ struct v4l2_async_notifier *notifier)
{
- struct device *dev = isp->dev;
struct device_node *node = NULL;
struct device_node *remote = NULL;
- int ret, num_subdevs = 0;
+ unsigned int size, i;
+ int ret;
- for_each_endpoint_of_node(dev->of_node, node) {
+ while ((node = of_graph_get_next_endpoint(dev->of_node, node)))
+ if (of_device_is_available(node))
+ notifier->num_subdevs++;
+
+ size = sizeof(*notifier->subdevs) * notifier->num_subdevs;
+ notifier->subdevs = devm_kzalloc(dev, size, GFP_KERNEL);
+ if (!notifier->subdevs) {
+ dev_err(dev, "Failed to allocate memory\n");
+ return -ENOMEM;
+ }
+
+ i = 0;
+ while ((node = of_graph_get_next_endpoint(dev->of_node, node))) {
struct isp_async_subdev *csd;
- struct v4l2_async_subdev *asd;
if (!of_device_is_available(node))
continue;
- remote = of_graph_get_remote_port_parent(node);
- if (!remote) {
- dev_err(dev, "Cannot get remote parent\n");
- ret = -EINVAL;
- goto err_cleanup;
+ csd = devm_kzalloc(dev, sizeof(*csd), GFP_KERNEL);
+ if (!csd) {
+ of_node_put(node);
+ dev_err(dev, "Failed to allocate memory\n");
+ return -ENOMEM;
}
- asd = v4l2_async_notifier_add_fwnode_subdev(
- &isp->notifier, of_fwnode_handle(remote),
- sizeof(*csd));
- if (IS_ERR(asd)) {
- ret = PTR_ERR(asd);
- of_node_put(remote);
- goto err_cleanup;
+ notifier->subdevs[i++] = &csd->asd;
+
+ ret = isp_of_parse_endpoint_node(dev, node, csd);
+ if (ret < 0) {
+ of_node_put(node);
+ return ret;
}
- csd = container_of(asd, struct isp_async_subdev, asd);
+ remote = of_graph_get_remote_port_parent(node);
+ of_node_put(node);
- ret = isp_of_parse_endpoint_node(dev, node, csd);
- if (ret < 0)
- goto err_cleanup;
+ if (!remote) {
+ dev_err(dev, "Cannot get remote parent\n");
+ return -EINVAL;
+ }
- num_subdevs++;
+ csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
+ csd->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
}
- return num_subdevs;
-
-err_cleanup:
- v4l2_async_notifier_cleanup(&isp->notifier);
- of_node_put(node);
- return ret;
+ return notifier->num_subdevs;
}
/*
@@ -516,7 +526,7 @@ static int isp_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct isp *isp;
struct resource *r;
- int num_subdevs, ret, i;
+ int ret, i;
isp = devm_kzalloc(dev, sizeof(*isp), GFP_KERNEL);
if (!isp)
@@ -539,8 +549,6 @@ static int isp_probe(struct platform_device *pdev)
if (!isp->cvdr)
return -ENOMEM;
- v4l2_async_notifier_init(&isp->notifier);
-
r = platform_get_resource_byname(pdev, IORESOURCE_MEM, isp_res[0].reg);
isp->ispss_ctrl = devm_ioremap_resource(dev, r);
if (IS_ERR(isp->ispss_ctrl)) {
@@ -596,9 +604,8 @@ static int isp_probe(struct platform_device *pdev)
memset(isp->virt_addr, 0, isp->pool_size);
- num_subdevs = isp_of_parse_ports(isp);
- if (num_subdevs < 0) {
- ret = num_subdevs;
+ ret = isp_of_parse_ports(dev, &isp->notifier);
+ if (ret < 0) {
goto err_cleanup;
}
@@ -607,7 +614,7 @@ static int isp_probe(struct platform_device *pdev)
goto err_cleanup;
isp->media_dev.dev = isp->dev;
- strscpy(isp->media_dev.model, "HiSilicon ISP",
+ strlcpy(isp->media_dev.model, "HiSilicon ISP",
sizeof(isp->media_dev.model));
isp->media_dev.ops = &isp_media_ops;
media_device_init(&isp->media_dev);
@@ -627,7 +634,7 @@ static int isp_probe(struct platform_device *pdev)
if (ret < 0)
goto err_register_entities;
- if (num_subdevs) {
+ if (isp->notifier.num_subdevs) {
isp->notifier.ops = &isp_subdev_notifier_ops;
ret = v4l2_async_notifier_register(&isp->v4l2_dev,
@@ -661,7 +668,6 @@ err_register_subdevs:
err_register_entities:
v4l2_device_unregister(&isp->v4l2_dev);
err_cleanup:
- v4l2_async_notifier_cleanup(&isp->notifier);
return ret;
}