Re: [PATCH][next] iio: adc: make read-only const array config static
David Laight <[email protected]> Wed, 15 Jul 2026 11:07:09 +0100
| Newsgroups | org.kernel.vger.kernel-janitors,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260715110709.74f556f4@pumpkin> |
On Tue, 14 Jul 2026 20:08:10 +0300 Andy Shevchenko <[email protected]> wrote: > On Tue, Jul 14, 2026 at 05:50:12PM +0100, Colin Ian King wrote: > > Don't populate the read-only const array config on the stack at run > > time, instead make it static. > > Reviewed-by: Andy Shevchenko <[email protected]> > > ... > > In all patches like this it's always a bikeshedding possible of moving static > data outside of a function. I have no strong opinion in these cases (when the > data solely used by a single function), but in general it might give different > readability experience (it's harder to notice static data in the local function > definition block). So I leave this exercise to the maintainers of the respective > pieces of the code. > If global you start wondering where it is used.... There is also the fact that run-time initialisation of a 3 byte array on stack is very likely to generate faster code than using static data. Mostly because the access to the static data is likely to be a cache miss. Then there are the architectures where just generating the address of the static data takes multiple instructions. In that case the on-stack version may even be smaller. David