Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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 <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
4b30409b dbe98b30

+10 -21
+3 -7
drivers/media/usb/hdpvr/hdpvr-core.c
··· 69 69 void hdpvr_delete(struct hdpvr_device *dev) 70 70 { 71 71 hdpvr_free_buffers(dev); 72 - 73 - if (dev->video_dev) 74 - video_device_release(dev->video_dev); 75 - 76 72 usb_put_dev(dev->udev); 77 73 } 78 74 ··· 393 397 394 398 /* let the user know what node this device is now attached to */ 395 399 v4l2_info(&dev->v4l2_dev, "device now attached to %s\n", 396 - video_device_node_name(dev->video_dev)); 400 + video_device_node_name(&dev->video_dev)); 397 401 return 0; 398 402 399 403 reg_fail: ··· 416 420 struct hdpvr_device *dev = to_hdpvr_dev(usb_get_intfdata(interface)); 417 421 418 422 v4l2_info(&dev->v4l2_dev, "device %s disconnected\n", 419 - video_device_node_name(dev->video_dev)); 423 + video_device_node_name(&dev->video_dev)); 420 424 /* prevent more I/O from starting and stop any ongoing */ 421 425 mutex_lock(&dev->io_mutex); 422 426 dev->status = STATUS_DISCONNECTED; ··· 432 436 #if IS_ENABLED(CONFIG_I2C) 433 437 i2c_del_adapter(&dev->i2c_adapter); 434 438 #endif 435 - video_unregister_device(dev->video_dev); 439 + video_unregister_device(&dev->video_dev); 436 440 atomic_dec(&dev_nr); 437 441 } 438 442
+6 -13
drivers/media/usb/hdpvr/hdpvr-video.c
··· 797 797 * Comment this out for now, but if the legacy mode can be 798 798 * removed in the future, then this code should be enabled 799 799 * again. 800 - dev->video_dev->tvnorms = 800 + dev->video_dev.tvnorms = 801 801 (index != HDPVR_COMPONENT) ? V4L2_STD_ALL : 0; 802 802 */ 803 803 } ··· 1228 1228 } 1229 1229 1230 1230 /* setup and register video device */ 1231 - dev->video_dev = video_device_alloc(); 1232 - if (!dev->video_dev) { 1233 - v4l2_err(&dev->v4l2_dev, "video_device_alloc() failed\n"); 1234 - res = -ENOMEM; 1235 - goto error; 1236 - } 1231 + dev->video_dev = hdpvr_video_template; 1232 + strcpy(dev->video_dev.name, "Hauppauge HD PVR"); 1233 + dev->video_dev.v4l2_dev = &dev->v4l2_dev; 1234 + video_set_drvdata(&dev->video_dev, dev); 1237 1235 1238 - *dev->video_dev = hdpvr_video_template; 1239 - strcpy(dev->video_dev->name, "Hauppauge HD PVR"); 1240 - dev->video_dev->v4l2_dev = &dev->v4l2_dev; 1241 - video_set_drvdata(dev->video_dev, dev); 1242 - 1243 - res = video_register_device(dev->video_dev, VFL_TYPE_GRABBER, devnum); 1236 + res = video_register_device(&dev->video_dev, VFL_TYPE_GRABBER, devnum); 1244 1237 if (res < 0) { 1245 1238 v4l2_err(&dev->v4l2_dev, "video_device registration failed\n"); 1246 1239 goto error;
+1 -1
drivers/media/usb/hdpvr/hdpvr.h
··· 66 66 /* Structure to hold all of our device specific stuff */ 67 67 struct hdpvr_device { 68 68 /* the v4l device for this device */ 69 - struct video_device *video_dev; 69 + struct video_device video_dev; 70 70 /* the control handler for this device */ 71 71 struct v4l2_ctrl_handler hdl; 72 72 /* the usb device for this device */