Re: [PATCH v4 02/28] printk: Add print format (%pra) for struct range

From: Jonathan Cameron
Date: Wed Oct 09 2024 - 08:27:57 EST


On Tue, 8 Oct 2024 19:56:20 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:

> On Mon, Oct 07, 2024 at 06:16:08PM -0500, Ira Weiny wrote:
> > The use of struct range in the CXL subsystem is growing. In particular,
> > the addition of Dynamic Capacity devices uses struct range in a number
> > of places which are reported in debug and error messages.
> >
> > To wit requiring the printing of the start/end fields in each print
> > became cumbersome. Dan Williams mentions in [1] that it might be time
> > to have a print specifier for struct range similar to struct resource
> >
> > A few alternatives were considered including '%par', '%r', and '%pn'.
> > %pra follows that struct range is similar to struct resource (%p[rR])
> > but need to be different. Based on discussions with Petr and Andy
> > '%pra' was chosen.[2]
> >
> > Andy also suggested to keep the range prints similar to struct resource
> > though combined code. Add hex_range() to handle printing for both
> > pointer types.
>
> ...
>
> > +static void __init
> > +struct_range(void)
> > +{
> > + struct range test_range = {
> > + .start = 0xc0ffee00ba5eba11,
> > + .end = 0xc0ffee00ba5eba11,
> > + };
>
> A side note, can we add something like
>
> #define DEFINE_RANGE(start, end) \
> (struct range) { \
> .start = (start), \
> .end = (end), \
> }
>
> in range.h and use here and in the similar cases?

DEFINE_XXXX at least sometimes is used in cases that create the
variable as well. E.g. DEFINE_MUTEX()

INIT_RANGE() maybe?