From: Hans Verkuil Date: Mon, 9 Mar 2015 16:34:09 +0000 (-0300) Subject: [media] hdpvr: embed video_device X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=4b30409b1b77975ed6197e3494662eedc7a1e26f;p=linux-beck.git [media] hdpvr: embed video_device Embed the video_device struct to simplify the error handling and in order to (eventually) get rid of video_device_alloc/release. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c index 42b4cdf28cfd..3fc64197b4e6 100644 --- a/drivers/media/usb/hdpvr/hdpvr-core.c +++ b/drivers/media/usb/hdpvr/hdpvr-core.c @@ -69,10 +69,6 @@ MODULE_DEVICE_TABLE(usb, hdpvr_table); void hdpvr_delete(struct hdpvr_device *dev) { hdpvr_free_buffers(dev); - - if (dev->video_dev) - video_device_release(dev->video_dev); - usb_put_dev(dev->udev); } @@ -397,7 +393,7 @@ static int hdpvr_probe(struct usb_interface *interface, /* let the user know what node this device is now attached to */ v4l2_info(&dev->v4l2_dev, "device now attached to %s\n", - video_device_node_name(dev->video_dev)); + video_device_node_name(&dev->video_dev)); return 0; reg_fail: @@ -420,7 +416,7 @@ static void hdpvr_disconnect(struct usb_interface *interface) struct hdpvr_device *dev = to_hdpvr_dev(usb_get_intfdata(interface)); v4l2_info(&dev->v4l2_dev, "device %s disconnected\n", - video_device_node_name(dev->video_dev)); + video_device_node_name(&dev->video_dev)); /* prevent more I/O from starting and stop any ongoing */ mutex_lock(&dev->io_mutex); dev->status = STATUS_DISCONNECTED; @@ -436,7 +432,7 @@ static void hdpvr_disconnect(struct usb_interface *interface) #if IS_ENABLED(CONFIG_I2C) i2c_del_adapter(&dev->i2c_adapter); #endif - video_unregister_device(dev->video_dev); + video_unregister_device(&dev->video_dev); atomic_dec(&dev_nr); } diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c index 59d15fd242ba..d8d8c0f519fc 100644 --- a/drivers/media/usb/hdpvr/hdpvr-video.c +++ b/drivers/media/usb/hdpvr/hdpvr-video.c @@ -797,7 +797,7 @@ static int vidioc_s_input(struct file *file, void *_fh, * Comment this out for now, but if the legacy mode can be * removed in the future, then this code should be enabled * again. - dev->video_dev->tvnorms = + dev->video_dev.tvnorms = (index != HDPVR_COMPONENT) ? V4L2_STD_ALL : 0; */ } @@ -1228,19 +1228,12 @@ int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent, } /* setup and register video device */ - dev->video_dev = video_device_alloc(); - if (!dev->video_dev) { - v4l2_err(&dev->v4l2_dev, "video_device_alloc() failed\n"); - res = -ENOMEM; - goto error; - } - - *dev->video_dev = hdpvr_video_template; - strcpy(dev->video_dev->name, "Hauppauge HD PVR"); - dev->video_dev->v4l2_dev = &dev->v4l2_dev; - video_set_drvdata(dev->video_dev, dev); + dev->video_dev = hdpvr_video_template; + strcpy(dev->video_dev.name, "Hauppauge HD PVR"); + dev->video_dev.v4l2_dev = &dev->v4l2_dev; + video_set_drvdata(&dev->video_dev, dev); - res = video_register_device(dev->video_dev, VFL_TYPE_GRABBER, devnum); + res = video_register_device(&dev->video_dev, VFL_TYPE_GRABBER, devnum); if (res < 0) { v4l2_err(&dev->v4l2_dev, "video_device registration failed\n"); goto error; diff --git a/drivers/media/usb/hdpvr/hdpvr.h b/drivers/media/usb/hdpvr/hdpvr.h index dc685d44cb3e..a3194304182d 100644 --- a/drivers/media/usb/hdpvr/hdpvr.h +++ b/drivers/media/usb/hdpvr/hdpvr.h @@ -66,7 +66,7 @@ struct hdpvr_options { /* Structure to hold all of our device specific stuff */ struct hdpvr_device { /* the v4l device for this device */ - struct video_device *video_dev; + struct video_device video_dev; /* the control handler for this device */ struct v4l2_ctrl_handler hdl; /* the usb device for this device */