diff options
author | Mike Isely <isely@pobox.com> | 2009-03-06 21:20:31 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:43:33 -0400 |
commit | b72b7bf5cbb2ae77b3bf748456655fc284baf04c (patch) | |
tree | 6183b07ecab2b9c34c711a4fb56681e70b8fe086 | |
parent | 59af33679592dd6e7bc7aa955098389724684a74 (diff) |
V4L/DVB (11155): pvrusb2: Set up v4l2_device instance
Define a v4l2_device instance in the pvrusb2 driver and initialize /
tear it down appropriately. This is a step in the v4l2-subdev
adoption effort.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h | 3 | ||||
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw.c | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h index d96f0f51076e..09798403e9fd 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
39 | #include "pvrusb2-hdw.h" | 39 | #include "pvrusb2-hdw.h" |
40 | #include "pvrusb2-io.h" | 40 | #include "pvrusb2-io.h" |
41 | #include <media/v4l2-device.h> | ||
41 | #include <media/cx2341x.h> | 42 | #include <media/cx2341x.h> |
42 | #include "pvrusb2-devattr.h" | 43 | #include "pvrusb2-devattr.h" |
43 | 44 | ||
@@ -179,6 +180,8 @@ struct pvr2_hdw { | |||
179 | struct usb_device *usb_dev; | 180 | struct usb_device *usb_dev; |
180 | struct usb_interface *usb_intf; | 181 | struct usb_interface *usb_intf; |
181 | 182 | ||
183 | /* Our handle into the v4l2 sub-device architecture */ | ||
184 | struct v4l2_device v4l2_dev; | ||
182 | /* Device description, anything that must adjust behavior based on | 185 | /* Device description, anything that must adjust behavior based on |
183 | device specific info will use information held here. */ | 186 | device specific info will use information held here. */ |
184 | const struct pvr2_device_desc *hdw_desc; | 187 | const struct pvr2_device_desc *hdw_desc; |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index 9441bcc37bc3..b66ac1c49dbe 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
@@ -2192,11 +2192,14 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
2192 | struct pvr2_hdw *hdw = NULL; | 2192 | struct pvr2_hdw *hdw = NULL; |
2193 | int valid_std_mask; | 2193 | int valid_std_mask; |
2194 | struct pvr2_ctrl *cptr; | 2194 | struct pvr2_ctrl *cptr; |
2195 | struct usb_device *usb_dev; | ||
2195 | const struct pvr2_device_desc *hdw_desc; | 2196 | const struct pvr2_device_desc *hdw_desc; |
2196 | __u8 ifnum; | 2197 | __u8 ifnum; |
2197 | struct v4l2_queryctrl qctrl; | 2198 | struct v4l2_queryctrl qctrl; |
2198 | struct pvr2_ctl_info *ciptr; | 2199 | struct pvr2_ctl_info *ciptr; |
2199 | 2200 | ||
2201 | usb_dev = interface_to_usbdev(intf); | ||
2202 | |||
2200 | hdw_desc = (const struct pvr2_device_desc *)(devid->driver_info); | 2203 | hdw_desc = (const struct pvr2_device_desc *)(devid->driver_info); |
2201 | 2204 | ||
2202 | if (hdw_desc == NULL) { | 2205 | if (hdw_desc == NULL) { |
@@ -2381,6 +2384,11 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
2381 | hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL); | 2384 | hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL); |
2382 | if (!hdw->ctl_read_urb) goto fail; | 2385 | if (!hdw->ctl_read_urb) goto fail; |
2383 | 2386 | ||
2387 | if (v4l2_device_register(&usb_dev->dev, &hdw->v4l2_dev) != 0) { | ||
2388 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | ||
2389 | "Error registering with v4l core, giving up"); | ||
2390 | goto fail; | ||
2391 | } | ||
2384 | mutex_lock(&pvr2_unit_mtx); do { | 2392 | mutex_lock(&pvr2_unit_mtx); do { |
2385 | for (idx = 0; idx < PVR_NUM; idx++) { | 2393 | for (idx = 0; idx < PVR_NUM; idx++) { |
2386 | if (unit_pointers[idx]) continue; | 2394 | if (unit_pointers[idx]) continue; |
@@ -2412,7 +2420,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
2412 | hdw->flag_ok = !0; | 2420 | hdw->flag_ok = !0; |
2413 | 2421 | ||
2414 | hdw->usb_intf = intf; | 2422 | hdw->usb_intf = intf; |
2415 | hdw->usb_dev = interface_to_usbdev(intf); | 2423 | hdw->usb_dev = usb_dev; |
2416 | 2424 | ||
2417 | usb_make_path(hdw->usb_dev, hdw->bus_info, sizeof(hdw->bus_info)); | 2425 | usb_make_path(hdw->usb_dev, hdw->bus_info, sizeof(hdw->bus_info)); |
2418 | 2426 | ||
@@ -2472,6 +2480,13 @@ static void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw) | |||
2472 | hdw->ctl_write_buffer = NULL; | 2480 | hdw->ctl_write_buffer = NULL; |
2473 | } | 2481 | } |
2474 | hdw->flag_disconnected = !0; | 2482 | hdw->flag_disconnected = !0; |
2483 | /* If we don't do this, then there will be a dangling struct device | ||
2484 | reference to our disappearing device persisting inside the V4L | ||
2485 | core... */ | ||
2486 | if (hdw->v4l2_dev.dev) { | ||
2487 | dev_set_drvdata(hdw->v4l2_dev.dev, NULL); | ||
2488 | hdw->v4l2_dev.dev = NULL; | ||
2489 | } | ||
2475 | hdw->usb_dev = NULL; | 2490 | hdw->usb_dev = NULL; |
2476 | hdw->usb_intf = NULL; | 2491 | hdw->usb_intf = NULL; |
2477 | pvr2_hdw_render_useless(hdw); | 2492 | pvr2_hdw_render_useless(hdw); |
@@ -2504,6 +2519,7 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw) | |||
2504 | } | 2519 | } |
2505 | pvr2_i2c_core_done(hdw); | 2520 | pvr2_i2c_core_done(hdw); |
2506 | pvr2_i2c_track_done(hdw); | 2521 | pvr2_i2c_track_done(hdw); |
2522 | v4l2_device_unregister(&hdw->v4l2_dev); | ||
2507 | pvr2_hdw_remove_usb_stuff(hdw); | 2523 | pvr2_hdw_remove_usb_stuff(hdw); |
2508 | mutex_lock(&pvr2_unit_mtx); do { | 2524 | mutex_lock(&pvr2_unit_mtx); do { |
2509 | if ((hdw->unit_number >= 0) && | 2525 | if ((hdw->unit_number >= 0) && |