2009-10-07 04:46:22

by Joe Perches

[permalink] [raw]
Subject: [PATCH 0/8] Add vsprintf extension %pU to print UUID/GUIDs and use it

Using %pU makes an x86 defconfig image a bit smaller

before: $ size vmlinux
text data bss dec hex filename
6976022 679572 1359668 9015262 898fde vmlinux

after: $ size vmlinux
text data bss dec hex filename
6975863 679652 1359668 9015183 898f8f vmlinux

Joe Perches (8):
lib/vsprintf.c: Add %pU to print UUID/GUIDs
random.c: Use %pU to print UUIDs
drivers/firmware/dmi_scan.c: Use %pUB to print UUIDs
drivers/md/md.c: Use %pU to print UUIDs
drivers/media/video/uvc: Use %pUl to print UUIDs
fs/gfs2/sys.c: Use %pUB to print UUIDs
fs/ubifs: Use %pUB to print UUIDs
fs/xfs/xfs_log_recover.c: Use %pU to print UUIDs

drivers/char/random.c | 10 +---
drivers/firmware/dmi_scan.c | 5 +--
drivers/md/md.c | 16 ++------
drivers/media/video/uvc/uvc_ctrl.c | 69 ++++++++++++++++------------------
drivers/media/video/uvc/uvc_driver.c | 7 +--
drivers/media/video/uvc/uvcvideo.h | 10 -----
fs/gfs2/sys.c | 16 +------
fs/ubifs/debug.c | 9 +---
fs/ubifs/super.c | 7 +---
fs/xfs/xfs_log_recover.c | 14 ++-----
lib/vsprintf.c | 62 ++++++++++++++++++++++++++++++-
11 files changed, 114 insertions(+), 111 deletions(-)


2009-10-07 04:46:24

by Joe Perches

[permalink] [raw]
Subject: [PATCH 1/8] lib/vsprintf.c: Add %pU to print UUID/GUIDs

UUID/GUIDs are somewhat common in kernel source.

Standardize the printed style of UUID/GUIDs by using
another extension to %p.

%pUb: 01020304-0506-0708-090a-0b0c0d0e0f10
%pUB: 01020304-0506-0708-090A-0B0C0D0E0F10 (upper case)
%pUl: 04030201-0605-0807-090a-0b0c0d0e0f10
%pUL: 04030201-0605-0807-090A-0B0C0D0E0F10 (upper case)

%pU defaults to %pUb

Signed-off-by: Joe Perches <[email protected]>
---
lib/vsprintf.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 61 insertions(+), 1 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 33bed5e..d24dc7f 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -790,6 +790,52 @@ static char *ip4_addr_string(char *buf, char *end, const u8 *addr,
return string(buf, end, ip4_addr, spec);
}

