Re: [linux-usb-devel] device struct bloat

From: David Brownell
Date: Mon Nov 05 2007 - 20:38:47 EST


On Monday 05 November 2007, Greg KH wrote:
> --- linux-2.6-2.orig/drivers/spi/spi.c
> +++ linux-2.6-2/drivers/spi/spi.c

It'd be quicker to end up in the right hands if you had
split this big and random patch according to subsystem...

There's already a patch in the MM queue that removes
the SPI-private semaphore. Except that it's missing
the bug noted below.

The class semaphore removal would be a different issue.


> @@ -613,7 +613,7 @@ int spi_write_then_read(struct spi_devic
>         }
>  
>         /* ... unless someone else is using the pre-allocated buffer */
> -       if (down_trylock(&lock)) {
> +       if (mutex_trylock(&lock)) {

According to its kerneldoc, mutex_trylock() follows the
spinlock model not the semaphore model. So the sense of
this test is incorrect ... as will be any similar changes
in other parts of this patch:

* NOTE: this function follows the spin_trylock() convention, so
* it is negated to the down_trylock() return values! Be careful
* about this when converting semaphore users to mutexes.

So the patch in the MM queue says "if (!mutex_trylock(...)) {

>                 local_buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL);
>                 if (!local_buf)
>                         return -ENOMEM;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/