mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@infradead.org>
To: aherrman@arcor.de
Cc: Luca Risolia <luca.risolia@studio.unibo.it>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	akpm@linux-foundation.org, linux-usb-devel@lists.sourceforge.net,
	video4linux-list@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] v4l: fix build error for et61x251 driver
Date: Fri, 14 Sep 2007 09:50:11 -0300	[thread overview]
Message-ID: <1189774211.5292.44.camel@gaivota> (raw)
In-Reply-To: <20070914074852.GA5598@devil>

> > > 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.
> 
> > > 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.
> 
> 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?

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);

>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.

>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


  reply	other threads:[~2007-09-14 12:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-13 12:36 [PATCH] v4l: Build error with et61x251, if V4L1_COMPAT is not selected aherrman
2007-09-13 15:07 ` Luca Risolia
2007-09-13 22:06   ` aherrman
2007-09-13 22:27   ` [PATCH] v4l: fix build error for et61x251 driver Andreas Herrmann
2007-09-13 22:28     ` Luca Risolia
2007-09-14  0:09       ` Linus Torvalds
2007-09-14  1:53         ` Luca Risolia
2007-09-14  7:48           ` aherrman
2007-09-14 12:50             ` Mauro Carvalho Chehab [this message]
2007-09-14 13:57               ` Luca Risolia
2007-09-14 15:56                 ` Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1189774211.5292.44.camel@gaivota \
    --to=mchehab@infradead.org \
    --cc=aherrman@arcor.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=luca.risolia@studio.unibo.it \
    --cc=torvalds@linux-foundation.org \
    --cc=video4linux-list@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®