On Sat, 20 Nov 2004, David Brownell wrote:
> 
> I thought I'd poke at the "sparse" lock checking stuff too,
> and as I half expected, it didn't like the way all the HCDs
> temporarily yield their spinlocks while calling out to URB
> completion handlers.  But a fix to remove the warnings is
> simple, just use a construct something like this to annotate
> those functions that call usb_hcd_giveback_urb():
> 
>       #ifdef __CHECKER__
>       #define __yields(x)     __attribute__((context(1,1)))
>       #else
>       #define __yields(x)
>       #endif

Please don't do it that way. At the very least, don't rely on internal 
sparse stuff that may change some day. What you really want is just

        /* Shorthand for "release and reaquire" lock x */
        #define __yields(x) __releases(x) __acquires(x)

which is a lot more readable, doesn't need any __CHECKER__ checks, and 
actually tells the user what "__yields()" means (even without the comment 
it's half-way readable: comments are good, but even better is code that 
you can follow even without them. The combination of both is best).

Right now the lock information is totally ignored by sparse, but hey, I 
may want to fix that some day. When I do, the syntax for specifying the 
lock may well change, and I'll have to fix up all the annotations, but for 
now the lock-specification is act least there for human-readability.

Also, considering that there hopefully aren't that many of these things, 
maybe it's easier to just write the thing out every time, ie

        int my_hcd_function(...)
                __releases(ehci->lock)
                __acquires(ehci->lock)
        {
                ...
        }

since the "__yields()" shorthand really doesn't buy you all that much 
unless it's a really common operation. 

But regardless, I really would not want people to use sparse-internal 
syntax for things like this.

                Linus


-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to