From 37aa7537eedea07bc68d28b672fdc6803547f27a Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Sat, 12 Apr 2014 16:23:53 +0300 Subject: Separate device object initialisation and opening Signed-off-by: Sakari Ailus --- yavta.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'yavta.c') 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) { -- cgit v1.2.3