From patchwork Sun Mar 8 21:57:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 28597 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1YUjD4-0000VU-Mr; Sun, 08 Mar 2015 22:58:06 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-5) with esmtp id 1YUjD2-0008Ss-8J; Sun, 08 Mar 2015 22:58:06 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753178AbbCHV6B (ORCPT + 1 other); Sun, 8 Mar 2015 17:58:01 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:38075 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751959AbbCHV5a (ORCPT ); Sun, 8 Mar 2015 17:57:30 -0400 Received: by widex7 with SMTP id ex7so14929149wid.3; Sun, 08 Mar 2015 14:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pHwdqpJtWA45/NgqBp5NSOm2pHkp5PeF0XbOuHI7Qh4=; b=tK4lGRiPY2WpkTztJX/7UWgKDPV1hoDA2uzztXyspTCspCBIc77cFiUkE5AR4IeydX iEklj602UxGycrOTnVH2H1FC3h1jC4MdscZfMAWP+6wHszol5sBS4f4lAuknnYYDHGi6 uLo2WKXzPrZWFQE080hdlAfRHLT7mcyd/nwSN5suYMgBDsUc6r83MEQ1l02wH/Ed2FJ2 OR0ZrlNA63N64VnFI1Lt053ArwrqpsYxkiKCsd23i3LOehgBYvdBv4xttqDsTRaRnraP 8NdiNMgGqpz+0rcH+i9uto/LRQLrdLqBjvep/LYXi5E5Ho3DcJXD0XVrRfSB35jtpZNv djGg== X-Received: by 10.181.8.75 with SMTP id di11mr97796332wid.26.1425851849414; Sun, 08 Mar 2015 14:57:29 -0700 (PDT) Received: from tango-charlie.Home (0545247b.skybroadband.com. [5.69.36.123]) by mx.google.com with ESMTPSA id dc9sm12466008wib.9.2015.03.08.14.57.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Mar 2015 14:57:28 -0700 (PDT) From: Lad Prabhakar To: LMML , Hans Verkuil Cc: LKML , "Lad, Prabhakar" Subject: [PATCH 1/2] media: davinci: vpif_capture: embed video_device struct in channel_obj Date: Sun, 8 Mar 2015 21:57:23 +0000 Message-Id: <1425851844-1917-2-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1425851844-1917-1-git-send-email-prabhakar.csengg@gmail.com> References: <1425851844-1917-1-git-send-email-prabhakar.csengg@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.3.8.214817 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' FORGED_FROM_GMAIL 0.1, MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_5000_5999 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, REFERENCES 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_GMAIL 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __REFERENCES 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' From: "Lad, Prabhakar" Embed video_device struct (video_dev) in channel_obj and also the Unregister path doesn't need to free the video_device structure, hence, change the video_device.release callback point to video_device_release_empty. Signed-off-by: Lad, Prabhakar --- drivers/media/platform/davinci/vpif_capture.c | 52 ++++++--------------------- drivers/media/platform/davinci/vpif_capture.h | 2 +- 2 files changed, 11 insertions(+), 43 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index fa0a515..a5f5481 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -712,7 +712,7 @@ static int vpif_set_input( ch->vpifparams.iface = chan_cfg->vpif_if; /* update tvnorms from the sub device input info */ - ch->video_dev->tvnorms = chan_cfg->inputs[index].input.std; + ch->video_dev.tvnorms = chan_cfg->inputs[index].input.std; return 0; } @@ -1337,7 +1337,7 @@ static int vpif_probe_complete(void) struct video_device *vdev; struct channel_obj *ch; struct vb2_queue *q; - int i, j, err, k; + int j, err, k; for (j = 0; j < VPIF_CAPTURE_MAX_DEVICES; j++) { ch = vpif_obj.dev[j]; @@ -1384,16 +1384,16 @@ static int vpif_probe_complete(void) INIT_LIST_HEAD(&common->dma_queue); /* Initialize the video_device structure */ - vdev = ch->video_dev; + vdev = &ch->video_dev; strlcpy(vdev->name, VPIF_DRIVER_NAME, sizeof(vdev->name)); - vdev->release = video_device_release; + vdev->release = video_device_release_empty; vdev->fops = &vpif_fops; vdev->ioctl_ops = &vpif_ioctl_ops; vdev->v4l2_dev = &vpif_obj.v4l2_dev; vdev->vfl_dir = VFL_DIR_RX; vdev->queue = q; vdev->lock = &common->lock; - video_set_drvdata(ch->video_dev, ch); + video_set_drvdata(&ch->video_dev, ch); err = video_register_device(vdev, VFL_TYPE_GRABBER, (j ? 1 : 0)); if (err) @@ -1410,14 +1410,9 @@ probe_out: common = &ch->common[k]; vb2_dma_contig_cleanup_ctx(common->alloc_ctx); /* Unregister video device */ - video_unregister_device(ch->video_dev); + video_unregister_device(&ch->video_dev); } kfree(vpif_obj.sd); - for (i = 0; i < VPIF_CAPTURE_MAX_DEVICES; i++) { - ch = vpif_obj.dev[i]; - /* Note: does nothing if ch->video_dev == NULL */ - video_device_release(ch->video_dev); - } v4l2_device_unregister(&vpif_obj.v4l2_dev); return err; @@ -1438,13 +1433,11 @@ static int vpif_async_complete(struct v4l2_async_notifier *notifier) static __init int vpif_probe(struct platform_device *pdev) { struct vpif_subdev_info *subdevdata; - int i, j, err; - int res_idx = 0; struct i2c_adapter *i2c_adap; - struct channel_obj *ch; - struct video_device *vfd; struct resource *res; int subdev_count; + int res_idx = 0; + int i, err; vpif_dev = &pdev->dev; @@ -1472,24 +1465,6 @@ static __init int vpif_probe(struct platform_device *pdev) res_idx++; } - for (i = 0; i < VPIF_CAPTURE_MAX_DEVICES; i++) { - /* Get the pointer to the channel object */ - ch = vpif_obj.dev[i]; - /* Allocate memory for video device */ - vfd = video_device_alloc(); - if (NULL == vfd) { - for (j = 0; j < i; j++) { - ch = vpif_obj.dev[j]; - video_device_release(ch->video_dev); - } - err = -ENOMEM; - goto vpif_unregister; - } - - /* Set video_dev to the video device */ - ch->video_dev = vfd; - } - vpif_obj.config = pdev->dev.platform_data; subdev_count = vpif_obj.config->subdev_count; @@ -1498,7 +1473,7 @@ static __init int vpif_probe(struct platform_device *pdev) if (vpif_obj.sd == NULL) { vpif_err("unable to allocate memory for subdevice pointers\n"); err = -ENOMEM; - goto vpif_sd_error; + goto vpif_unregister; } if (!vpif_obj.config->asd_sizes) { @@ -1541,13 +1516,6 @@ static __init int vpif_probe(struct platform_device *pdev) probe_subdev_out: /* free sub devices memory */ kfree(vpif_obj.sd); - -vpif_sd_error: - for (i = 0; i < VPIF_CAPTURE_MAX_DEVICES; i++) { - ch = vpif_obj.dev[i]; - /* Note: does nothing if ch->video_dev == NULL */ - video_device_release(ch->video_dev); - } vpif_unregister: v4l2_device_unregister(&vpif_obj.v4l2_dev); @@ -1576,7 +1544,7 @@ static int vpif_remove(struct platform_device *device) common = &ch->common[VPIF_VIDEO_INDEX]; vb2_dma_contig_cleanup_ctx(common->alloc_ctx); /* Unregister video device */ - video_unregister_device(ch->video_dev); + video_unregister_device(&ch->video_dev); kfree(vpif_obj.dev[i]); } return 0; diff --git a/drivers/media/platform/davinci/vpif_capture.h b/drivers/media/platform/davinci/vpif_capture.h index f65d28d..8b8a663 100644 --- a/drivers/media/platform/davinci/vpif_capture.h +++ b/drivers/media/platform/davinci/vpif_capture.h @@ -92,7 +92,7 @@ struct common_obj { struct channel_obj { /* Identifies video device for this channel */ - struct video_device *video_dev; + struct video_device video_dev; /* Indicates id of the field which is being displayed */ u32 field_id; /* flag to indicate whether decoder is initialized */