Re: [PATCH 1/1] x86: Use resource_set_{range,size}() helpers

From: Ilpo Järvinen
Date: Wed Apr 16 2025 - 07:54:20 EST


On Wed, 16 Apr 2025, Andy Shevchenko wrote:

> On Wed, Apr 16, 2025 at 01:13:18PM +0300, Ilpo Järvinen wrote:
> > Convert open coded resource size calculations to use
> > resource_set_{range,size}() helpers.
> >
> > While at it, use SZ_* for size parameter which makes the intent of code
> > more obvious.
>
> ...
>
> > + resource_set_range(res, base, 1ULL << (segn_busn_bits + 20));
>
> Then probably
>
> resource_set_range(res, base, BIT_ULL(segn_busn_bits) * SZ_1M);
>
> to follow the same "While at it"?

I'll change that now since you brought it up. It did cross my mind to
convert that to * SZ_1M but it seemed to go farther than I wanted with a
simple conversion patch.

I've never liked the abuse of BIT*() for size related shifts though, I
recall I saw somewhere a helper that was better named for size related
operations but I just cannot recall its name and seem to not find that
anymore :-(. But until I come across it once again, I guess I'll have to
settle to BIT*().

> > + resource_set_range(res, 0xC0000, SZ_128K);
> > res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW |
> > IORESOURCE_PCI_FIXED;
>
> I'm wondering why not DEFINE_RES_MEM() in such cases?

I guess you meant DEFINE_RES() as that seems to allow giving custom flags.
However, DEFINE_RES*() will overwrite ->name which seems something that
ought to not be done here.

I found one other case from the same file though which is truly defines
a resource from scratch.

--
i.