+static char *uuid_string(char *buf, char *end, const u8 *addr,
+ struct printf_spec spec, const char *fmt)
+{
+ char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
+ char *p = uuid;
+ int i;
+ static const u8 be[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+ static const u8 le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
+ const u8 *index = be;
+ bool uc = false;
+
+ switch (*(++fmt)) {
+ case 'L':
+ uc = true; /* fall-through */
+ case 'l':
+ index = le;
+ break;
+ case 'B':
+ uc = true;
+ break;
+ }
+
+ for (i = 0; i < 16; i++) {
+ p = pack_hex_byte(p, addr[index[i]]);
+ switch (i) {
+ case 3:
+ case 5:
+ case 7:
+ case 9:
+ *p++ = '-';
+ break;
+ }
+ }
+
+ *p = 0;
+
+ if (uc) {
+ p = uuid;
+ do {
+ *p = toupper(*p);
+ } while (*(++p));
+ }
+
+ return string(buf, end, uuid, spec);
+}
+
/*
* Show a '%p' thing. A kernel extension is that the '%p' is followed
* by an extra set of alphanumeric characters that are extended format
@@ -814,6 +860,18 @@ static char *ip4_addr_string(char *buf, char *end, const u8 *addr,
* IPv4 uses dot-separated decimal with leading 0's (010.123.045.006)
* - 'I6c' for IPv6 addresses printed as specified by
* http://www.ietf.org/id/draft-kawamura-ipv6-text-representation-03.txt
+ * - 'U' For a 16 byte UUID/GUID, it prints the UUID/GUID in the form
+ * "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ * Options for %pU are:
+ * b big endian lower case hex (default)
+ * B big endian UPPER case hex
+ * l little endian lower case hex
+ * L little endian UPPER case hex
+ * big endian output byte order is:
+ * [0][1][2][3]-[4][5]-[6][7]-[8][9]-[10][11][12][13][14][15]
+ * little endian output byte order is:
+ * [3][2][1][0]-[5][4]-[7][6]-[8][9]-[10][11][12][13][14][15]
+ *
* Note: The difference between 'S' and 'F' is that on ia64 and ppc64
* function pointers are really function descriptors, which contain a
* pointer to the real address.
@@ -828,9 +886,9 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
case 'F':
case 'f':
ptr = dereference_function_descriptor(ptr);
- case 's':
/* Fallthrough */
case 'S':
+ case 's':
return symbol_string(buf, end, ptr, spec, *fmt);
case 'R':
return resource_string(buf, end, ptr, spec);
@@ -853,6 +911,8 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
return ip4_addr_string(buf, end, ptr, spec, fmt);
}
break;
+ case 'U':
+ return uuid_string(buf, end, ptr, spec, fmt);
}
spec.flags |= SMALL;
if (spec.field_width == -1) {
--
1.6.3.1.10.g659a0.dirty

2009-10-07 04:46:47

by Joe Perches

[permalink] [raw]
Subject: [PATCH 2/8] random.c: Use %pU to print UUIDs

Signed-off-by: Joe Perches <[email protected]>
---
drivers/char/random.c | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 04b505e..7104df9 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1245,12 +1245,8 @@ static int proc_do_uuid(ctl_table *table, int write,
if (uuid[8] == 0)
generate_random_uuid(uuid);

- sprintf(buf, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
- "%02x%02x%02x%02x%02x%02x",
- uuid[0], uuid[1], uuid[2], uuid[3],
- uuid[4], uuid[5], uuid[6], uuid[7],
- uuid[8], uuid[9], uuid[10], uuid[11],
- uuid[12], uuid[13], uuid[14], uuid[15]);
+ sprintf(buf, "%pU", uuid);
+
fake_table.data = buf;
fake_table.maxlen = sizeof(buf);

@@ -1350,7 +1346,7 @@ ctl_table random_table[] = {

/********************************************************************
*
- * Random funtions for networking
+ * Random functions for networking
*
********************************************************************/

--
1.6.3.1.10.g659a0.dirty

2009-10-07 04:46:26

by Joe Perches

[permalink] [raw]
Subject: [PATCH 3/8] drivers/firmware/dmi_scan.c: Use %pUB to print UUIDs

Signed-off-by: Joe Perches <[email protected]>
---
drivers/firmware/dmi_scan.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 938100f..c8b2609 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -169,10 +169,7 @@ static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, int inde
if (!s)
return;

- sprintf(s,
- "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
- d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
- d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
+ sprintf(s, "%pUB", d);

dmi_ident[slot] = s;
}
--
1.6.3.1.10.g659a0.dirty

2009-10-07 04:46:26

by Joe Perches

[permalink] [raw]
Subject: [PATCH 4/8] drivers/md/md.c: Use %pU to print UUIDs

Signed-off-by: Joe Perches <[email protected]>
---
drivers/md/md.c | 16 ++++------------
1 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 26ba42a..68b52d7 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1813,15 +1813,11 @@ static void print_sb_1(struct mdp_superblock_1 *sb)

uuid = sb->set_uuid;
printk(KERN_INFO
- "md: SB: (V:%u) (F:0x%08x) Array-ID:<%02x%02x%02x%02x"
- ":%02x%02x:%02x%02x:%02x%02x:%02x%02x%02x%02x%02x%02x>\n"
+ "md: SB: (V:%u) (F:0x%08x) Array-ID:<%pU>\n"
"md: Name: \"%s\" CT:%llu\n",
le32_to_cpu(sb->major_version),
le32_to_cpu(sb->feature_map),
- uuid[0], uuid[1], uuid[2], uuid[3],
- uuid[4], uuid[5], uuid[6], uuid[7],
- uuid[8], uuid[9], uuid[10], uuid[11],
- uuid[12], uuid[13], uuid[14], uuid[15],
+ uuid,
sb->set_name,
(unsigned long long)le64_to_cpu(sb->ctime)
& MD_SUPERBLOCK_1_TIME_SEC_MASK);
@@ -1830,8 +1826,7 @@ static void print_sb_1(struct mdp_superblock_1 *sb)
printk(KERN_INFO
"md: L%u SZ%llu RD:%u LO:%u CS:%u DO:%llu DS:%llu SO:%llu"
" RO:%llu\n"
- "md: Dev:%08x UUID: %02x%02x%02x%02x:%02x%02x:%02x%02x:%02x%02x"
- ":%02x%02x%02x%02x%02x%02x\n"
+ "md: Dev:%08x UUID: %pU\n"
"md: (F:0x%08x) UT:%llu Events:%llu ResyncOffset:%llu CSUM:0x%08x\n"
"md: (MaxDev:%u) \n",
le32_to_cpu(sb->level),
@@ -1844,10 +1839,7 @@ static void print_sb_1(struct mdp_superblock_1 *sb)
(unsigned long long)le64_to_cpu(sb->super_offset),
(unsigned long long)le64_to_cpu(sb->recovery_offset),
le32_to_cpu(sb->dev_number),
- uuid[0], uuid[1], uuid[2], uuid[3],
- uuid[4], uuid[5], uuid[6], uuid[7],
- uuid[8], uuid[9], uuid[10], uuid[11],
- uuid[12], uuid[13], uuid[14], uuid[15],
+ uuid,
sb->devflags,
(unsigned long long)le64_to_cpu(sb->utime) & MD_SUPERBLOCK_1_TIME_SEC_MASK,
(unsigned long long)le64_to_cpu(sb->events),
--
1.6.3.1.10.g659a0.dirty

2009-10-07 04:47:08

by Joe Perches

[permalink] [raw]
Subject: [PATCH 5/8] drivers/media/video/uvc: Use %pUl to print UUIDs

Signed-off-by: Joe Perches <[email protected]>
---
drivers/media/video/uvc/uvc_ctrl.c | 69 ++++++++++++++++------------------
drivers/media/video/uvc/uvc_driver.c | 7 +--
drivers/media/video/uvc/uvcvideo.h | 10 -----
3 files changed, 35 insertions(+), 51 deletions(-)

diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index c3225a5..4d06976 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -1093,8 +1093,8 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,

if (!found) {
uvc_trace(UVC_TRACE_CONTROL,
- "Control " UVC_GUID_FORMAT "/%u not found.\n",
- UVC_GUID_ARGS(entity->extension.guidExtensionCode),
+ "Control %pUl/%u not found.\n",
+ entity->extension.guidExtensionCode,
xctrl->selector);
return -EINVAL;
}
@@ -1171,9 +1171,9 @@ int uvc_ctrl_resume_device(struct uvc_device *dev)
(ctrl->info->flags & UVC_CONTROL_RESTORE) == 0)
continue;

- printk(KERN_INFO "restoring control " UVC_GUID_FORMAT
- "/%u/%u\n", UVC_GUID_ARGS(ctrl->info->entity),
- ctrl->info->index, ctrl->info->selector);
+ printk(KERN_INFO "restoring control %pUl/%u/%u\n",
+ ctrl->info->entity,
+ ctrl->info->index, ctrl->info->selector);
ctrl->dirty = 1;
}

@@ -1228,46 +1228,43 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev,
dev->intfnum, info->selector, (__u8 *)&size, 2);
if (ret < 0) {
uvc_trace(UVC_TRACE_CONTROL, "GET_LEN failed on "
- "control " UVC_GUID_FORMAT "/%u (%d).\n",
- UVC_GUID_ARGS(info->entity), info->selector,
- ret);
+ "control %pUl/%u (%d).\n",
+ info->entity, info->selector, ret);
return;
}

