From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org, hverkuil@xs4all.nl
Cc: mchehab@osg.samsung.com, shuahkh@osg.samsung.com,
laurent.pinchart@ideasonboard.com
Subject: [RFC v4 19/21] omap3isp: Allocate the media device dynamically
Date: Tue, 8 Nov 2016 15:55:28 +0200 [thread overview]
Message-ID: <1478613330-24691-19-git-send-email-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <1478613330-24691-1-git-send-email-sakari.ailus@linux.intel.com>
Use the new media_device_alloc() API to allocate and release the media
device.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/platform/omap3isp/isp.c | 24 +++++++++++++-----------
drivers/media/platform/omap3isp/isp.h | 2 +-
drivers/media/platform/omap3isp/ispvideo.c | 2 +-
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 2e1b17e..8bc7a7c 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -1601,8 +1601,8 @@ static void isp_unregister_entities(struct isp_device *isp)
omap3isp_stat_unregister_entities(&isp->isp_hist);
v4l2_device_unregister(&isp->v4l2_dev);
- media_device_unregister(&isp->media_dev);
- media_device_cleanup(&isp->media_dev);
+ media_device_unregister(isp->media_dev);
+ media_device_put(isp->media_dev);
}
static int isp_link_entity(
@@ -1680,14 +1680,16 @@ static int isp_register_entities(struct isp_device *isp)
{
int ret;
- isp->media_dev.dev = isp->dev;
- strlcpy(isp->media_dev.model, "TI OMAP3 ISP",
- sizeof(isp->media_dev.model));
- isp->media_dev.hw_revision = isp->revision;
- isp->media_dev.ops = &isp_media_ops;
- media_device_init(&isp->media_dev);
+ isp->media_dev = media_device_alloc(isp->dev, isp);
+ if (!isp->media_dev)
+ return -ENOMEM;
+
+ strlcpy(isp->media_dev->model, "TI OMAP3 ISP",
+ sizeof(isp->media_dev->model));
+ isp->media_dev->hw_revision = isp->revision;
+ isp->media_dev->ops = &isp_media_ops;
- isp->v4l2_dev.mdev = &isp->media_dev;
+ isp->v4l2_dev.mdev = isp->media_dev;
ret = v4l2_device_register(isp->dev, &isp->v4l2_dev);
if (ret < 0) {
dev_err(isp->dev, "%s: V4L2 device registration failed (%d)\n",
@@ -2165,7 +2167,7 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)
struct isp_bus_cfg *bus;
int ret;
- ret = media_entity_enum_init(&isp->crashed, &isp->media_dev);
+ ret = media_entity_enum_init(&isp->crashed, isp->media_dev);
if (ret)
return ret;
@@ -2183,7 +2185,7 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)
if (ret < 0)
return ret;
- return media_device_register(&isp->media_dev);
+ return media_device_register(isp->media_dev);
}
/*
diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h
index 7e6f663..7378279 100644
--- a/drivers/media/platform/omap3isp/isp.h
+++ b/drivers/media/platform/omap3isp/isp.h
@@ -176,7 +176,7 @@ struct isp_xclk {
struct isp_device {
struct v4l2_device v4l2_dev;
struct v4l2_async_notifier notifier;
- struct media_device media_dev;
+ struct media_device *media_dev;
struct device *dev;
u32 revision;
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index 7354469..33e74b9 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -1104,7 +1104,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
pipe = video->video.entity.pipe
? to_isp_pipeline(&video->video.entity) : &video->pipe;
- ret = media_entity_enum_init(&pipe->ent_enum, &video->isp->media_dev);
+ ret = media_entity_enum_init(&pipe->ent_enum, video->isp->media_dev);
if (ret)
goto err_enum_init;
--
2.1.4
next prev parent reply other threads:[~2016-11-08 13:55 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-08 13:54 [RFC v4 00/21] Make use of kref in media device, grab references as needed Sakari Ailus
2016-11-08 13:55 ` [RFC v4 01/21] Revert "[media] media: fix media devnode ioctl/syscall and unregister race" Sakari Ailus
2016-11-08 13:55 ` [RFC v4 02/21] Revert "[media] media: fix use-after-free in cdev_put() when app exits after driver unbind" Sakari Ailus
2016-11-08 13:55 ` [RFC v4 03/21] Revert "[media] media-device: dynamically allocate struct media_devnode" Sakari Ailus
2016-11-08 13:55 ` [RFC v4 04/21] media: Remove useless curly braces and parentheses Sakari Ailus
2016-11-22 9:59 ` Laurent Pinchart
2016-11-08 13:55 ` [RFC v4 05/21] media: devnode: Rename mdev argument as devnode Sakari Ailus
2016-11-22 10:00 ` Laurent Pinchart
2016-11-08 13:55 ` [RFC v4 06/21] media device: Drop nop release callback Sakari Ailus
2016-11-22 10:01 ` Laurent Pinchart
2016-11-08 13:55 ` [RFC v4 07/21] media-device: Make devnode.dev->kobj parent of devnode.cdev Sakari Ailus
2016-11-08 13:55 ` [RFC v4 08/21] media: Enable allocating the media device dynamically Sakari Ailus
2016-11-08 19:20 ` Shuah Khan
2016-11-10 23:53 ` Laurent Pinchart
2016-11-11 0:00 ` Shuah Khan
2016-11-11 0:11 ` Laurent Pinchart
2016-11-11 0:16 ` Shuah Khan
2016-11-11 0:19 ` Laurent Pinchart
2016-11-11 0:35 ` Shuah Khan
2016-11-14 13:40 ` Sakari Ailus
2016-11-15 0:13 ` Shuah Khan
2016-11-08 13:55 ` [RFC v4 09/21] media: Split initialising and adding media devnode Sakari Ailus
2016-11-08 13:55 ` [RFC v4 10/21] media: Shuffle functions around Sakari Ailus
2016-11-08 13:55 ` [RFC v4 11/21] media device: Refcount the media device Sakari Ailus
2016-11-08 13:55 ` [RFC v4 12/21] media device: Initialise media devnode in media_device_init() Sakari Ailus
2016-11-08 13:55 ` [RFC v4 13/21] media device: Deprecate media_device_{init,cleanup}() for drivers Sakari Ailus
2016-11-08 13:55 ` [RFC v4 14/21] media device: Get the media device driver's device Sakari Ailus
2016-11-22 9:46 ` Hans Verkuil
2016-11-22 9:58 ` Laurent Pinchart
2016-11-22 10:58 ` Hans Verkuil
2016-11-22 22:16 ` Laurent Pinchart
2016-11-08 13:55 ` [RFC v4 15/21] media: Provide a way to the driver to set a private pointer Sakari Ailus
2016-11-08 13:55 ` [RFC v4 16/21] media: Add release callback for media device Sakari Ailus
2016-11-08 13:55 ` [RFC v4 17/21] v4l: Acquire a reference to the media device for every video device Sakari Ailus
2016-11-08 13:55 ` [RFC v4 18/21] media-device: Postpone graph object removal until free Sakari Ailus
2016-11-08 13:55 ` Sakari Ailus [this message]
2016-11-22 10:05 ` [RFC v4 19/21] omap3isp: Allocate the media device dynamically Hans Verkuil
2016-12-02 14:52 ` Sakari Ailus
2016-11-08 13:55 ` [RFC v4 20/21] omap3isp: Release the isp device struct by media device callback Sakari Ailus
2016-11-08 13:55 ` [RFC v4 21/21] omap3isp: Don't rely on devm for memory resource management Sakari Ailus
2016-11-08 17:00 ` [RFC v4 01/21] Revert "[media] media: fix media devnode ioctl/syscall and unregister race" Mauro Carvalho Chehab
2016-11-10 23:49 ` Laurent Pinchart
2016-11-22 10:01 ` Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1478613330-24691-19-git-send-email-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@osg.samsung.com \
--cc=shuahkh@osg.samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).