From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753711AbbL2QnP (ORCPT ); Tue, 29 Dec 2015 11:43:15 -0500 Received: from mga04.intel.com ([192.55.52.120]:13235 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753516AbbL2Qmn (ORCPT ); Tue, 29 Dec 2015 11:42:43 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,496,1444719600"; d="scan'208";a="882943738" From: Andy Shevchenko To: Andrew Morton , Rasmus Villemoes , linux-kernel@vger.kernel.org, Joe Perches Cc: Andy Shevchenko Subject: [PATCH v2 2/2] lib/vsprintf: factor out %pN[F] handler as netdev_bits() Date: Tue, 29 Dec 2015 18:42:38 +0200 Message-Id: <1451407358-7041-3-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1451407358-7041-1-git-send-email-andriy.shevchenko@linux.intel.com> References: <1451407358-7041-1-git-send-email-andriy.shevchenko@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move switch case to the netdev_features_string() and rename it to netdev_bits(). In the future we can extend it as needed. Here we replace the fallback of %pN from '%p' with possible flags to sticter '0x%p' without any flags variation. Signed-off-by: Andy Shevchenko --- lib/vsprintf.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 6946431..5c22317 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1324,11 +1324,22 @@ char *uuid_string(char *buf, char *end, const u8 *addr, return string(buf, end, uuid, spec); } -static -char *netdev_feature_string(char *buf, char *end, const void *addr) +static noinline_for_stack +char *netdev_bits(char *buf, char *end, const void *addr, const char *fmt) { - unsigned long long num = *(const netdev_features_t *)addr; - int size = sizeof(netdev_features_t); + unsigned long long num; + int size; + + switch (fmt[1]) { + case 'F': + num = *(const netdev_features_t *)addr; + size = sizeof(netdev_features_t); + break; + default: + num = (unsigned long)addr; + size = sizeof(unsigned long); + break; + } return special_hex_number(buf, end, num, size); } @@ -1671,11 +1682,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, break; case 'N': - switch (fmt[1]) { - case 'F': - return netdev_feature_string(buf, end, ptr); - } - break; + return netdev_bits(buf, end, ptr, fmt); case 'a': return address_val(buf, end, ptr, fmt); case 'd': -- 2.6.4