if (info->size != le16_to_cpu(size)) {
- uvc_trace(UVC_TRACE_CONTROL, "Control " UVC_GUID_FORMAT
- "/%u size doesn't match user supplied "
- "value.\n", UVC_GUID_ARGS(info->entity),
- info->selector);
+ uvc_trace(UVC_TRACE_CONTROL,
+ "Control %pUl/%u size doesn't match user supplied value.\n",
+ info->entity, info->selector);
return;
}

ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id,
dev->intfnum, info->selector, &inf, 1);
if (ret < 0) {
- uvc_trace(UVC_TRACE_CONTROL, "GET_INFO failed on "
- "control " UVC_GUID_FORMAT "/%u (%d).\n",
- UVC_GUID_ARGS(info->entity), info->selector,
- ret);
+ uvc_trace(UVC_TRACE_CONTROL,
+ "GET_INFO failed on control %pUl/%u (%d).\n",
+ info->entity, info->selector, ret);
return;
}

flags = info->flags;
if (((flags & UVC_CONTROL_GET_CUR) && !(inf & (1 << 0))) ||
((flags & UVC_CONTROL_SET_CUR) && !(inf & (1 << 1)))) {
- uvc_trace(UVC_TRACE_CONTROL, "Control "
- UVC_GUID_FORMAT "/%u flags don't match "
- "supported operations.\n",
- UVC_GUID_ARGS(info->entity), info->selector);
+ uvc_trace(UVC_TRACE_CONTROL,
+ "Control %pUl/%u flags don't match supported operations.\n",
+ info->entity, info->selector);
return;
}
}

ctrl->info = info;
ctrl->data = kmalloc(ctrl->info->size * UVC_CTRL_NDATA, GFP_KERNEL);
- uvc_trace(UVC_TRACE_CONTROL, "Added control " UVC_GUID_FORMAT "/%u "
- "to device %s entity %u\n", UVC_GUID_ARGS(ctrl->info->entity),
- ctrl->info->selector, dev->udev->devpath, entity->id);
+ uvc_trace(UVC_TRACE_CONTROL,
+ "Added control %pUl/%u to device %s entity %u\n",
+ ctrl->info->entity, ctrl->info->selector,
+ dev->udev->devpath, entity->id);
}

