diff mbox

[yavta,v3,01/11] Separate device object initialisation and opening

Message ID 1397309043-8322-2-git-send-email-sakari.ailus@iki.fi (mailing list archive)
State New, archived
Headers show

Commit Message

Sakari Ailus April 12, 2014, 1:23 p.m. UTC
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 yavta.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/yavta.c b/yavta.c
index 739463d..c7ad7b4 100644
--- a/yavta.c
+++ b/yavta.c
@@ -220,17 +220,20 @@  static const char *v4l2_format_name(unsigned int fourcc)
 	return name;
 }
 
-static int video_open(struct device *dev, const char *devname, int no_query)
+static void video_init(struct device *dev)
 {
-	struct v4l2_capability cap;
-	unsigned int capabilities;
-	int ret;
-
 	memset(dev, 0, sizeof *dev);
 	dev->fd = -1;
 	dev->memtype = V4L2_MEMORY_MMAP;
 	dev->buffers = NULL;
 	dev->type = (enum v4l2_buf_type)-1;
+}
+
+static int video_open(struct device *dev, const char *devname, int no_query)
+{
+	struct v4l2_capability cap;
+	unsigned int capabilities;
+	int ret;
 
 	dev->fd = open(devname, O_RDWR);
 	if (dev->fd < 0) {
@@ -1599,6 +1602,8 @@  int main(int argc, char *argv[])
 
 	unsigned int rt_priority = 1;
 
+	video_init(&dev);
+
 	opterr = 0;
 	while ((c = getopt_long(argc, argv, "c::Cd:f:F::hi:Iln:pq:r:R::s:t:uw:", opts, NULL)) != -1) {