2023-10-26 13:56:09

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 1/2] scripts: dt_to_config: Fix nul-separated compatible values

When using dt_to_config on a DTB:

-------------- : /soc/adc@10059000 : renesas,r9a07g043-adc\0renesas,rzg2l-adc : no_driver : no_config : none

When using dt_to_config on a DTS:

+M------------ : /soc/adc@10059000 : renesas,r9a07g043-adc : no_driver : no_config : none
+Md-c--------- : /soc/adc@10059000 : renesas,rzg2l-adc : drivers/iio/adc/rzg2l_adc.c : CONFIG_RZG2L_ADC : none

As of commit 32b9c61307629ac7 ("Preserve datatype markers when emitting
dts format") in dtc v1.4.7, "dtc -O dts" no longer outputs compatible
properties containing multiple values as multiple strings. Instead, it
outputs single strings, where the individual values are internally
separated by an escaped nul character.

Fix this by translating nul-separated compatible values to the
traditional multi-string format before splitting them.

Fixes: f858927fd6ce394a ("scripts/dtc: Update to upstream version v1.4.7-14-gc86da84d30e4")
Signed-off-by: Geert Uytterhoeven <[email protected]>
---
scripts/dtc/dt_to_config | 1 +
1 file changed, 1 insertion(+)

diff --git a/scripts/dtc/dt_to_config b/scripts/dtc/dt_to_config
index 299d1c2b20d7785a..563362f363e8cec1 100755
--- a/scripts/dtc/dt_to_config
+++ b/scripts/dtc/dt_to_config
@@ -748,6 +748,7 @@ sub handle_compatible()
$pn_arg{node} = $node;
$pn_arg{node_enabled} = $node_enabled;

+ $compatible =~ s/\\0/", "/g;
my @compatibles = split('", "', $compatible);

$compatibles[0] =~ s/^"//;
--
2.34.1