/*
@@ -1293,17 +1290,16 @@ int uvc_ctrl_add_info(struct uvc_control_info *info)
continue;

if (ctrl->selector == info->selector) {
- uvc_trace(UVC_TRACE_CONTROL, "Control "
- UVC_GUID_FORMAT "/%u is already defined.\n",
- UVC_GUID_ARGS(info->entity), info->selector);
+ uvc_trace(UVC_TRACE_CONTROL,
+ "Control %pUl/%u is already defined.\n",
+ info->entity, info->selector);
ret = -EEXIST;
goto end;
}
if (ctrl->index == info->index) {
- uvc_trace(UVC_TRACE_CONTROL, "Control "
- UVC_GUID_FORMAT "/%u would overwrite index "
- "%d.\n", UVC_GUID_ARGS(info->entity),
- info->selector, info->index);
+ uvc_trace(UVC_TRACE_CONTROL,
+ "Control %pUl/%u would overwrite index %d.\n",
+ info->entity, info->selector, info->index);
ret = -EEXIST;
goto end;
}
@@ -1344,10 +1340,9 @@ int uvc_ctrl_add_mapping(struct uvc_control_mapping *mapping)
continue;

if (info->size * 8 < mapping->size + mapping->offset) {
- uvc_trace(UVC_TRACE_CONTROL, "Mapping '%s' would "
- "overflow control " UVC_GUID_FORMAT "/%u\n",
- mapping->name, UVC_GUID_ARGS(info->entity),
- info->selector);
+ uvc_trace(UVC_TRACE_CONTROL,
+ "Mapping '%s' would overflow control %pUl/%u\n",
+ mapping->name, info->entity, info->selector);
ret = -EOVERFLOW;
goto end;
}
@@ -1366,9 +1361,9 @@ int uvc_ctrl_add_mapping(struct uvc_control_mapping *mapping)

mapping->ctrl = info;
list_add_tail(&mapping->list, &info->mappings);
- uvc_trace(UVC_TRACE_CONTROL, "Adding mapping %s to control "
- UVC_GUID_FORMAT "/%u.\n", mapping->name,
- UVC_GUID_ARGS(info->entity), info->selector);
+ uvc_trace(UVC_TRACE_CONTROL,
+ "Adding mapping %s to control %pUl/%u.\n",
+ mapping->name, info->entity, info->selector);

ret = 0;
break;
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
index 8756be5..411dc63 100644
--- a/drivers/media/video/uvc/uvc_driver.c
+++ b/drivers/media/video/uvc/uvc_driver.c
@@ -328,11 +328,10 @@ static int uvc_parse_format(struct uvc_device *dev,
sizeof format->name);
format->fcc = fmtdesc->fcc;
} else {
- uvc_printk(KERN_INFO, "Unknown video format "
- UVC_GUID_FORMAT "\n",
- UVC_GUID_ARGS(&buffer[5]));
+ uvc_printk(KERN_INFO, "Unknown video format %pUl\n",
+ &buffer[5]);
snprintf(format->name, sizeof format->name,
- UVC_GUID_FORMAT, UVC_GUID_ARGS(&buffer[5]));
+ "%pUl", &Buffer[5]);
format->fcc = 0;
}

diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
index e7958aa..9f4a437 100644
--- a/drivers/media/video/uvc/uvcvideo.h
+++ b/drivers/media/video/uvc/uvcvideo.h
@@ -555,16 +555,6 @@ extern unsigned int uvc_trace_param;
#define uvc_printk(level, msg...) \
printk(level "uvcvideo: " msg)

-#define UVC_GUID_FORMAT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" \
- "%02x%02x%02x%02x%02x%02x"
-#define UVC_GUID_ARGS(guid) \
- (guid)[3], (guid)[2], (guid)[1], (guid)[0], \
- (guid)[5], (guid)[4], \
- (guid)[7], (guid)[6], \
- (guid)[8], (guid)[9], \
- (guid)[10], (guid)[11], (guid)[12], \
- (guid)[13], (guid)[14], (guid)[15]
-
/* --------------------------------------------------------------------------
* Internal functions.
*/
--
1.6.3.1.10.g659a0.dirty

2009-10-07 04:47:04

by Joe Perches

[permalink] [raw]
Subject: [PATCH 6/8] fs/gfs2/sys.c: Use %pUB to print UUIDs

Signed-off-by: Joe Perches <[email protected]>
---
fs/gfs2/sys.c | 16 +++-------------
1 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index 4463297..25f03da 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -85,11 +85,7 @@ static ssize_t uuid_show(struct gfs2_sbd *sdp, char *buf)
buf[0] = '\0';
if (!gfs2_uuid_valid(uuid))
return 0;
- return snprintf(buf, PAGE_SIZE, "%02X%02X%02X%02X-%02X%02X-"
- "%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n",
- uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5],
- uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], uuid[11],
- uuid[12], uuid[13], uuid[14], uuid[15]);
+ return snprintf(buf, PAGE_SIZE, "%pUB\n", uuid);
}

