On Wed, Aug 23, 2023 at 02:47:11PM +0300, Svyatoslav Ryhel wrote: > > > 23 серпня 2023 р. 14:17:37 GMT+03:00, Thierry Reding > <thierry.red...@gmail.com> написав(-ла): > >On Tue, Aug 22, 2023 at 02:22:15PM +0300, Svyatoslav Ryhel wrote: > >> Remove of TrustZone nodes is required by many product devices > >> which require repetable calls of same function from device board. > >> To simplify this, TZ remove is converted into Kconfig option. > >> > >> Signed-off-by: Svyatoslav Ryhel <clamo...@gmail.com> > >> --- > >> arch/arm/mach-tegra/Kconfig | 14 ++++++++++++++ > >> arch/arm/mach-tegra/dt-setup.c | 7 +++++++ > >> 2 files changed, 21 insertions(+) > > > >I kind of preferred the original because it's very explicit. There's > >also no big advantage in consolidating this because the code is unlikely > >to ever require changing (the libfdt API is quite stable and these nodes > >are all hard-coded anyway). This new variant put non-generic code (it > >requires a Kconfig option after all) into a generic place, so it seems a > >bit backwards. > > So you say that I have to add same function to boards over and over > for all devices I plan to mainline? Unneeded code duplication in > action.
There's a balance to be struck between duplication and readability. If you insert this board-specific code into a generic code path, that generic code path becomes difficult to read given the extra #ifdef guards etc. If you're really worried about duplicating code you can move the two libfdt calls into a separate function and call that function from each of the boards that need it. Thierry
signature.asc
Description: PGP signature