On Wed, 16 Oct 2013 13:53:56 +0200 Frederic Weisbecker <fweis...@gmail.com> wrote:
> static int done; > > if (!done) { > trace_printk(something); > trace_printk(something else); > trace_dump_stack(); > done = 1; > } > > Having a DO_ONCE() would help a lot I think. > > Now we can rename it to __DO_ONCE() and put a big fat comment to avoid it > to be misused. I wonder if we should make it just ONCE(), with no arguments that should go into an if statement. if (ONCE()) do_this_function_once(); Where ONCE() is: ({ static int __once; int __old_once = __once; __once = 1; __old_once; }) Or the xchg version: ({ static int __once; if (!__once) xchg(&__once, 1); else 1; }) -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/