static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
@@ -573,14 +569,8 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name);
if (!sdp->sd_args.ar_spectator)
add_uevent_var(env, "JOURNALID=%u", sdp->sd_lockstruct.ls_jid);
- if (gfs2_uuid_valid(uuid)) {
- add_uevent_var(env, "UUID=%02X%02X%02X%02X-%02X%02X-%02X%02X-"
- "%02X%02X-%02X%02X%02X%02X%02X%02X",
- uuid[0], uuid[1], uuid[2], uuid[3], uuid[4],
- uuid[5], uuid[6], uuid[7], uuid[8], uuid[9],
- uuid[10], uuid[11], uuid[12], uuid[13],
- uuid[14], uuid[15]);
- }
+ if (gfs2_uuid_valid(uuid))
+ add_uevent_var(env, "UUID=%pUB", uuid);
return 0;
}

--
1.6.3.1.10.g659a0.dirty

2009-10-07 04:47:07

by Joe Perches

[permalink] [raw]
Subject: [PATCH 7/8] fs/ubifs: Use %pUB to print UUIDs

Signed-off-by: Joe Perches <[email protected]>
---
fs/ubifs/debug.c | 9 ++-------
fs/ubifs/super.c | 7 +------
2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index dbc093a..3cfd74c 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -350,13 +350,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
le32_to_cpu(sup->fmt_version));
printk(KERN_DEBUG "\ttime_gran %u\n",
le32_to_cpu(sup->time_gran));
- printk(KERN_DEBUG "\tUUID %02X%02X%02X%02X-%02X%02X"
- "-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n",
- sup->uuid[0], sup->uuid[1], sup->uuid[2], sup->uuid[3],
- sup->uuid[4], sup->uuid[5], sup->uuid[6], sup->uuid[7],
- sup->uuid[8], sup->uuid[9], sup->uuid[10], sup->uuid[11],
- sup->uuid[12], sup->uuid[13], sup->uuid[14],
- sup->uuid[15]);
+ printk(KERN_DEBUG "\tUUID %pUB\n",
+ sup->uuid);
break;
}
case UBIFS_MST_NODE:
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 333e181..f50ba84 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1393,12 +1393,7 @@ static int mount_ubifs(struct ubifs_info *c)
c->leb_size, c->leb_size >> 10);
dbg_msg("data journal heads: %d",
c->jhead_cnt - NONDATA_JHEADS_CNT);
- dbg_msg("UUID: %02X%02X%02X%02X-%02X%02X"
- "-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
- c->uuid[0], c->uuid[1], c->uuid[2], c->uuid[3],
- c->uuid[4], c->uuid[5], c->uuid[6], c->uuid[7],
- c->uuid[8], c->uuid[9], c->uuid[10], c->uuid[11],
- c->uuid[12], c->uuid[13], c->uuid[14], c->uuid[15]);
+ dbg_msg("UUID: %pUB", c->uuid);
dbg_msg("big_lpt %d", c->big_lpt);
dbg_msg("log LEBs: %d (%d - %d)",
c->log_lebs, UBIFS_LOG_LNUM, c->log_last);
--
1.6.3.1.10.g659a0.dirty

2009-10-07 04:47:24

by Joe Perches

[permalink] [raw]
Subject: [PATCH 8/8] fs/xfs/xfs_log_recover.c: Use %pU to print UUIDs

Signed-off-by: Joe Perches <[email protected]>
---
fs/xfs/xfs_log_recover.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 1099395..3b8e3df 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -225,16 +225,10 @@ xlog_header_check_dump(
xfs_mount_t *mp,
xlog_rec_header_t *head)
{
- int b;
-
- cmn_err(CE_DEBUG, "%s: SB : uuid = ", __func__);
- for (b = 0; b < 16; b++)
- cmn_err(CE_DEBUG, "%02x", ((__uint8_t *)&mp->m_sb.sb_uuid)[b]);
- cmn_err(CE_DEBUG, ", fmt = %d\n", XLOG_FMT);
- cmn_err(CE_DEBUG, " log : uuid = ");
- for (b = 0; b < 16; b++)
- cmn_err(CE_DEBUG, "%02x", ((__uint8_t *)&head->h_fs_uuid)[b]);
- cmn_err(CE_DEBUG, ", fmt = %d\n", be32_to_cpu(head->h_fmt));
+ cmn_err(CE_DEBUG, "%s: SB : uuid = %pU, fmt = %d\n",
+ __func__, &mp->m_sb.sb_uuid, XLOG_FMT);
+ cmn_err(CE_DEBUG, " log : uuid = %pU, fmt = %d\n",
+ &head->h_fs_uuid, be32_to_cpu(head->h_fmt));
}
#else
#define xlog_header_check_dump(mp, head)
--
1.6.3.1.10.g659a0.dirty

2009-10-07 05:20:56

by Matt Mackall

[permalink] [raw]
Subject: Re: [PATCH 2/8] random.c: Use %pU to print UUIDs

On Tue, 2009-10-06 at 21:45 -0700, Joe Perches wrote:
> Signed-off-by: Joe Perches <[email protected]>
> ---
> drivers/char/random.c | 10 +++-------
> 1 files changed, 3 insertions(+), 7 deletions(-)

