Re: [PATCH] USB: add Sensoray 2255 v4l driver

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mauro Carvalho Chehab
Date: Thursday, May 15, 2008 - 7:51 pm

Hi Greg and Dean,

In general, the driver seems sane and almost ready for their kernel inclusion.
However, there were several videobuf changes affecting mostly the users of
videobuf-vmalloc during the last kernel development cycle, to fix lock issues.
The code should be reviewed at the light of the latest version, and tested. The
good news is that the videobuf handler will be simpler, but a lock is now required.

I have other comments to help improving the driver quality.

Btw, I noticed the lack of Dean's SOB. Is this intentional?

Cheers,
Mauro.

On Wed, 14 May 2008 13:59:27 -0700
Greg KH <greg@kroah.com> wrote:



It seems a little dangerous to use just DIR_IN/DIR_OUT, since a future change
on a kernel header could cause namespace conflict. IMO, the better is to rename
those macros to something more specific, like S2255_DIR_IN.

The same comment is also true to struct and other namespace definitions, like
"framei", "bufferi", etc.


Why to reserve 32 integers here? While this may have some sense at userspace
API, I can't see any reason to use this internally.


Just those two norms? Are you sure it doesn't support the other european PAL
variants (PAL/G, PAL/D, PAL/K)?


Hmmm... what happens if the user plugs two or more of such devices?


This seems to be violating CodingStyle. It should be something like:
	{
		.id = foo,
<snip/>
	}, {

The same applies also to other structs. The better is to check the patch with
checkpatch.pl, since other violations might be present.


As already discussed, the driver should support only the video standards
supported by the hardware. colorspace conversion can happen at userspace apps.


I saw another discussion about this.

I like the idea of loading firmware asynchronously, provided that you block at
open() or at ioctl(), if the user requested to open before having the firmware
loaded.


This is probably obsolete. We've cleaned up those code. The better is to take a
look at videobuf implementation at em28xx-video, where some lock bugs were fixed and the
code were simplified. I don't have your hardware to test, but I suspect that
the driver suffers some bugs at videobuf implementation that we've removed recently.


Better to use "strlcpy" instead of just "strcpy", to avoid the risk of buffer
overflow. Ok, currently, there's no risk, but, if tomorrow someone changes
something here, the bug will emerge.

Also, please fill bus info, with something like:

	strlcpy(cap->bus_info, dev->udev->dev.bus_id, sizeof(cap->bus_info));

This is required for some udev implementations to properly work.


The implementation you did is not generic enough for videodev2. I agree that we
may improve the implementation of try_fmt/s_fmt at videobuf2. Feel free to
propose such improvements.

There are now a videobuf method to implement vidiocgmbuf. The better is to use
it, instead of duplicating the code.


This define here sounds strange. I would move it to the beginning at the
driver. Better to write a short comment about this magic number.


The sleep above seems a hack to my eyes. The better is to protect with a
spinlock. The current code, at vivi and em28xx already prevents such issues (at
least, it went fine at the tests we did).


Also, the timeout is obsolete


No. NTSC/M is just one variant of NTSC, used on US/Canada. There are other
variants at Asia, in Korea and Japan. The difference is at the audio carrier.


Also, PAL/B is just one variant. 

A proper code would be to do this:
	if (*i & V4L2_STD_PAL)

(notice that the equal operator were replaced by the logical operation _AND_.
This covers all european PAL. However, this mask doesn't cover PAL/N, PAL/Nc
and PAL/M.

If all you need is to check if the video mode is 50Hz/60Hz, the proper code would be, instead:

	if (*i & V4L2_STD_525_60)
		/* some logic for NTSC/M, PAL/M and PAL/60 */
	else
		/* some logic for the other PAL variations and SECAM */


The invalid combinations should be tested, to avoid OOPSes and other bad behaviours.


You have just a few controls. However, the better would be to use a switch(),
since the compiler can reorder the operations to improve the code speed and
size.


It seems too hard to return ENODEV. Couldn't the driver try again to load the
firmware here?


Argh. I would use a wait_event_timeout() instead, and use a higher timeout value. 

Also, it seems that fw_state needs to be atomic.


Hmm... I'm in doubt if we should return, instead, -EBUSY.


This seems weird. Why to release the firmware?


In this case, it should return -EBUSY.



Instead of incrementing the usage, printing the open message just to discover
that you don't have enough memory, I would move the users increment and the
dprintk to happen after the allocation of fh.


You'll need to define a spinlock for videoqueue, otherwise the kernel will now
complain. Please test your code against the latest development version (or the
latest code at mainstream).
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] USB: add Sensoray 2255 v4l driver, Greg KH, (Wed May 14, 1:59 pm)
Re: [v4l-dvb-maintainer] [PATCH] USB: add Sensoray 2255 v4 ..., Markus Rechberger, (Wed May 14, 6:17 pm)
Re: [PATCH] USB: add Sensoray 2255 v4l driver, Oliver Neukum, (Thu May 15, 4:38 am)
Re: [PATCH] USB: add Sensoray 2255 v4l driver, Oliver Neukum, (Thu May 15, 5:03 am)
Re: [v4l-dvb-maintainer] [PATCH] USB: add Sensoray 2255 v4 ..., Markus Rechberger, (Thu May 15, 9:57 am)
Re: [PATCH] USB: add Sensoray 2255 v4l driver, Greg KH, (Thu May 15, 11:44 am)
Re: [PATCH] USB: add Sensoray 2255 v4l driver, Oliver Neukum, (Thu May 15, 12:54 pm)
Re: [PATCH] USB: add Sensoray 2255 v4l driver, Greg KH, (Thu May 15, 1:10 pm)
Re: [PATCH] USB: add Sensoray 2255 v4l driver, Oliver Neukum, (Thu May 15, 1:13 pm)
Re: [PATCH] USB: add Sensoray 2255 v4l driver, Mauro Carvalho Chehab, (Thu May 15, 7:51 pm)
Re: [v4l-dvb-maintainer] [PATCH] USB: add Sensoray 2255 v4 ..., Mauro Carvalho Chehab, (Thu May 15, 7:59 pm)
Re: [PATCH] USB: add Sensoray 2255 v4l driver, Oliver Neukum, (Thu May 15, 11:28 pm)
Re: [PATCH] USB: add Sensoray 2255 v4l driver, Mauro Carvalho Chehab, (Fri May 16, 8:34 am)
Re: [PATCH] USB: add Sensoray 2255 v4l driver, Oliver Neukum, (Fri May 16, 9:04 am)
Re: [PATCH] USB: add Sensoray 2255 v4l driver, Mauro Carvalho Chehab, (Fri May 16, 11:17 am)