mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Janne Grunau <j@jannau.net>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Jarod Wilson <jwilson@redhat.com>,
	linux-kernel@vger.kernel.org,
	Christoph Bartelmus <lirc@bartelmus.de>,
	dconti@acm.wwu.edu
Subject: Re: [PATCH 03/18] lirc driver for 1st-gen Media Center Ed. USB IR transceivers
Date: Wed, 10 Sep 2008 01:59:32 +0200	[thread overview]
Message-ID: <200809100159.32524.j@jannau.net> (raw)
In-Reply-To: <20080909132140.3c0adcca@bike.lwn.net>

On Tuesday 09 September 2008 21:21:40 Jonathan Corbet wrote:
>
> > + * 2003_11_11 - Restructured to minimalize code interpretation in
> > the + *	      driver. The normal use case will be with lirc.
> > + *
> > + * 2004_01_01 - Removed all code interpretation. Generate mode2
> > data + *	      for passing off to lirc. Cleanup
> > + *
> > + * 2004_01_04 - Removed devfs handle. Put in a temporary
> > workaround + *	      for a known issue where repeats generate two
> > + *	      sequential spaces (last_was_repeat_gap)
> > + *
> > + * 2004_02_17 - Changed top level api to no longer use fops, and
> > + *	      instead use new interface for polling via
> > + *	      lirc_thread. Restructure data read/mode2 generation to
> > + *	      a single pass, reducing number of buffers. Rev to .2
> > + *
> > + * 2004_02_27 - Last of fixups to plugin->add_to_buf API. Properly
> > + *	      handle broken fragments from the receiver. Up the
> > + *	      sample rate and remove any pacing from
> > + *	      fetch_more_data. Fixes all known issues.
>
> General convention is that this sort of changelog information belongs
> in the SCM, not in the code.  That's doubly true for the USB skeleton
> driver info.

I don't really care and I agree that the SCM is the preferred place for 
the information. The only problem is that the info is in a different 
SCM (lirc cvs repository).

I've removed the changelogs from all files as long as no names wre 
mentioned.

> > +#include <linux/smp_lock.h>
>
> It doesn't look like this include is needed.

removed

