Re: [patch 01/03] USB: USB/IP: add common functions needed

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <greg@...>
Cc: <linux-usb@...>, <linux-kernel@...>, <bgmerrell@...>, <hirofuchi@...>, <gregkh@...>
Date: Friday, August 29, 2008 - 8:14 pm

On Thu, 28 Aug 2008 16:00:31 -0700
greg@kroah.com wrote:

> From: Takahiro Hirofuchi

Local variable `flag' is unneeded.

It's a bit sloppy that a user can do

echo wibble > /sys/whatever-file-this-is

and that will set usbip_debug_flag to zero. We should have a library
function somewhere which can be used for this very common pattern.

Something like

/*
* Convert an optionally NULL-terminated digit string into a long. Returns
* a -ve errno if an invalid character was detected. Otherwise returns the
* number of characters whcih were consumed from the input.
*/
int sysfs_parse_long(const char *buf, long *ret)
{
...
}

then the above becomes

static ssize_t store_flag(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
return sysfs_parse_long(buf, &usbip_debug_flag);
}

(probably wrong, but you get the idea).

> +DEVICE_ATTR(usbip_debug, (S_IRUGO | S_IWUSR), show_flag, store_flag);

> +

Please use lib/hexdump.c

> +static void usbip_dump_pipe(unsigned int p)

There's a heck of a lot of debugging code there. It'd be good to have
some way of making it config-time optional, if it isn't already.

> +/*-------------------------------------------------------------------------*/

no no no no no. Use the kthread interface.

> +void usbip_start_threads(struct usbip_device *ud)

ditto

> +void usbip_task_init(struct usbip_task *ut, char *name,

hey, that's networking stuff. Someone tell the networking developers?

> +int usbip_xmit(int send, struct socket *sock, char *buf,

Use get_task_comm() here.

> + else

typo.

> +

ditto

> + else

ditto

> +

kill this?

> +int setquickack(struct socket *socket)

Can file->f_dentry->d_inode ever be NULL??

> + socket = SOCKET_I(inode);

flags &= ~(URB_NO_TRANSFER_DMA_MAP|URB_NO_SETUP_DMA_MAP);

> + return flags;

Do all these kzalloc()s really need to zero out the memory?

> + if (!buff)

can `size' really be less than zero?

> + ret = usbip_xmit(0, ud->tcp_socket, (char *)urb->transfer_buffer,

?

> + */

Is it appropriate that this be under CONFIG_USB_DEBUG? Or should there
be a usbip-specific config variable?

> +#define udbg(fmt, args...) \

There are four duplicates there. That seems odd.

> +};

This header adds a lot of symbols which have fairly generic-sounding
names and which don't have "usbip" within them. There is a risk that
we will later clash with some other header file's dbg_sysfs.

> +

These two are risky also.

> +

I assume the below data structures are known about by userspace?

If so, the comment should make that very very clear. This is part of
the kernel ABI.

Is this interface versioned? If not, should it be?

This header doesn't appear to have __KERNEL__ guards. Should we be
aiming to be able to use this header directly within userspace
compilation?

> +/*

kill?

> +int setnodelay(struct socket *);

hm. So we sit there waiting for a wakeup and each time one occurs we
will assume that there is a single event waiting at ut->event.

I don't see handshaking in event_handler(). It looks like this will be
rich with races and overruns. But I didn't look for the sending side.

> +void usbip_start_eh(struct usbip_device *ud)

"happened"

> +{

"happened"

> + spin_lock(&ud->lock);

It all does look rather racy. In what context does usbip_recv_iso()
get called? I hope it isn't rx interrupt :(

> --- a/drivers/usb/Kconfig

--

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 00/03] USB-IP patches, , (Thu Aug 28, 7:00 pm)
Re: [patch 00/03] USB-IP patches, Brian G. Merrell, (Sat Aug 30, 1:50 am)
Re: [patch 00/03] USB-IP patches, Greg KH, (Tue Sep 2, 1:12 pm)
Re: [patch 00/03] USB-IP patches, Brian G. Merrell, (Tue Sep 23, 9:28 pm)
Re: [patch 00/03] USB-IP patches, Arnaldo Carvalho de Melo, (Thu Aug 28, 7:06 pm)
Re: [patch 03/03] USB: USB/IP: add host driver, Willy Tarreau, (Fri Aug 29, 1:43 am)
Re: [patch 02/03] USB: USB/IP: add client driver, Alan Stern, (Fri Aug 29, 12:02 pm)
Re: [patch 02/03] USB: USB/IP: add client driver, Oliver Neukum, (Fri Aug 29, 4:23 am)
Re: [patch 01/03] USB: USB/IP: add common functions needed, Andrew Morton, (Fri Aug 29, 8:14 pm)