From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751701AbcF0JPV (ORCPT ); Mon, 27 Jun 2016 05:15:21 -0400 Received: from mail.skyhub.de ([78.46.96.112]:35971 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751215AbcF0JPU (ORCPT ); Mon, 27 Jun 2016 05:15:20 -0400 Date: Mon, 27 Jun 2016 11:15:04 +0200 From: Borislav Petkov To: Joe Perches Cc: LKML , Andrew Morton , Andy Lutomirski , X86 ML Subject: [PATCH -v2 2/3] printk: Make the printk*once() variants return a value Message-ID: <20160627091504.GA26674@nazgul.tnic> References: <20160624083020.26871-1-bp@alien8.de> <20160624083020.26871-3-bp@alien8.de> <1466775784.1847.60.camel@perches.com> <20160625110119.GB5671@nazgul.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160625110119.GB5671@nazgul.tnic> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Borislav Petkov Date: Thu, 23 Jun 2016 10:41:30 +0200 Subject: [PATCH] printk: Make the printk*once() variants return a value Have printk*once() return a bool which denotes whether the string was printed or not so that calling code can react accordingly. Signed-off-by: Borislav Petkov Cc: Andrew Morton --- v2: Wrap __ret_print_once in unlikely. include/linux/printk.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/include/linux/printk.h b/include/linux/printk.h index f4da695fd615..f136b22c7772 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -108,11 +108,14 @@ struct va_format { * Dummy printk for disabled debugging statements to use whilst maintaining * gcc's format checking. */ -#define no_printk(fmt, ...) \ -do { \ - if (0) \ - printk(fmt, ##__VA_ARGS__); \ -} while (0) +#define no_printk(fmt, ...) \ +({ \ + do { \ + if (0) \ + printk(fmt, ##__VA_ARGS__); \ + } while (0); \ + 0; \ +}) #ifdef CONFIG_EARLY_PRINTK extern asmlinkage __printf(1, 2) @@ -309,20 +312,24 @@ extern asmlinkage void dump_stack(void) __cold; #define printk_once(fmt, ...) \ ({ \ static bool __print_once __read_mostly; \ + bool __ret_print_once = !__print_once; \ \ if (!__print_once) { \ __print_once = true; \ printk(fmt, ##__VA_ARGS__); \ } \ + unlikely(__ret_print_once); \ }) #define printk_deferred_once(fmt, ...) \ ({ \ static bool __print_once __read_mostly; \ + bool __ret_print_once = !__print_once; \ \ if (!__print_once) { \ __print_once = true; \ printk_deferred(fmt, ##__VA_ARGS__); \ } \ + unlikely(__ret_print_once); \ }) #else #define printk_once(fmt, ...) \ -- 2.8.4 -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. --