> > +/* Structure to hold all of our device specific stuff */
> > +struct usb_skel {
>
> Perhaps renaming this structure to something more directly
> descriptive would make sense?

renamed to mceusb_device

> > +	struct usb_device *udev; /* save off the usb device pointer */
> > +	struct usb_interface *interface; /* the interface for this device
> > */ +	unsigned char minor;	 /* the starting minor number for this
> > device */
>
> Minor numbers don't necessarily fit in an unsigned char.
>
> > +	unsigned char num_ports; /* the number of ports this device has
> > */ +	char num_interrupt_in;	 /* number of interrupt in endpoints */
> > +	char num_bulk_in;	 /* number of bulk in endpoints */
> > +	char num_bulk_out;	 /* number of bulk out endpoints */
> > +
> > +	unsigned char *bulk_in_buffer;	/* the buffer to receive data */
> > +	int bulk_in_size;		/* the size of the receive buffer */
> > +	__u8 bulk_in_endpointAddr;	/* the address of bulk in endpoint */
> > +
> > +	unsigned char *bulk_out_buffer;	/* the buffer to send data */
> > +	int bulk_out_size;		/* the size of the send buffer */
> > +	struct urb *write_urb;		/* the urb used to send data */
> > +	__u8 bulk_out_endpointAddr;	/* the address of bulk out endpoint
> > */ +
> > +	atomic_t write_busy;		/* true iff write urb is busy */
> > +	struct completion write_finished; /* wait for the write to finish
> > */ +
> > +	wait_queue_head_t wait_q; /* for timeouts */
> > +	int open_count;		/* number of times this port has been opened */
> > +	struct mutex sem;	/* locks this structure */
>
> "sem" is not a semaphore; it should probably have a different name.

renamed to lock

> > +static void mceusb_setup(struct usb_device *udev)
> > +{
> > +	char data[8];
> > +	int res;
> > +
> > +	memset(data, 0, 8);
> > +
> > +	/* Get Status */
> > +	res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
> > +			      USB_REQ_GET_STATUS, USB_DIR_IN,
> > +			      0, 0, data, 2, HZ * 3);
>
> res is set many times in this function, but it is never checked.  It
> seems to me like the addition of some error handling would be a good
> idea.

sigh, It would be a good idea, not sure if I'm motivated enough to add 
that to a driver I can't test and I know almost nothing about.


> > +	/* These two are sent by the windows driver, but stall for
> > +	 * me. I dont have an analyzer on the linux side so i can't
> > +	 * see what is actually different and why the device takes
> > +	 * issue with them
> > +	 */
>
> Hmm...how was that information obtained?  If this driver was
> reverse-engineered, it would be good to know just what process was
> followed.

That's probably a question for the original author, Dan. CC added. I'm 
just cleaning them up for kernel inclusion.

> > +static int msir_fetch_more_data(struct usb_skel *dev, int
> > dont_block) +{
>
> ...
>
> > +			/* retry a few times on overruns; map all
> > +			   other errors to -EIO */
> > +			if (retval) {
> > +				if (retval == -EOVERFLOW && retries < 5) {
> > +					retries++;
> > +					interruptible_sleep_on_timeout(
> > +						&dev->wait_q, HZ);
> > +					continue;
>
> As others have noted, I think, getting new sleep_on() calls into the
> kernel is kind of a hard sell.

there are more, I'll fix them all before the next patchset get posted. 

> ...
>
> > +
> > +	/* select a "subminor" number (part of a minor number) */
> > +	down(&minor_table_mutex);
>
> So...this driver has a mutex called "sem" and a semaphore called
> "minor_table_mutex".  I suspect that minor_table_mutex should, in
> fact, be a mutex.

yes, the declaration looks like this:
static DECLARE_MUTEX(...);

which gives us a single holder semaphore. the static in front of 
DECLARE_MUTEX() fools checkpatch. changed to to DEFINE_MUTEX, also in 
two other drivers.

>
> ...
>
> > +error:
> > +	mceusb_delete(dev);
> > +	dev = NULL;
> > +	dprintk("%s: retval = %x", __func__, retval);
> > +	up(&minor_table_mutex);
> > +	return retval;
> > +}
>
> This will leak the memory allocated for dev.  It also leaves the
> entry in minor_table pointing to a nonfunctional device.

fixed.

Thanks for the review.

Janne


  reply	other threads:[~2008-09-09 23:59 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-09  4:05 [PATCH 0/18] linux infrared remote control drivers Jarod Wilson
2008-09-09  4:05 ` [PATCH 01/18] lirc core device driver infrastructure Jarod Wilson
2008-09-09  4:05   ` [PATCH 02/18] lirc serial port receiver/transmitter device driver Jarod Wilson
2008-09-09  4:05     ` [PATCH 03/18] lirc driver for 1st-gen Media Center Ed. USB IR transceivers Jarod Wilson
2008-09-09  4:05       ` [PATCH 04/18] lirc driver for 2nd-gen and later " Jarod Wilson
2008-09-09  4:05         ` [PATCH 05/18] lirc driver for i2c-based IR receivers Jarod Wilson
2008-09-09  4:05           ` [PATCH 06/18] lirc driver for the ATI USB RF remote receiver Jarod Wilson
2008-09-09  4:05             ` [PATCH 07/18] lirc driver for the CommandIR USB Transceiver Jarod Wilson
2008-09-09  4:05               ` [PATCH 08/18] lirc driver for the Soundgraph IMON IR Receivers Jarod Wilson
2008-09-09  4:05                 ` [PATCH 09/18] lirc driver for the Streamzap PC Receiver Jarod Wilson
2008-09-09  4:05                   ` [PATCH 10/18] lirc driver for Igor Cesko's USB IR receiver Jarod Wilson
2008-09-09  4:05                     ` [PATCH 11/18] lirc driver for the Technotrend " Jarod Wilson
2008-09-09  4:05                       ` [PATCH 12/18] lirc driver for the Sasem OnAir and Dign HV5 receivers Jarod Wilson
2008-09-09  4:05                         ` [PATCH 13/18] lirc driver for ITE8709 CIR port receiver Jarod Wilson
2008-09-09  4:05                           ` [PATCH 14/18] lirc driver for the ITE IT87xx CIR Port receivers Jarod Wilson
2008-09-09  4:06                             ` [PATCH 15/18] lirc driver for the SIR IrDA port Jarod Wilson
2008-09-09  4:06                               ` [PATCH 16/18] lirc driver for the IR interface on BT829-based hardware Jarod Wilson
2008-09-09  4:06                                 ` [PATCH 17/18] lirc driver for homebrew parallel port receivers Jarod Wilson
2008-09-09  4:06                                   ` [PATCH 18/18] lirc driver for the zilog/haupauge IR transceiver Jarod Wilson
2008-09-09  4:06                                     ` Jarod Wilson
2008-09-11 15:22                   ` [PATCH 09/18] lirc driver for the Streamzap PC Receiver Jonathan Corbet
2008-09-10 21:02                 ` [PATCH 08/18] lirc driver for the Soundgraph IMON IR Receivers Jonathan Corbet
2008-09-10 21:23                   ` Janne Grunau
2008-09-11  3:22                     ` Jarod Wilson
2008-09-22 21:47                   ` Jarod Wilson
2008-09-24 20:21                     ` Jarod Wilson
2008-09-10 17:09               ` [PATCH 07/18] lirc driver for the CommandIR USB Transceiver Jonathan Corbet
2008-09-11 18:24                 ` Christoph Bartelmus
     [not found]                   ` <1221159005.13683.34.camel@minimatt>
2008-09-11 19:03                     ` Jarod Wilson
2008-09-11 19:14                     ` Janne Grunau
2008-09-25 15:21                 ` Jarod Wilson
2008-09-10  9:58             ` [PATCH 06/18] lirc driver for the ATI USB RF remote receiver Ville Syrjälä
2008-09-10 13:05               ` Jarod Wilson
2008-09-10 13:14                 ` Christoph Hellwig
2008-09-10 13:37                   ` Jon Smirl
2008-09-10 14:30                     ` Dmitry Torokhov
2008-09-10 13:44                   ` Janne Grunau
2008-09-10 14:13                     ` Jarod Wilson
2008-09-10 14:19                     ` Christoph Hellwig
2008-09-10 14:08                 ` Ville Syrjälä
2008-09-10 14:37                   ` Dmitry Torokhov
2008-09-09  4:13           ` [PATCH 05/18] lirc driver for i2c-based IR receivers Jarod Wilson
2008-09-10 15:42           ` Jonathan Corbet
2008-09-09 23:30         ` [PATCH 04/18] lirc driver for 2nd-gen and later Media Center Ed. USB IR transceivers Jonathan Corbet
2008-09-10  0:36           ` Janne Grunau
2008-09-11  9:21           ` Adrian Bunk
2008-09-09 19:21       ` [PATCH 03/18] lirc driver for 1st-gen " Jonathan Corbet
2008-09-09 23:59         ` Janne Grunau [this message]
2008-09-10  1:39           ` Jarod Wilson
2008-09-10  0:04         ` Janne Grunau
2008-09-09 16:14     ` [PATCH 02/18] lirc serial port receiver/transmitter device driver Jonathan Corbet
2008-09-09 19:51       ` Stefan Lippers-Hollmann
2008-09-09 19:56         ` Jarod Wilson
2008-09-10 17:40       ` Jarod Wilson
2008-09-09  7:40   ` [PATCH 01/18] lirc core device driver infrastructure Sebastian Siewior
2008-09-09  9:53     ` Janne Grunau
2008-09-09 12:33       ` Sebastian Siewior
2008-09-09 13:10         ` Janne Grunau
2008-09-11 16:41       ` Christoph Bartelmus
2008-09-09 11:13     ` Alan Cox
2008-09-09 13:27     ` Stefan Richter
2008-09-09 17:03     ` Jarod Wilson
2008-09-11 18:30       ` Christoph Bartelmus
2008-09-11 19:09         ` Jarod Wilson
2008-09-13  7:21           ` Christoph Bartelmus
2008-09-09  9:46   ` Andi Kleen
2008-09-09 11:35     ` Janne Grunau
2008-09-09 13:03       ` Andi Kleen
2008-09-09 13:20         ` Janne Grunau
2008-09-12 16:46           ` Greg KH
2008-09-09 13:01   ` Christoph Hellwig
2008-09-10 12:24     ` Janne Grunau
2008-09-10 12:29       ` Christoph Hellwig
2008-09-10 12:45         ` Janne Grunau
2008-09-11 18:03       ` Christoph Bartelmus
2008-09-11 19:18         ` Janne Grunau
2008-09-12  0:16     ` Janne Grunau
2008-09-12  8:33       ` Christoph Hellwig
2008-09-12 14:51         ` Jarod Wilson
2008-09-09 15:33   ` Jonathan Corbet
2008-09-12  0:12     ` Janne Grunau
2008-09-10 13:08   ` Dmitry Torokhov
2008-09-11  8:47     ` Gerd Hoffmann
2008-09-11 21:28       ` Maxim Levitsky
2008-09-13  7:20         ` Christoph Bartelmus
2008-09-12  4:44       ` Dmitry Torokhov
2008-09-09  4:36 ` [PATCH 0/18] linux infrared remote control drivers Chris Wedgwood
2008-09-09  7:06 ` Alexey Dobriyan
2008-09-09  8:32   ` Janne Grunau
2008-09-09 12:46 ` Christoph Hellwig
2008-09-09 15:23   ` Jarod Wilson
2008-09-09 18:27     ` Lennart Sorensen
2008-09-09 18:34       ` Jarod Wilson
2008-09-09 15:34   ` Jon Smirl

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=200809100159.32524.j@jannau.net \
    --to=j@jannau.net \
    --cc=corbet@lwn.net \
    --cc=dconti@acm.wwu.edu \
    --cc=jwilson@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lirc@bartelmus.de \
    /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®