Re: [RFC/PATCH] sysfs'ify video4linux

From: Gerd Knorr (
Date: Thu Jul 17 2003 - 11:37:15 EST

> > ... if a ->release() callback is required anyway to fix it? I see two
> > ways to handle it:
> >
> > (1) mandatory ->release() callback, drivers must make sure the stuff
> > is not freed before the callback was called. In that case the
> > class_device can be left embedded inside the drivers provate
> > structs.
> That sounds fine, and is the same as what I did for usb host devices.


> > (2) optional ->release() callback (for those drivers which want add
> > private attributes), "struct video_device" must be moved out of
> > the drivers private structs then and released in a new function
> > (which also calls the drivers ->release callback if present).
> > Should probably also be allocated by videodev.c for symmetry.
> That's "prettier", but probably requires a lot more work in every v4l
> driver, right?

Not sure which of them is actually more work.

Version (1) can be done without breaking the build, with a hack along
the lines "if (no release callback) printk(KERN_WARN please fix your
driver)", so the drivers can be fixed step-by-step afterwards.

Fixing the drivers might be non-trivial through. Some drivers are
hot-pluggable (usb cams), some drivers register more than one v4l device
(bttv wants up to three). Those drivers can't just call kfree() in the
->release callback because there might be other references, some open
file handle for a unplugged usb cam, another not-yet unregistered
v4l device, whatever. Probably they must implement some reference
counting scheme to get that right. The very simple ones (in
drivers/media/radio for example) likely just need the kfree() moved
from the ->remove function into the new ->release() callback.

Version (2) needs every v4l driver touched to make it compile again.
Not sure how hard it is to fixup them. I'd guess it is pretty straigt
forward to do the conversion, it's just alot of work. I also could do
a number of other cleanups along the way. Maybe I trap into some hidden
pitfalls through, havn't looked at all the drivers in detail yet.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Wed Jul 23 2003 - 22:00:29 EST