diff options
Diffstat (limited to 'drivers/media/platform/davinci/vpfe_capture.c')
-rw-r--r-- | drivers/media/platform/davinci/vpfe_capture.c | 91 |
1 files changed, 42 insertions, 49 deletions
diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c index 6efb2f1631c4..ee1cd79739c8 100644 --- a/drivers/media/platform/davinci/vpfe_capture.c +++ b/drivers/media/platform/davinci/vpfe_capture.c @@ -229,7 +229,7 @@ int vpfe_register_ccdc_device(struct ccdc_hw_device *dev) BUG_ON(!dev->hw_ops.getfid); mutex_lock(&ccdc_lock); - if (NULL == ccdc_cfg) { + if (!ccdc_cfg) { /* * TODO. Will this ever happen? if so, we need to fix it. * Proabably we need to add the request to a linked list and @@ -265,7 +265,7 @@ EXPORT_SYMBOL(vpfe_register_ccdc_device); */ void vpfe_unregister_ccdc_device(struct ccdc_hw_device *dev) { - if (NULL == dev) { + if (!dev) { printk(KERN_ERR "invalid ccdc device ptr\n"); return; } @@ -281,7 +281,6 @@ void vpfe_unregister_ccdc_device(struct ccdc_hw_device *dev) mutex_lock(&ccdc_lock); ccdc_dev = NULL; mutex_unlock(&ccdc_lock); - return; } EXPORT_SYMBOL(vpfe_unregister_ccdc_device); @@ -384,7 +383,7 @@ static int vpfe_config_image_format(struct vpfe_device *vpfe_dev, }; struct v4l2_mbus_framefmt *mbus_fmt = &fmt.format; struct v4l2_pix_format *pix = &vpfe_dev->fmt.fmt.pix; - int i, ret = 0; + int i, ret; for (i = 0; i < ARRAY_SIZE(vpfe_standards); i++) { if (vpfe_standards[i].std_id & std_id) { @@ -453,7 +452,7 @@ static int vpfe_config_image_format(struct vpfe_device *vpfe_dev, static int vpfe_initialize_device(struct vpfe_device *vpfe_dev) { - int ret = 0; + int ret; /* set first input of current subdevice as the current input */ vpfe_dev->current_input = 0; @@ -469,7 +468,7 @@ static int vpfe_initialize_device(struct vpfe_device *vpfe_dev) /* now open the ccdc device to initialize it */ mutex_lock(&ccdc_lock); - if (NULL == ccdc_dev) { + if (!ccdc_dev) { v4l2_err(&vpfe_dev->v4l2_dev, "ccdc device not registered\n"); ret = -ENODEV; goto unlock; @@ -511,12 +510,10 @@ static int vpfe_open(struct file *file) } /* Allocate memory for the file handle object */ - fh = kmalloc(sizeof(struct vpfe_fh), GFP_KERNEL); - if (NULL == fh) { - v4l2_err(&vpfe_dev->v4l2_dev, - "unable to allocate memory for file handle object\n"); + fh = kmalloc(sizeof(*fh), GFP_KERNEL); + if (!fh) return -ENOMEM; - } + /* store pointer to fh in private_data member of file */ file->private_data = fh; fh->vpfe_dev = vpfe_dev; @@ -584,7 +581,7 @@ static irqreturn_t vpfe_isr(int irq, void *dev_id) goto clear_intr; /* only for 6446 this will be applicable */ - if (NULL != ccdc_dev->hw_ops.reset) + if (ccdc_dev->hw_ops.reset) ccdc_dev->hw_ops.reset(); if (field == V4L2_FIELD_NONE) { @@ -617,9 +614,8 @@ static irqreturn_t vpfe_isr(int irq, void *dev_id) * interleavely or separately in memory, reconfigure * the CCDC memory address */ - if (field == V4L2_FIELD_SEQ_TB) { + if (field == V4L2_FIELD_SEQ_TB) vpfe_schedule_bottom_field(vpfe_dev); - } goto clear_intr; } /* @@ -824,7 +820,7 @@ static const struct vpfe_pixel_format * int temp, found; vpfe_pix_fmt = vpfe_lookup_pix_format(pixfmt->pixelformat); - if (NULL == vpfe_pix_fmt) { + if (!vpfe_pix_fmt) { /* * use current pixel format in the vpfe device. We * will find this pix format in the table @@ -919,8 +915,7 @@ static const struct vpfe_pixel_format * else pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; - v4l2_info(&vpfe_dev->v4l2_dev, "adjusted width = %d, height =" - " %d, bpp = %d, bytesperline = %d, sizeimage = %d\n", + v4l2_info(&vpfe_dev->v4l2_dev, "adjusted width = %d, height = %d, bpp = %d, bytesperline = %d, sizeimage = %d\n", pixfmt->width, pixfmt->height, vpfe_pix_fmt->bpp, pixfmt->bytesperline, pixfmt->sizeimage); return vpfe_pix_fmt; @@ -967,7 +962,7 @@ static int vpfe_enum_fmt_vid_cap(struct file *file, void *priv, /* Fill in the information about format */ pix_fmt = vpfe_lookup_pix_format(pix); - if (NULL != pix_fmt) { + if (pix_fmt) { temp_index = fmt->index; *fmt = pix_fmt->fmtdesc; fmt->index = temp_index; @@ -981,7 +976,7 @@ static int vpfe_s_fmt_vid_cap(struct file *file, void *priv, { struct vpfe_device *vpfe_dev = video_drvdata(file); const struct vpfe_pixel_format *pix_fmts; - int ret = 0; + int ret; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_fmt_vid_cap\n"); @@ -993,8 +988,7 @@ static int vpfe_s_fmt_vid_cap(struct file *file, void *priv, /* Check for valid frame format */ pix_fmts = vpfe_check_format(vpfe_dev, &fmt->fmt.pix); - - if (NULL == pix_fmts) + if (!pix_fmts) return -EINVAL; /* store the pixel format in the device object */ @@ -1020,7 +1014,7 @@ static int vpfe_try_fmt_vid_cap(struct file *file, void *priv, v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_try_fmt_vid_cap\n"); pix_fmts = vpfe_check_format(vpfe_dev, &f->fmt.pix); - if (NULL == pix_fmts) + if (!pix_fmts) return -EINVAL; return 0; } @@ -1088,12 +1082,11 @@ static int vpfe_enum_input(struct file *file, void *priv, &subdev, &index, inp->index) < 0) { - v4l2_err(&vpfe_dev->v4l2_dev, "input information not found" - " for the subdev\n"); + v4l2_err(&vpfe_dev->v4l2_dev, "input information not found for the subdev\n"); return -EINVAL; } sdinfo = &vpfe_dev->cfg->sub_devs[subdev]; - memcpy(inp, &sdinfo->inputs[index], sizeof(struct v4l2_input)); + *inp = sdinfo->inputs[index]; return 0; } @@ -1114,8 +1107,8 @@ static int vpfe_s_input(struct file *file, void *priv, unsigned int index) struct vpfe_subdev_info *sdinfo; int subdev_index, inp_index; struct vpfe_route *route; - u32 input = 0, output = 0; - int ret = -EINVAL; + u32 input, output; + int ret; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_input\n"); @@ -1147,6 +1140,9 @@ static int vpfe_s_input(struct file *file, void *priv, unsigned int index) if (route && sdinfo->can_route) { input = route->input; output = route->output; + } else { + input = 0; + output = 0; } if (sd) @@ -1181,7 +1177,7 @@ static int vpfe_querystd(struct file *file, void *priv, v4l2_std_id *std_id) { struct vpfe_device *vpfe_dev = video_drvdata(file); struct vpfe_subdev_info *sdinfo; - int ret = 0; + int ret; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querystd\n"); @@ -1200,7 +1196,7 @@ static int vpfe_s_std(struct file *file, void *priv, v4l2_std_id std_id) { struct vpfe_device *vpfe_dev = video_drvdata(file); struct vpfe_subdev_info *sdinfo; - int ret = 0; + int ret; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_std\n"); @@ -1349,7 +1345,7 @@ static int vpfe_reqbufs(struct file *file, void *priv, { struct vpfe_device *vpfe_dev = video_drvdata(file); struct vpfe_fh *fh = file->private_data; - int ret = 0; + int ret; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_reqbufs\n"); @@ -1481,7 +1477,7 @@ static int vpfe_streamon(struct file *file, void *priv, struct vpfe_fh *fh = file->private_data; struct vpfe_subdev_info *sdinfo; unsigned long addr; - int ret = 0; + int ret; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamon\n"); @@ -1564,7 +1560,7 @@ static int vpfe_streamoff(struct file *file, void *priv, struct vpfe_device *vpfe_dev = video_drvdata(file); struct vpfe_fh *fh = file->private_data; struct vpfe_subdev_info *sdinfo; - int ret = 0; + int ret; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamoff\n"); @@ -1650,7 +1646,7 @@ static int vpfe_s_selection(struct file *file, void *priv, { struct vpfe_device *vpfe_dev = video_drvdata(file); struct v4l2_rect rect = sel->r; - int ret = 0; + int ret; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_selection\n"); @@ -1708,7 +1704,7 @@ static long vpfe_param_handler(struct file *file, void *priv, bool valid_prio, unsigned int cmd, void *param) { struct vpfe_device *vpfe_dev = video_drvdata(file); - int ret = 0; + int ret; v4l2_dbg(2, debug, &vpfe_dev->v4l2_dev, "vpfe_param_handler\n"); @@ -1821,7 +1817,7 @@ static int vpfe_probe(struct platform_device *pdev) struct vpfe_device *vpfe_dev; struct i2c_adapter *i2c_adap; struct video_device *vfd; - int ret = -ENOMEM, i, j; + int ret, i, j; int num_subdevs = 0; /* Get the pointer to the device object */ @@ -1830,12 +1826,12 @@ static int vpfe_probe(struct platform_device *pdev) if (!vpfe_dev) { v4l2_err(pdev->dev.driver, "Failed to allocate memory for vpfe_dev\n"); - return ret; + return -ENOMEM; } vpfe_dev->pdev = &pdev->dev; - if (NULL == pdev->dev.platform_data) { + if (!pdev->dev.platform_data) { v4l2_err(pdev->dev.driver, "Unable to get vpfe config\n"); ret = -ENODEV; goto probe_free_dev_mem; @@ -1843,19 +1839,16 @@ static int vpfe_probe(struct platform_device *pdev) vpfe_cfg = pdev->dev.platform_data; vpfe_dev->cfg = vpfe_cfg; - if (NULL == vpfe_cfg->ccdc || - NULL == vpfe_cfg->card_name || - NULL == vpfe_cfg->sub_devs) { + if (!vpfe_cfg->ccdc || !vpfe_cfg->card_name || !vpfe_cfg->sub_devs) { v4l2_err(pdev->dev.driver, "null ptr in vpfe_cfg\n"); ret = -ENOENT; goto probe_free_dev_mem; } /* Allocate memory for ccdc configuration */ - ccdc_cfg = kmalloc(sizeof(struct ccdc_config), GFP_KERNEL); - if (NULL == ccdc_cfg) { - v4l2_err(pdev->dev.driver, - "Memory allocation failed for ccdc_cfg\n"); + ccdc_cfg = kmalloc(sizeof(*ccdc_cfg), GFP_KERNEL); + if (!ccdc_cfg) { + ret = -ENOMEM; goto probe_free_dev_mem; } @@ -1940,11 +1933,10 @@ static int vpfe_probe(struct platform_device *pdev) video_set_drvdata(&vpfe_dev->video_dev, vpfe_dev); i2c_adap = i2c_get_adapter(vpfe_cfg->i2c_adapter_id); num_subdevs = vpfe_cfg->num_subdevs; - vpfe_dev->sd = kmalloc(sizeof(struct v4l2_subdev *) * num_subdevs, - GFP_KERNEL); - if (NULL == vpfe_dev->sd) { - v4l2_err(&vpfe_dev->v4l2_dev, - "unable to allocate memory for subdevice pointers\n"); + vpfe_dev->sd = kmalloc_array(num_subdevs, + sizeof(*vpfe_dev->sd), + GFP_KERNEL); + if (!vpfe_dev->sd) { ret = -ENOMEM; goto probe_out_video_unregister; } @@ -1974,6 +1966,7 @@ static int vpfe_probe(struct platform_device *pdev) v4l2_info(&vpfe_dev->v4l2_dev, "v4l2 sub device %s register fails\n", sdinfo->name); + ret = -ENXIO; goto probe_sd_out; } } |