Looks good. Been meaning to fix that typo for ages.

Signed-off-by: Matt Mackall <[email protected]>

--
http://selenic.com : development and support for Mercurial and Linux

2009-10-07 06:12:35

by Joe Perches

[permalink] [raw]
Subject: [PATCH 9/8] efi.h: Use %pUl to print UUIDs

Shrinks vmlinux

without:
$ size vmlinux
text data bss dec hex filename
6975863 679652 1359668 9015183 898f8f vmlinux

with:
$ size vmlinux
text data bss dec hex filename
6975639 679652 1359668 9014959 898eaf vmlinux

Signed-off-by: Joe Perches <[email protected]>

diff --git a/include/linux/efi.h b/include/linux/efi.h
index ce4581f..fb737bc 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -280,11 +280,7 @@ efi_guidcmp (efi_guid_t left, efi_guid_t right)
static inline char *
efi_guid_unparse(efi_guid_t *guid, char *out)
{
- sprintf(out, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
- guid->b[3], guid->b[2], guid->b[1], guid->b[0],
- guid->b[5], guid->b[4], guid->b[7], guid->b[6],
- guid->b[8], guid->b[9], guid->b[10], guid->b[11],
- guid->b[12], guid->b[13], guid->b[14], guid->b[15]);
+ sprintf(out, "%pUl", guid->b);
return out;
}



2009-10-11 22:33:10

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 5/8] drivers/media/video/uvc: Use %pUl to print UUIDs

Hi Joe,

