[media] omap3isp: Platform data could be NULL
authorSakari Ailus <sakari.ailus@iki.fi>
Wed, 25 Mar 2015 22:57:29 +0000 (19:57 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 2 Apr 2015 19:39:14 +0000 (16:39 -0300)
Only check for call platform data callback functions if there's platform
data. Also take care of a few other cases where the NULL pdata pointer could
have been accessed, and remove the check for NULL dev->platform_data
pointer.

Removing the check for NULL dev->platform_data isn't strictly needed by the
DT support but there's no harm from that either: the device now can be used
without sensors, for instance.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/omap3isp/isp.c
drivers/media/platform/omap3isp/ispvideo.c

index 82499cd7c3d764dd79ff015bd2ccbafb839c3ae8..537377b43083e154857db03c2bf930a3e86f73a4 100644 (file)
@@ -330,8 +330,8 @@ static int isp_xclk_init(struct isp_device *isp)
                if (np)
                        continue;
 
-               if (pdata->xclks[i].con_id == NULL &&
-                   pdata->xclks[i].dev_id == NULL)
+               if (!pdata || (pdata->xclks[i].con_id == NULL &&
+                              pdata->xclks[i].dev_id == NULL))
                        continue;
 
                xclk->lookup = kzalloc(sizeof(*xclk->lookup), GFP_KERNEL);
@@ -1989,7 +1989,8 @@ static int isp_register_entities(struct isp_device *isp)
                goto done;
 
        /* Register external entities */
-       for (subdevs = pdata->subdevs; subdevs && subdevs->subdevs; ++subdevs) {
+       for (subdevs = pdata ? pdata->subdevs : NULL;
+            subdevs && subdevs->subdevs; ++subdevs) {
                struct v4l2_subdev *sensor;
 
                sensor = isp_register_subdev_group(isp, subdevs->subdevs);
@@ -2271,9 +2272,6 @@ static int isp_probe(struct platform_device *pdev)
        int ret;
        int i, m;
 
-       if (pdata == NULL)
-               return -EINVAL;
-
        isp = devm_kzalloc(&pdev->dev, sizeof(*isp), GFP_KERNEL);
        if (!isp) {
                dev_err(&pdev->dev, "could not allocate memory\n");
index 0b5967ecd4556fffc1b120fe2191b006424cd0aa..d285af18df7ffa4c4b50ad630f3e13bae966296f 100644 (file)
@@ -1018,7 +1018,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
 
        pipe->entities = 0;
 
-       if (video->isp->pdata->set_constraints)
+       if (video->isp->pdata && video->isp->pdata->set_constraints)
                video->isp->pdata->set_constraints(video->isp, true);
        pipe->l3_ick = clk_get_rate(video->isp->clock[ISP_CLK_L3_ICK]);
        pipe->max_rate = pipe->l3_ick;
@@ -1100,7 +1100,7 @@ err_set_stream:
 err_check_format:
        media_entity_pipeline_stop(&video->video.entity);
 err_pipeline_start:
-       if (video->isp->pdata->set_constraints)
+       if (video->isp->pdata && video->isp->pdata->set_constraints)
                video->isp->pdata->set_constraints(video->isp, false);
        /* The DMA queue must be emptied here, otherwise CCDC interrupts that
         * will get triggered the next time the CCDC is powered up will try to
@@ -1161,7 +1161,7 @@ isp_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
        video->queue = NULL;
        video->error = false;
 
-       if (video->isp->pdata->set_constraints)
+       if (video->isp->pdata && video->isp->pdata->set_constraints)
                video->isp->pdata->set_constraints(video->isp, false);
        media_entity_pipeline_stop(&video->video.entity);