On Mon, 2010-12-20 at 16:54 +0000, Mark Brown wrote:
On Mon, Dec 20, 2010 at 05:47:13PM +0100, Takashi Iwai wrote:
Yes, this would be safer. I didn't put it since I wasn't sure whether BUG() content is also expanded at each caller. If yes, it would bloat. (Alternatively we may use snd_BUG_ON() -- it's built in only when CONFIG_SND_DEBUG is set.)
That's entirely up to the compiler - inline is purely advice and may well be completely ignored by the compile (and of course functions that aren't marked inline may be inlined if it decides that's useful).
One way to enforce the expansion of inline functions on gcc is to use __attribute__ ((always_inline)). Generally it is best left up to the compiler to perform the inling if it so deems necessary.
One reason for making it a BUG() is that if we get far enough for the check to go off when doing actual register lookups we've hit a definite bug in the code.
By performing the check at *_init, it will be impossible for the code to ever reach any of the read()/write() functions if an unsupported word size has been passed in. The downside is that we depend on the implementers of the *_init functions to perform this check.
Thanks, Dimitrios