On Wednesday 07 October 2009 06:45:38 Joe Perches wrote:
> Signed-off-by: Joe Perches <[email protected]>
> ---
> drivers/media/video/uvc/uvc_ctrl.c | 69 ++++++++++++++++------------------
> drivers/media/video/uvc/uvc_driver.c | 7 +--
> drivers/media/video/uvc/uvcvideo.h | 10 -----
> 3 files changed, 35 insertions(+), 51 deletions(-)
>
> diff --git a/drivers/media/video/uvc/uvc_ctrl.c
> b/drivers/media/video/uvc/uvc_ctrl.c index c3225a5..4d06976 100644
> --- a/drivers/media/video/uvc/uvc_ctrl.c
> +++ b/drivers/media/video/uvc/uvc_ctrl.c
> @@ -1093,8 +1093,8 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
>
> if (!found) {
> uvc_trace(UVC_TRACE_CONTROL,
> - "Control " UVC_GUID_FORMAT "/%u not found.\n",
> - UVC_GUID_ARGS(entity->extension.guidExtensionCode),
> + "Control %pUl/%u not found.\n",
> + entity->extension.guidExtensionCode,
> xctrl->selector);
> return -EINVAL;
> }
> @@ -1171,9 +1171,9 @@ int uvc_ctrl_resume_device(struct uvc_device *dev)
> (ctrl->info->flags & UVC_CONTROL_RESTORE) == 0)
> continue;
>
> - printk(KERN_INFO "restoring control " UVC_GUID_FORMAT
> - "/%u/%u\n", UVC_GUID_ARGS(ctrl->info->entity),
> - ctrl->info->index, ctrl->info->selector);
> + printk(KERN_INFO "restoring control %pUl/%u/%u\n",
> + ctrl->info->entity,
> + ctrl->info->index, ctrl->info->selector);
> ctrl->dirty = 1;
> }
>
> @@ -1228,46 +1228,43 @@ static void uvc_ctrl_add_ctrl(struct uvc_device
> *dev, dev->intfnum, info->selector, (__u8 *)&size, 2);
> if (ret < 0) {
> uvc_trace(UVC_TRACE_CONTROL, "GET_LEN failed on "
> - "control " UVC_GUID_FORMAT "/%u (%d).\n",
> - UVC_GUID_ARGS(info->entity), info->selector,
> - ret);
> + "control %pUl/%u (%d).\n",
> + info->entity, info->selector, ret);
> return;
> }
>
> if (info->size != le16_to_cpu(size)) {
> - uvc_trace(UVC_TRACE_CONTROL, "Control " UVC_GUID_FORMAT
> - "/%u size doesn't match user supplied "
> - "value.\n", UVC_GUID_ARGS(info->entity),
> - info->selector);
> + uvc_trace(UVC_TRACE_CONTROL,
> + "Control %pUl/%u size doesn't match user supplied value.\n",
> + info->entity, info->selector);
> return;
> }
>
> ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id,
> dev->intfnum, info->selector, &inf, 1);
> if (ret < 0) {
> - uvc_trace(UVC_TRACE_CONTROL, "GET_INFO failed on "
> - "control " UVC_GUID_FORMAT "/%u (%d).\n",
> - UVC_GUID_ARGS(info->entity), info->selector,
> - ret);
> + uvc_trace(UVC_TRACE_CONTROL,
> + "GET_INFO failed on control %pUl/%u (%d).\n",
> + info->entity, info->selector, ret);
> return;
> }
>
> flags = info->flags;
> if (((flags & UVC_CONTROL_GET_CUR) && !(inf & (1 << 0))) ||
> ((flags & UVC_CONTROL_SET_CUR) && !(inf & (1 << 1)))) {
> - uvc_trace(UVC_TRACE_CONTROL, "Control "
> - UVC_GUID_FORMAT "/%u flags don't match "
> - "supported operations.\n",
> - UVC_GUID_ARGS(info->entity), info->selector);
> + uvc_trace(UVC_TRACE_CONTROL,
> + "Control %pUl/%u flags don't match supported operations.\n",
> + info->entity, info->selector);
> return;
> }
> }
>
> ctrl->info = info;
> ctrl->data = kmalloc(ctrl->info->size * UVC_CTRL_NDATA, GFP_KERNEL);
> - uvc_trace(UVC_TRACE_CONTROL, "Added control " UVC_GUID_FORMAT "/%u "
> - "to device %s entity %u\n", UVC_GUID_ARGS(ctrl->info->entity),
> - ctrl->info->selector, dev->udev->devpath, entity->id);
> + uvc_trace(UVC_TRACE_CONTROL,
> + "Added control %pUl/%u to device %s entity %u\n",
> + ctrl->info->entity, ctrl->info->selector,
> + dev->udev->devpath, entity->id);
> }
>
> /*
> @@ -1293,17 +1290,16 @@ int uvc_ctrl_add_info(struct uvc_control_info
> *info) continue;
>
> if (ctrl->selector == info->selector) {
> - uvc_trace(UVC_TRACE_CONTROL, "Control "
> - UVC_GUID_FORMAT "/%u is already defined.\n",
> - UVC_GUID_ARGS(info->entity), info->selector);
> + uvc_trace(UVC_TRACE_CONTROL,
> + "Control %pUl/%u is already defined.\n",
> + info->entity, info->selector);
> ret = -EEXIST;
> goto end;
> }
> if (ctrl->index == info->index) {
> - uvc_trace(UVC_TRACE_CONTROL, "Control "
> - UVC_GUID_FORMAT "/%u would overwrite index "
> - "%d.\n", UVC_GUID_ARGS(info->entity),
> - info->selector, info->index);
> + uvc_trace(UVC_TRACE_CONTROL,
> + "Control %pUl/%u would overwrite index %d.\n",
> + info->entity, info->selector, info->index);
> ret = -EEXIST;
> goto end;
> }
> @@ -1344,10 +1340,9 @@ int uvc_ctrl_add_mapping(struct uvc_control_mapping
> *mapping) continue;
>
> if (info->size * 8 < mapping->size + mapping->offset) {
> - uvc_trace(UVC_TRACE_CONTROL, "Mapping '%s' would "
> - "overflow control " UVC_GUID_FORMAT "/%u\n",
> - mapping->name, UVC_GUID_ARGS(info->entity),
> - info->selector);
> + uvc_trace(UVC_TRACE_CONTROL,
> + "Mapping '%s' would overflow control %pUl/%u\n",
> + mapping->name, info->entity, info->selector);
> ret = -EOVERFLOW;
> goto end;
> }
> @@ -1366,9 +1361,9 @@ int uvc_ctrl_add_mapping(struct uvc_control_mapping
> *mapping)
>
> mapping->ctrl = info;
> list_add_tail(&mapping->list, &info->mappings);
> - uvc_trace(UVC_TRACE_CONTROL, "Adding mapping %s to control "
> - UVC_GUID_FORMAT "/%u.\n", mapping->name,
> - UVC_GUID_ARGS(info->entity), info->selector);
> + uvc_trace(UVC_TRACE_CONTROL,
> + "Adding mapping %s to control %pUl/%u.\n",
> + mapping->name, info->entity, info->selector);
>
> ret = 0;
> break;
> diff --git a/drivers/media/video/uvc/uvc_driver.c
> b/drivers/media/video/uvc/uvc_driver.c index 8756be5..411dc63 100644
> --- a/drivers/media/video/uvc/uvc_driver.c
> +++ b/drivers/media/video/uvc/uvc_driver.c
> @@ -328,11 +328,10 @@ static int uvc_parse_format(struct uvc_device *dev,
> sizeof format->name);
> format->fcc = fmtdesc->fcc;
> } else {
> - uvc_printk(KERN_INFO, "Unknown video format "
> - UVC_GUID_FORMAT "\n",
> - UVC_GUID_ARGS(&buffer[5]));
> + uvc_printk(KERN_INFO, "Unknown video format %pUl\n",
> + &buffer[5]);
> snprintf(format->name, sizeof format->name,
> - UVC_GUID_FORMAT, UVC_GUID_ARGS(&buffer[5]));
> + "%pUl", &Buffer[5]);

Buffer should still be written buffer.

As this will go through the linuxtv v4l-dvb tree, I'll have to add backward
compatibility code (that will not make it to mainline). If that's ok with you
it will be easier for me to test and apply that part of the patch through my
tree once the vsprintf extension gets in.

--
Regards,

Laurent Pinchart

2009-10-31 09:08:32

by Mauro Carvalho Chehab

[permalink] [raw]
Subject: Re: [PATCH 5/8] drivers/media/video/uvc: Use %pUl to print UUIDs

Hi Laurent,

Em Mon, 12 Oct 2009 00:34:58 +0200
Laurent Pinchart <[email protected]> escreveu:

> As this will go through the linuxtv v4l-dvb tree, I'll have to add backward
> compatibility code (that will not make it to mainline). If that's ok with you
> it will be easier for me to test and apply that part of the patch through my
> tree once the vsprintf extension gets in.

I'm assuming that those printk patches from Joe to uvc will go via your tree,
so please submit a pull request when they'll be ready for upstream.




Cheers,
Mauro

2009-10-31 19:10:35

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 5/8] drivers/media/video/uvc: Use %pUl to print UUIDs

On Saturday 31 October 2009 10:07:01 Mauro Carvalho Chehab wrote:
> Hi Laurent,
>
> Em Mon, 12 Oct 2009 00:34:58 +0200
>
> Laurent Pinchart <[email protected]> escreveu:
> > As this will go through the linuxtv v4l-dvb tree, I'll have to add
> > backward compatibility code (that will not make it to mainline). If
> > that's ok with you it will be easier for me to test and apply that part
> > of the patch through my tree once the vsprintf extension gets in.
>
> I'm assuming that those printk patches from Joe to uvc will go via your
> tree, so please submit a pull request when they'll be ready for upstream.

I'll submit the pull request as soon as the printk core patch hits upstream.

The change will break the driver when used with older versions (it will
compile, load and run, but will print broken messages), and compat.h
compatibility magic will not be possible. As the messages are purely
informational, I'm pondering not even keeping #ifdef compatibility. Any
thought on that ?

--
Regards,

Laurent Pinchart

2009-10-31 19:27:35

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 5/8] drivers/media/video/uvc: Use %pUl to print UUIDs

On Sat, 2009-10-31 at 20:10 +0100, Laurent Pinchart wrote:
> On Saturday 31 October 2009 10:07:01 Mauro Carvalho Chehab wrote:
> > I'm assuming that those printk patches from Joe to uvc will go via your
> > tree, so please submit a pull request when they'll be ready for upstream.
> I'll submit the pull request as soon as the printk core patch hits upstream.

I believe Andrew Morton has picked up the patches for
his mm-commits set. If you do nothing, these should
show up in Linus' tree after awhile.

lib-vsprintfc-add-%pu-to-print-uuid-guids.patch
fs-xfs-xfs_log_recoverc-use-%pu-to-print-uuids.patch
randomc-use-%pu-to-print-uuids.patch
drivers-firmware-dmi_scanc-use-%pub-to-print-uuids.patch
drivers-md-mdc-use-%pu-to-print-uuids.patch
fs-gfs2-sysc-use-%pub-to-print-uuids.patch
fs-ubifs-use-%pub-to-print-uuids.patch
efih-use-%pul-to-print-uuids.patch
drivers-media-video-uvc-use-%pul-to-print-uuids.patch
lib-unified-uuid-guid-definition.patch
gfs2-use-unified-uuid-guid-code.patch

2009-11-04 14:42:11

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 5/8] drivers/media/video/uvc: Use %pUl to print UUIDs

Hi Joe,

On Saturday 31 October 2009 20:27:38 Joe Perches wrote:
> On Sat, 2009-10-31 at 20:10 +0100, Laurent Pinchart wrote:
> > On Saturday 31 October 2009 10:07:01 Mauro Carvalho Chehab wrote:
> > > I'm assuming that those printk patches from Joe to uvc will go via your
> > > tree, so please submit a pull request when they'll be ready for
> > > upstream.
> >
> > I'll submit the pull request as soon as the printk core patch hits
> > upstream.
>
> I believe Andrew Morton has picked up the patches for
> his mm-commits set. If you do nothing, these should
> show up in Linus' tree after awhile.

Thanks for the notice.

Andrew, could you please drop drivers-media-video-uvc-use-%pul-to-print-
uuids.patch ? I will push it through the v4l-dvb tree as I need to add
backward compatibility support.

--
Regards,

Laurent Pinchart

2009-11-04 16:42:35

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 5/8] drivers/media/video/uvc: Use %pUl to print UUIDs

On Wed, 2009-11-04 at 15:42 +0100, Laurent Pinchart wrote:
> Andrew, could you please drop drivers-media-video-uvc-use-%pul-to-print-
> uuids.patch ? I will push it through the v4l-dvb tree as I need to add
> backward compatibility support.

One thing you might evaluate is how useful it is to continue
to support backward compatibility.

I think drivers/media is the only drivers directory except
staging to continue to use KERNEL_VERSION checks.

cheers, Joe