Re: [PATCH] x86, ioremap: use %pR in printk

Matthew Wilcox
2008-10-20T13:04:55Z

On Mon, Oct 20, 2008 at 01:36:02PM +0200, Ingo Molnar wrote:
> One open question would be whether to set the width to 8 on 32-bit
> platforms and 16 on 64-bit platforms - right now it's 8 on both. Since
> this is specifically a 'physical address' thing it might make sense to
> extend that on 64-bit systems. (although it's quite a bit of screen real
> estate so i think the current width of 8 should be fine)

Maybe we should let architectures configure it -- after all, they know
the real size of a physical address. I'm thinking something like this:

#ifndef PHYS_ADDR_T_SIZE
#ifdef CONFIG_64BIT
#define PHYS_ADDR_T_SIZE 64
#else
#define PHYS_ADDR_T_SIZE 32
#endif
#endif

static char *phys_addr_string(char *buf, char *end, phys_addr_t *val, int field_width, int precision, int flags)
{
/* room for the actual number, the "0x" and the final zero */
char sym[2*sizeof(phys_addr_t) + 3];
char *p = sym, *pend = sym + sizeof(sym);
int size = DIV_ROUND_UP(PHYS_ADDR_T_SIZE, 4);

p = number(p, pend, *val, 16, size, -1, SPECIAL | SMALL | ZEROPAD);
*p = 0;

return string(buf, end, sym, field_width, precision, flags);
}

Architectures can define PHYS_ADDR_T_SIZE to a variable if they want
to be able to detect it at boot-time. Or just define it to a number
(eg 36 for PAE).

By the way, the patch I'm replying to has a bug; you mis-sized 'sym'.
It needs three extra bytes, not two.

--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."