v4l: Build error with et61x251, if V4L1_COMPAT is not selected
PATCH 1/1 v4l: Build error with et61x251, if V4L1_COMPAT is not selected
With current git tree I get an build error
for et61x251, if V4L1_COMPAT is not selected:
drivers/media/video/et61x251/et61x251_core.c: In et61x251_show_:drivers/media/video/et61x251/et61x251_core.c:718: error: implicit declaration of to_video_device
Fix: add VIDEO_V4L1_COMPAT as a dependency for this driver.
--- drivers/media/video/et61x251/Kconfig | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/media/video/et61x251/Kconfig +1 -1
@@ -1,6 +1,6 @@ config USB_ET61X251 tristate "USB ET61X[12]51 PC Camera Controller support" - depends on VIDEO_V4L2 + depends on VIDEO_V4L2 && VIDEO_V4L1_COMPAT ---help--- Say Y here if you want support for cameras based on Etoms ET61X151 or ET61X251 PC Camera Controllers.
Signature · 1 line
1.5.3
Quoted 8 lines · On Thursday 13 September 2007 14:36:27 [email protected] wrote:
With current git tree I get an build error
for et61x251, ifV4L1_COMPATis not selected:
drivers/media/video/et61x251/et61x251_core.c: Inet61x251_show_:drivers/media/video/et61x251/et61x251_core.c:718: error: implicit declaration ofto_video_deviceFix: add
VIDEO_V4L1_COMPATas a dependency for this driver.
No, wait. The driver really is V4L2 only. If you can, please fix it by replacing to_video_device() with container_of() instead:
cam = video_get_drvdata(container_of(cd, struct video_device, class_dev));
Best regards
Luca Risolia
Quoted 18 lines
Signed-off-by Andreas Herrmann <[email protected]>--- drivers/media/video/et61x251/Kconfig | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)(quoted diff) +0
-0b/drivers/media/video/et61x251/Kconfig index dcc1a03..9143424 100644
drivers/media/video/et61x251/Kconfig +1
-1@@ -1,6 +1,6 @@ config USB_ET61X251 tristate "USB ET61X[12]51 PC Camera Controller support" - depends on VIDEO_V4L2 + depends on VIDEO_V4L2 && VIDEO_V4L1_COMPAT ---help--- Say Y here if you want support for cameras based on Etoms ET61X151 or ET61X251 PC Camera Controllers.
Quoted 8 lines · Luca Risolia
Quoted 7 lines · On Thursday 13 September 2007 14:36:27 [email protected] wrote:
With current git tree I get an build error
for et61x251, ifV4L1_COMPATis not selected:
drivers/media/video/et61x251/et61x251_core.c: Inet61x251_show_:drivers/media/video/et61x251/et61x251_core.c:718: error: implicit declaration ofto_video_device
Quoted 6 lines
Quoted 1 line
Fix: add
VIDEO_V4L1_COMPATas a dependency for this driver.No, wait. The driver really is V4L2 only. If you can, please fix it by replacing
to_video_device()withcontainer_of()instead:cam =
video_get_drvdata(container_of(cd, struct video_device, class_dev));
Ah just some v4l1 remainders.
I'll do that.
Regards,
Andreas
PATCH 1/1 v4l: fix build error for et61x251 driver
In reply to Luca RisoliaThis fixes a kernel build problem and
should make it into 2.6.23, I think.
Regards,
Andreas
--
Get rid of some v4l1 remainders to avoid kernel build errors if V4L1_COMPAT is not selected:
drivers/media/video/et61x251/et61x251_core.c: In et61x251_show_:
drivers/media/video/et61x251/et61x251_core.c:718: error: implicit
declaration of to_video_device
Fix as suggested by Luca Risolia <[email protected]>
--- drivers/media/video/et61x251/et61x251_core.c | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-)
drivers/media/video/et61x251/et61x251_core.c +16 -8
@@ -715,7 +715,8 @@ static ssize_t et61x251_show_reg(struct class_device* cd, char* buf)if (mutex_lock_interruptible (&et61x251_sysfs_lock))return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;
@@ -739,7 +740,8 @@ et61x251_store_reg(struct class_device* cd, const char* buf, size_t len)if (mutex_lock_interruptible (&et61x251_sysfs_lock))return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;
@@ -771,7 +773,8 @@ static ssize_t et61x251_show_val(struct class_device* cd, char* buf)if (mutex_lock_interruptible (&et61x251_sysfs_lock))return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;
@@ -803,7 +806,8 @@ et61x251_store_val(struct class_device* cd, const char* buf, size_t len)if (mutex_lock_interruptible (&et61x251_sysfs_lock))return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;
@@ -839,7 +843,8 @@ static ssize_t et61x251_show_i2c_reg(struct class_device* cd, char* buf)if (mutex_lock_interruptible (&et61x251_sysfs_lock))return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;
@@ -865,7 +870,8 @@ et61x251_store_i2c_reg(struct class_device* cd, const char* buf, size_t len)if (mutex_lock_interruptible (&et61x251_sysfs_lock))return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;
@@ -897,7 +903,8 @@ static ssize_t et61x251_show_i2c_val(struct class_device* cd, char* buf)if (mutex_lock_interruptible (&et61x251_sysfs_lock))return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;
@@ -934,7 +941,8 @@ et61x251_store_i2c_val(struct class_device* cd, const char* buf, size_t len)if (mutex_lock_interruptible (&et61x251_sysfs_lock))return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;
Signature · 1 line
1.5.3
Re: [PATCH] v4l: fix build error for et61x251 driver
Quoted 111 lines · On Friday 14 September 2007 00:27:17 Andreas Herrmann wrote:
This fixes a kernel build problem and
should make it into 2.6.23, I think.Regards,
Andreas
--
Get rid of some v4l1 remainders to avoid kernel build errors if
V4L1_COMPATis not selected:
drivers/media/video/et61x251/et61x251_core.c: Inet61x251_show_:
drivers/media/video/et61x251/et61x251_core.c:718: error: implicit
declaration ofto_video_deviceFix as suggested by Luca Risolia <[email protected]>
Signed-off-by Andreas Herrmann <[email protected]>--- drivers/media/video/et61x251/et61x251_core.c | 24++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-)
(quoted diff) +0
-0
b/drivers/media/video/et61x251/et61x251_core.cindex 585bd1f..a3ee968 100644drivers/media/video/et61x251/et61x251_core.c +8
-4@@ -715,7 +715,8 @@ static ssize_t et61x251_show_reg(struct class_device* cd, char* buf) if (mutex_lock_interruptible(&et61x251_sysfs_lock))return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;@@ -739,7 +740,8 @@ et61x251_store_reg(struct class_device* cd, const char* buf, size_t len) if (mutex_lock_interruptible(&et61x251_sysfs_lock))return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;@@ -771,7 +773,8 @@ static ssize_t et61x251_show_val(struct class_device* cd, char* buf) if (mutex_lock_interruptible(&et61x251_sysfs_lock))return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;@@ -803,7 +806,8 @@ et61x251_store_val(struct class_device* cd, const char* buf, size_t len) if (mutex_lock_interruptible(&et61x251_sysfs_lock))return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;@@ -839,7 +843,8 @@ static ssize_t et61x251_show_i2c_reg(structclass_device* cd, char* buf) if
(mutex_lock_interruptible(&et61x251_sysfs_lock))drivers/media/video/et61x251/et61x251_core.c +4
-2return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;@@ -865,7 +870,8 @@ et61x251_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) if (mutex_lock_interruptible(&et61x251_sysfs_lock)) return -ERESTARTSYS; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;@@ -897,7 +903,8 @@ static ssize_t et61x251_show_i2c_val(structclass_device* cd, char* buf) if
(mutex_lock_interruptible(&et61x251_sysfs_lock))drivers/media/video/et61x251/et61x251_core.c +4
-2return -ERESTARTSYS ; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;@@ -934,7 +941,8 @@ et61x251_store_i2c_val(struct class_device* cd, const char* buf, size_t len) if (mutex_lock_interruptible(&et61x251_sysfs_lock)) return -ERESTARTSYS; - cam =video_get_drvdata (to_video_device (cd)); + cam = video_get_drvdata(container_of(cd, struct video_device, + class_dev));if (!cam) {mutex_unlock (&et61x251_sysfs_lock);return -ENODEV ;
Re: [PATCH] v4l: fix build error for et61x251 driver
Quoted 21 lines · Luca Risolia
Hacked-by Luca Risolia <[email protected]>Quoted 18 lines · On Friday 14 September 2007 00:27:17 Andreas Herrmann wrote:
This fixes a kernel build problem and
should make it into 2.6.23, I think.Regards,
Andreas
--
Get rid of some v4l1 remainders to avoid kernel build errors if
V4L1_COMPATis not selected:
drivers/media/video/et61x251/et61x251_core.c: Inet61x251_show_:
drivers/media/video/et61x251/et61x251_core.c:718: error: implicit
declaration ofto_video_deviceFix as suggested by Luca Risolia <[email protected]>
This patch is really ugly.
Why can't the "to_video_device()" macro be used? Just move it to a place where it's usable! IOW, what's wrong with the *much* simpler patch below?
That "to_video_device()" macro has absolutely _nothing_ to do with CONFIG_VIDEO_V4L1_COMPAT, as far as I can tell!
Linus
---
include/media/v4l2-dev.h +3 -2
@@ -337,6 +337,9 @@ void *priv;struct class_device class_dev;/* sysfs */ }; +/* Class-dev to video-device */ +#define to_video_device (cd) container_of(cd, struct video_device, class_dev) +/* Version 2 functions */ extern int video_register_device (struct video_device *vfd,int type,int nr);void video_unregister_device (struct video_device *);
@@ -354,11 +357,9 @@ extern int video_usercopy(struct inode *inode, struct file *file,int (*func)(struct inode *inode,struct file *file, unsigned int cmd, void *arg)); -#ifdef CONFIG_VIDEO_V4L1_COMPAT #include <linux/mm.h> -#define to_video_device (cd) container_of(cd, struct video_device, class_dev)static inline int __must_check video_device_create_file (struct video_device *vfd,struct class_device_attribute *attr)
Re: [PATCH] v4l: fix build error for et61x251 driver
Quoted 21 lines · On Friday 14 September 2007 02:09:01 Linus Torvalds wrote:
Quoted 20 lines · Luca Risolia
Hacked-by Luca Risolia <[email protected]>Quoted 17 lines · On Friday 14 September 2007 00:27:17 Andreas Herrmann wrote:
This fixes a kernel build problem and
should make it into 2.6.23, I think.Regards,
Andreas
--
Get rid of some v4l1 remainders to avoid kernel build errors if
V4L1_COMPATis not selected:
drivers/media/video/et61x251/et61x251_core.c: Inet61x251_show_:
drivers/media/video/et61x251/et61x251_core.c:718: error: implicit
declaration ofto_video_device
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Fix as suggested by Luca Risolia <[email protected]>
This patch is really ugly.
Why can't the "
to_video_device()" macro be used? Just move it to a place where it's usable! IOW, what's wrong with the *much* simpler patch below?
There's nothing wtong in my opinion. I do not know the exact reason why Mauro moved "to_video_device()" into CONFIG_VIDEO_V4L1_COMPAT. Pheraps he can give more details about this change.
Quoted 28 lines
That "
to_video_device()" macro has absolutely _nothing_ to do withCONFIG_VIDEO_V4L1_COMPAT, as far as I can tell!Linus
---include/media/v4l2-dev.h +2
-0@@ -337,6 +337,9 @@ void *priv;struct class_device class_dev;/* sysfs */ }; +/* Class-dev to video-device */ +#define to_video_device (cd) container_of(cd, struct video_device,
class_dev) +
/* Version 2 functions */
extern int video_register_device(structvideo_device*vfd, int type, int
nr); voidvideo_unregister_device(struct video_device *);include/media/v4l2-dev.h +0
-2@@ -354,11 +357,9 @@ extern int video_usercopy(struct inode *inode, struct file *file, int (*func)(struct inode *inode, struct file *file, unsigned int cmd, void *arg)); -#ifdef CONFIG_VIDEO_V4L1_COMPAT #include <linux/mm.h> -#define to_video_device (cd) container_of(cd, struct video_device,
Quoted 3 lines
class_dev) static inline int__must_check
video_device_create_file(structvideo_device*vfd,
structclass_device_attribute*attr)
Best regards
Luca Risolia
Re: [PATCH] v4l: fix build error for et61x251 driver
Quoted 5 lines · Luca Risolia
Quoted 4 lines · On Friday 14 September 2007 02:09:01 Linus Torvalds wrote:
Quoted 3 lines · Luca Risolia
Hacked-by Luca Risolia <[email protected]>On Friday 14 September 2007 00:27:17 Andreas Herrmann wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
This fixes a kernel build problem and
should make it into 2.6.23, I think.This patch is really ugly.
Well, yes. I should have known as I converted so many occurences of to_video_device to container_of in my second patch.
Quoted 6 lines
Quoted 2 lines
Why can't the "
to_video_device()" macro be used? Just move it to a place where it's usable! IOW, what's wrong with the *much* simpler patch below?There's nothing wtong in my opinion. I do not know the exact reason why Mauro moved "
to_video_device()" intoCONFIG_VIDEO_V4L1_COMPAT. Pheraps he can give more details about this change.
BTW, just a few V4L2 drivers and videodev seem to use this construct:
video/usbvision/usbvision-video.c: container_of(cd, struct video_device, class_dev);
video/sn9c102/sn9c102_core.c: cam = video_get_drvdata(container_of(cd, struct video_device,
video/sn9c102/sn9c102_core.c- class_dev));
video/videodev.c: struct video_device *vfd = container_of(cd, struct video_device,
video/videodev.c- class_dev);
And then their are drivers with other variants of container_of, e.g.:
video/pvrusb2/pvrusb2-v4l2.c: vp = container_of(chp,struct pvr2_v4l2,channel);
video/bt8xx/bttv-vbi.c: struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
...
I think, there should be a to_video_device macro for usage in v4l2.
An most probable for the other container_of stuff (when more there is more than one occurence of a particular construct), drivers should provide their own macro, e.g. to_video_buffer() or so.
That's what other subsystems do. It is more self-explanatory than a direct usage of container_of.
So why not apply (my first patch ... oh no, of course that's rubbish ;-) Linus' below patch for 2.6.23 to fix the compilation for that particular driver. And to work on the conversion of container_of() stuff to meaningful macros for the next kernel release?
Regards,
Andreas
Quoted 36 lines
Quoted 30 lines
That "
to_video_device()" macro has absolutely _nothing_ to do withCONFIG_VIDEO_V4L1_COMPAT, as far as I can tell!Linus
---include/media/v4l2-dev.h +2
-0@@ -337,6 +337,9 @@ void *priv;struct class_device class_dev;/* sysfs */ }; +/* Class-dev to video-device */ +#define to_video_device (cd) container_of(cd, struct video_device,
class_dev) +
/* Version 2 functions */
extern int video_register_device(structvideo_device*vfd, int type, int
nr); voidvideo_unregister_device(struct video_device *);include/media/v4l2-dev.h +0
-2@@ -354,11 +357,9 @@ extern int video_usercopy(struct inode *inode, struct file *file, int (*func)(struct inode *inode, struct file *file, unsigned int cmd, void *arg)); -#ifdef CONFIG_VIDEO_V4L1_COMPAT #include <linux/mm.h> -#define to_video_device (cd) container_of(cd, struct video_device,Quoted 3 lines
class_dev) static inline int__must_check
video_device_create_file(structvideo_device*vfd,
structclass_device_attribute*attr)Best regards
Luca Risolia
Re: [PATCH] v4l: fix build error for et61x251 driver
Quoted 31 lines
Quoted 1 line
Quoted 1 line
This patch is really ugly.
Well, yes. I should have known as I converted so many occurences of
to_video_devicetocontainer_ofin my second patch.Quoted 6 lines
Quoted 2 lines
Why can't the "
to_video_device()" macro be used? Just move it to a place where it's usable! IOW, what's wrong with the *much* simpler patch below?There's nothing wtong in my opinion. I do not know the exact reason why Mauro moved "
to_video_device()" intoCONFIG_VIDEO_V4L1_COMPAT. Pheraps he can give more details about this change.BTW, just a few V4L2 drivers and videodev seem to use this construct:
video/usbvision/usbvision-video.c:container_of(cd, struct video_device, class_dev);
video/sn9c102/sn9c102_core.c: cam = video_get_drvdata(container_of(cd, structvideo_device,
video/sn9c102/sn9c102_core.c-class_dev));
video/videodev.c: structvideo_device*vfd = container_of(cd, structvideo_device,
video/videodev.c-class_dev);And then their are drivers with other variants of
container_of, e.g.:
video/pvrusb2/pvrusb2-v4l2.c: vp =container_of(chp,struct pvr2_v4l2,channel);video/bt8xx/bttv-vbi.c: struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); ...I think, there should be a
to_video_devicemacro for usage in v4l2.
An most probable for the othercontainer_ofstuff (when more there is more than one occurence of a particular construct), drivers should provide their own macro, e.g.to_video_buffer()or so.
Quoted 7 lines
That's what other subsystems do. It is more self-explanatory than a direct usage of
container_of.So why not apply (my first patch ... oh no, of course that's rubbish ;-) Linus' below patch for 2.6.23 to fix the compilation for that particular driver. And to work on the conversion of
container_of()stuff to meaningful macros for the next kernel release?
The to_video_device and the container_of (cd, struct video_device, class_dev) (as you noticed at the above drivers) are used to provide procfs interface.
On videodev, there's the v4l2 core stuff, used on all V4L drivers. It allows some control to the V4L devices (basically, see/change the modprobe loading parameters).
The other drivers that uses to_video_device (or the container_of alternative) to create other userspace interfaces, specific to each driver and not documented at V4L2 API:
bttv-driver.c:static CLASS_DEVICE_ATTR(card, S_IRUGO, show_card, NULL); et61x251_core.c:static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR, et61x251_core.c:static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR, et61x251_core.c:static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR, et61x251_core.c:static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, ov511.c:static CLASS_DEVICE_ATTR(custom_id, S_IRUGO, show_custom_id, NULL); ov511.c:static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL); ov511.c:static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_bridge, NULL); ov511.c:static CLASS_DEVICE_ATTR(sensor, S_IRUGO, show_sensor, NULL); ov511.c:static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); ov511.c:static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); ov511.c:static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); ov511.c:static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); ov511.c:static CLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL); pwc-if.c:static CLASS_DEVICE_ATTR(pan_tilt, S_IRUGO | S_IWUSR, show_pan_tilt, pwc-if.c:static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status, sn9c102_core.c:static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR, sn9c102_core.c:static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR, sn9c102_core.c:static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR, sn9c102_core.c:static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, sn9c102_core.c:static CLASS_DEVICE_ATTR(green, S_IWUGO, NULL, sn9c102_store_green); sn9c102_core.c:static CLASS_DEVICE_ATTR(blue, S_IWUGO, NULL, sn9c102_store_blue); sn9c102_core.c:static CLASS_DEVICE_ATTR(red, S_IWUGO, NULL, sn9c102_store_red); sn9c102_core.c:static CLASS_DEVICE_ATTR(frame_header, S_IRUGO, stv680.c:static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); usbvision-video.c:static CLASS_DEVICE_ATTR(version, S_IRUGO, show_version, NULL); usbvision-video.c:static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL); usbvision-video.c:static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); usbvision-video.c:static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); usbvision-video.c:static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); usbvision-video.c:static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); usbvision-video.c:static CLASS_DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); usbvision-video.c:static CLASS_DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); usbvision-video.c:static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL);
Quoted 1 line
From the above, you can clearly see that et62x251 and s9c102 provides an
interface to directly change a register at the device. The other drivers allows reading/changing a few controls directly via /proc (this is also possible, using V4L2 interface). This is not recommended, since V4L2 API should be the proper way to control the devices.
Quoted 1 line
From my POV, a driver that is creating its own userspace API is not
fully compliant with V4L2 API.
So, the proper fix is to make those drivers dependent of V4L1, where this kind of usage were valid.
Cheers,
Mauro
Re: [PATCH] v4l: fix build error for et61x251 driver
Quoted 97 lines · On Friday 14 September 2007 14:50:11 Mauro Carvalho Chehab wrote:
Quoted 36 lines
Quoted 1 line
Quoted 1 line
This patch is really ugly.
Well, yes. I should have known as I converted so many occurences of
to_video_devicetocontainer_ofin my second patch.Quoted 7 lines
Quoted 3 lines
Why can't the "
to_video_device()" macro be used? Just move it to a place where it's usable! IOW, what's wrong with the *much* simpler patch below?There's nothing wtong in my opinion. I do not know the exact reason why Mauro moved "
to_video_device()" intoCONFIG_VIDEO_V4L1_COMPAT. Pheraps he can give more details about this change.BTW, just a few V4L2 drivers and videodev seem to use this construct:
video/usbvision/usbvision-video.c: container_of(cd, structvideo_device,class_dev);
video/sn9c102/sn9c102_core.c: cam =
video_get_drvdata(container_of(cd, structvideo_device, video/sn9c102/sn9c102_core.c-class_dev));
video/videodev.c: structvideo_device*vfd = container_of(cd,
structvideo_device, video/videodev.c-class_dev);And then their are drivers with other variants of
container_of, e.g.:
video/pvrusb2/pvrusb2-v4l2.c: vp = container_of(chp,struct
pvr2_v4l2,channel);video/bt8xx/bttv-vbi.c: structbttv_buffer*buf =container_of(vb,struct bttv_buffer,vb); ...I think, there should be a
to_video_devicemacro for usage in v4l2. An most probable for the othercontainer_ofstuff (when more there is more than one occurence of a particular construct), drivers should provide their own macro, e.g.to_video_buffer()or so.Quoted 7 lines
That's what other subsystems do. It is more self-explanatory than a direct usage of
container_of.So why not apply (my first patch ... oh no, of course that's rubbish ;-) Linus' below patch for 2.6.23 to fix the compilation for that particular driver. And to work on the conversion of
container_of()stuff to meaningful macros for the next kernel release?The
to_video_deviceand thecontainer_of(cd, structvideo_device,class_dev) (as you noticed at the above drivers) are used to provide procfs interface.On videodev, there's the v4l2 core stuff, used on all V4L drivers. It allows some control to the V4L devices (basically, see/change the modprobe loading parameters).
The other drivers that uses
to_video_device(or thecontainer_ofalternative) to create other userspace interfaces, specific to each driver and not documented at V4L2 API:bttv-driver.c:static
CLASS_DEVICE_ATTR(card, S_IRUGO, show_card, NULL); et61x251_core.c:static CLASS_DEVICE_ATTR(reg,S_IRUGO|S_IWUSR, et61x251_core.c:static CLASS_DEVICE_ATTR(val,S_IRUGO|S_IWUSR, et61x251_core.c:static CLASS_DEVICE_ATTR(i2c_reg,S_IRUGO|S_IWUSR, et61x251_core.c:static CLASS_DEVICE_ATTR(i2c_val,S_IRUGO|S_IWUSR, ov511.c:staticCLASS_DEVICE_ATTR(custom_id, S_IRUGO, show_custom_id, NULL); ov511.c:staticCLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL); ov511.c:staticCLASS_DEVICE_ATTR(bridge, S_IRUGO, show_bridge, NULL); ov511.c:staticCLASS_DEVICE_ATTR(sensor, S_IRUGO, show_sensor, NULL); ov511.c:staticCLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); ov511.c:staticCLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); ov511.c:staticCLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); ov511.c:staticCLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
ov511.c:staticCLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL); pwc-if.c:static CLASS_DEVICE_ATTR(pan_tilt,S_IRUGO|S_IWUSR,show_pan_tilt, pwc-if.c:static CLASS_DEVICE_ATTR(button,S_IRUGO|S_IWUSR,show_snapshot_button_status, sn9c102_core.c:static CLASS_DEVICE_ATTR(reg,S_IRUGO|S_IWUSR,
sn9c102_core.c:static CLASS_DEVICE_ATTR(val,S_IRUGO|S_IWUSR, sn9c102_core.c:static CLASS_DEVICE_ATTR(i2c_reg,S_IRUGO|S_IWUSR, sn9c102_core.c:static CLASS_DEVICE_ATTR(i2c_val,S_IRUGO|S_IWUSR, sn9c102_core.c:staticCLASS_DEVICE_ATTR(green, S_IWUGO, NULL, sn9c102_store_green); sn9c102_core.c:staticCLASS_DEVICE_ATTR(blue, S_IWUGO, NULL, sn9c102_store_blue); sn9c102_core.c:staticCLASS_DEVICE_ATTR(red, S_IWUGO, NULL, sn9c102_store_red); sn9c102_core.c:static CLASS_DEVICE_ATTR(frame_header,S_IRUGO, stv680.c:staticCLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); usbvision-video.c:staticCLASS_DEVICE_ATTR(version, S_IRUGO, show_version, NULL); usbvision-video.c:staticCLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL); usbvision-video.c:staticCLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); usbvision-video.c:staticCLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); usbvision-video.c:staticCLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); usbvision-video.c:staticCLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); usbvision-video.c:staticCLASS_DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); usbvision-video.c:staticCLASS_DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); usbvision-video.c:staticCLASS_DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL);
Quoted 5 lines
From the above, you can clearly see that et62x251 and s9c102 provides an interface to directly change a register at the device. The other drivers allows reading/changing a few controls directly via /proc (this is also possible, using V4L2 interface). This is not recommended, since V4L2 API should be the proper way to control the devices.
through ioctl()? It's not as immediate and safe as controlling the device registers through /sysfs (not /proc). However, the sysfs interface in those drivers appeared before V4L2 had its own ioctls and we agreed to keep and export the interface to the only users selecting CONFIG_VIDEO_ADV_DEBUG (ok, this is actually valid for the sn9c102, I'll submit a patch for the et61x251 in the future).
Quoted 2 lines
From my POV, a driver that is creating its own userspace API is not fully compliant with V4L2 API.
Isn't Video4Linux2 ioctl() supersedeing sysfs in this case?
Quoted 2 lines
Cheers,
Mauro
Best regards
Luca Risolia
Re: [PATCH] v4l: fix build error for et61x251 driver
Quoted 6 lines
through
ioctl()? It's not as immediate and safe as controlling the device registers through /sysfs (not /proc). However, the sysfs interface in those drivers appeared before V4L2 had its own ioctls and we agreed to keep and export the interface to the only users selectingCONFIG_VIDEO_ADV_DEBUG(ok, this is actually valid for the sn9c102, I'll submit a patch for the et61x251 in the future).
Direct register access for debug ok, but not this is not ok for normal usage.
Quoted 6 lines
Quoted 4 lines
From my POV, a driver that is creating its own userspace API is not fully compliant with V4L2 API.
Isn't Video4Linux2
ioctl()supersedeing sysfs in this case?
It should be. However, things like direct register access (for non-debug mode) may allow some controls that weren't visible via ioctl. That's why the sysfs usage may be evil: a driver may have some parts accessible only via sysfs interface, on a non-standard way, without offering the official API support. So, some device functionalities may be hidden from userspace apps that are compliant with V4L2.
Summarizing:
Linus patch seems to be the better solution to solve the V4L1_COMPAT bug.
I would also convert the other container_of stuff to to_video_device (to have code uniformity).
et61x251 direct register interfaces should be available only if CONFIG_VIDEO_ADV_DEBUG is selected to avoid its miss-usage. If there are other device configurations that needs specific register settings not yet provided, this should be provided via V4L2 standard ioctls.
This way, et61x251 will be compliant with V4L2.
I still think that we should work at the remaining sysfs classes to make them coherent on all V4L devices.
Cheers,
Mauro.