From: Oliver Neukum <oliver@neukum.org>
To: Greg KH <greg@kroah.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
USB list <linux-usb@vger.kernel.org>,
Stefan Kopp <stefan_kopp@agilent.com>,
Marcel Janssen <korgull@home.nl>,
Felipe Balbi <me@felipebalbi.com>,
Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] USB: add USB test and measurement class driver - round 2
Date: Thu, 28 Aug 2008 23:29:33 +0200 [thread overview]
Message-ID: <200808282329.34780.oliver@neukum.org> (raw)
In-Reply-To: <20080828161702.GB18132@kroah.com>
> > > + buffer[4] = (this_part - 12 - 3) & 255;
> > > + buffer[5] = ((this_part - 12 - 3) >> 8) & 255;
> > > + buffer[6] = ((this_part - 12 - 3) >> 16) & 255;
> > > + buffer[7] = ((this_part - 12 - 3) >> 24) & 255;
> >
> > We have excellent endianness conversion macros.
>
> For splitting values up into the individual byte portions? I think this
> is far more obvious as to exactly what is going on, don't you?
No. Kernel code does not exist to show how to do endianness conversion.
We have clearly labeled functions.
> > > + buffer[8] = data->TermCharEnabled * 2;
> > > + /* Use term character? */
> >
> > smp_rmb(); /* we must make sure we don't read a stale terminator */
>
> I'm not going to worry about races here, that's not a real issue.
There is no such thing as an ignorable race. On second thought
you can take the mutex in the sysfs handlers. That will also do the job.
> > This and usbtmc_read() need a test for disconnection. Open() and disconnect
> > are guarded in usbcore, read & write are not. By reference count you've made
> > sure you have a valid device descriptor, but the device may have been reprobed.
>
> If so, then struct usb_device would be different, right? Oh, I see,
> disconnect() using usbfs/sysfs. Bah, is it really something that
> happens in the real world? Oh well, I'll go fix this...
This is oopsable from user space.
> > If you ignore an error return, be open about it.
>
> I'm not? Should I print an error and then just continue on? Would that
> be sufficient?
Yes.
> > > +static void usbtmc_disconnect(struct usb_interface *intf)
> > > +{
> > > + struct usbtmc_device_data *data;
> > > +
> > > + dev_dbg(&intf->dev, "usbtmc_disconnect called\n");
> > > +
> >
> > You must set a flag for read, write and ioctl.
>
> Will do. Then I need to lock the flag with a mutex, right?
Yes. You can set the intf pointer to NULL. That's sort of idiomatic.
And you should NULL intfdata.
Regards
Oliver
next prev parent reply other threads:[~2008-08-28 21:28 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-27 17:20 Greg KH
2008-08-27 18:28 ` Alan Stern
2008-08-27 18:36 ` Greg KH
2008-08-27 18:58 ` Alan Stern
2008-08-27 19:05 ` Oliver Neukum
2008-08-27 19:16 ` Alan Stern
2008-08-27 23:48 ` Greg KH
2008-08-27 23:47 ` Greg KH
2008-08-28 10:10 ` Oliver Neukum
2008-08-28 16:17 ` Greg KH
2008-08-28 21:29 ` Oliver Neukum [this message]
2008-08-28 16:58 ` Marcel Janssen
2008-08-28 20:38 ` Greg KH
2008-08-29 6:57 ` stefan_kopp
2008-08-29 7:46 ` Oliver Neukum
2008-08-29 8:14 ` stefan_kopp
2008-08-29 8:34 ` Oliver Neukum
2008-08-29 9:13 ` stefan_kopp
2008-08-29 11:33 ` Oliver Neukum
2008-08-29 14:39 ` Greg KH
2008-08-29 16:41 ` Marcel Janssen
2008-08-29 20:01 ` Greg KH
2008-08-27 18:37 ` Oliver Neukum
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=200808282329.34780.oliver@neukum.org \
--to=oliver@neukum.org \
--cc=greg@kroah.com \
--cc=korgull@home.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=me@felipebalbi.com \
--cc=stefan_kopp@agilent.com \
--cc=stern@rowland.harvard.edu \
/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®