Re: [PATCH v3 02/25] printk: Add print format (%par) for struct range
From: Andy Shevchenko
Date: Thu Aug 22 2024 - 14:10:50 EST
On Thu, Aug 22, 2024 at 12:53:32PM -0500, Ira Weiny wrote:
> Petr Mladek wrote:
> > On Fri 2024-08-16 09:44:10, Ira Weiny wrote:
...
> > > + %par [range 0x60000000-0x6fffffff] or
> >
> > It seems that it is always 64-bit. It prints:
> >
> > struct range {
> > u64 start;
> > u64 end;
> > };
>
> Indeed. Thanks I should not have just copied/pasted.
With that said, I'm not sure the %pa is a good placeholder for this ('a' stands
to "address" AFAIU). Perhaps this should go somewhere under %pr/%pR?
> > > + [range 0x0000000060000000-0x000000006fffffff]
> > > +
> > > +For printing struct range. A variation of printing a physical address is to
> > > +print the value of struct range which are often used to hold a physical address
> > > +range.
> > > +
> > > +Passed by reference.
...
> > Is this really needed? What about using "default_str_spec" instead?
>
> Because I got confused and was coping from resource_string().
>
> Deleted now...
>
> > > + .field_width = RANGE_PRINTK_SIZE,
>
> However, my testing indicates this needs to be.
>
> .field_width = 18, /* 2 (0x) + 2 * 8 (bytes) */
>
> ... to properly zero pad the value. Does that make sense?
Looking at this, moving under %pr/R should deduplicate the code, no?
I.o.w. better to use existing code for them to print struct range, no?
--
With Best Regards,
Andy Shevchenko