From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yinghai Lu Subject: [PATCH 01/15] Make %pR could handle bus resource with domain Date: Wed, 1 Feb 2012 14:43:48 -0800 Message-ID: <1328136242-17725-2-git-send-email-yinghai@kernel.org> References: <1328136242-17725-1-git-send-email-yinghai@kernel.org> Return-path: In-Reply-To: <1328136242-17725-1-git-send-email-yinghai@kernel.org> Sender: linux-kernel-owner@vger.kernel.org To: Jesse Barnes , Benjamin Herrenschmidt , Tony Luck Cc: Bjorn Helgaas , Dominik Brodowski , Andrew Morton , Linus Torvalds , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Yinghai Lu List-Id: linux-arch.vger.kernel.org So could use %pR for busn_res with domain nr in start/end Signed-off-by: Yinghai Lu Cc: Andrew Morton --- lib/vsprintf.c | 28 ++++++++++++++++++++++++---- 1 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 8e75003..b34eeea 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -451,6 +451,12 @@ char *resource_string(char *buf, char *end, struct resource *res, .precision = -1, .flags = SPECIAL | SMALL | ZEROPAD, }; + static const struct printf_spec domain_spec = { + .base = 16, + .field_width = 4, + .precision = -1, + .flags = SMALL | ZEROPAD, + }; static const struct printf_spec bus_spec = { .base = 16, .field_width = 2, @@ -507,11 +513,25 @@ char *resource_string(char *buf, char *end, struct resource *res, specp = &mem_spec; decode = 0; } - p = number(p, pend, res->start, *specp); - if (res->start != res->end) { - *p++ = '-'; - p = number(p, pend, res->end, *specp); + + if (res->flags & IORESOURCE_BUS && res->end >> 8) { + p = number(p, pend, res->start >> 8, domain_spec); + *p++ = ':'; + p = number(p, pend, res->start & 0xff, *specp); + if (res->start != res->end) { + *p++ = '-'; + p = number(p, pend, res->end >> 8, domain_spec); + *p++ = ':'; + p = number(p, pend, res->end & 0xff, *specp); + } + } else { + p = number(p, pend, res->start, *specp); + if (res->start != res->end) { + *p++ = '-'; + p = number(p, pend, res->end, *specp); + } } + if (decode) { if (res->flags & IORESOURCE_MEM_64) p = string(p, pend, " 64bit", str_spec); -- 1.7.7 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from acsinet15.oracle.com ([141.146.126.227]:33752 "EHLO acsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756315Ab2BAWo3 (ORCPT ); Wed, 1 Feb 2012 17:44:29 -0500 From: Yinghai Lu Subject: [PATCH 01/15] Make %pR could handle bus resource with domain Date: Wed, 1 Feb 2012 14:43:48 -0800 Message-ID: <1328136242-17725-2-git-send-email-yinghai@kernel.org> In-Reply-To: <1328136242-17725-1-git-send-email-yinghai@kernel.org> References: <1328136242-17725-1-git-send-email-yinghai@kernel.org> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Jesse Barnes , Benjamin Herrenschmidt , Tony Luck Cc: Bjorn Helgaas , Dominik Brodowski , Andrew Morton , Linus Torvalds , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Yinghai Lu Message-ID: <20120201224348.WDmiymnasXYQ8obOnn34pFiO5cTkt6k4Jp-9ml2nlk8@z> So could use %pR for busn_res with domain nr in start/end Signed-off-by: Yinghai Lu Cc: Andrew Morton --- lib/vsprintf.c | 28 ++++++++++++++++++++++++---- 1 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 8e75003..b34eeea 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -451,6 +451,12 @@ char *resource_string(char *buf, char *end, struct resource *res, .precision = -1, .flags = SPECIAL | SMALL | ZEROPAD, }; + static const struct printf_spec domain_spec = { + .base = 16, + .field_width = 4, + .precision = -1, + .flags = SMALL | ZEROPAD, + }; static const struct printf_spec bus_spec = { .base = 16, .field_width = 2, @@ -507,11 +513,25 @@ char *resource_string(char *buf, char *end, struct resource *res, specp = &mem_spec; decode = 0; } - p = number(p, pend, res->start, *specp); - if (res->start != res->end) { - *p++ = '-'; - p = number(p, pend, res->end, *specp); + + if (res->flags & IORESOURCE_BUS && res->end >> 8) { + p = number(p, pend, res->start >> 8, domain_spec); + *p++ = ':'; + p = number(p, pend, res->start & 0xff, *specp); + if (res->start != res->end) { + *p++ = '-'; + p = number(p, pend, res->end >> 8, domain_spec); + *p++ = ':'; + p = number(p, pend, res->end & 0xff, *specp); + } + } else { + p = number(p, pend, res->start, *specp); + if (res->start != res->end) { + *p++ = '-'; + p = number(p, pend, res->end, *specp); + } } + if (decode) { if (res->flags & IORESOURCE_MEM_64) p = string(p, pend, " 64bit", str_spec); -- 1.7.7