lkml.org 
[lkml]   [2008]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] USB: add USB test and measurement class driver - round 2
Date

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




\
 
 \ /
  Last update: 2008-08-28 23:31    [W:0.032 / U:44.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site