diff options
author | Oleksij Rempel <o.rempel@pengutronix.de> | 2022-02-03 11:45:51 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-02-07 09:05:12 +0100 |
commit | 1e58f7f213c1df7fedb098b643ce7bb0dd8e0dde (patch) | |
tree | 6615b12fd0ddc480ac63b3063259d56ac24c68c8 /arch/arm | |
parent | c062cd5cf47d3dece09b710dfd12570950c1c770 (diff) | |
download | barebox-1e58f7f213c1df7fedb098b643ce7bb0dd8e0dde.tar.gz barebox-1e58f7f213c1df7fedb098b643ce7bb0dd8e0dde.tar.xz |
ARM: rpi: set host name based on DT compatible
The "rpi" host name is not practical if you need to work with different
variants of RPi at same time. Usually, removing barebox_set_hostname()
would let barebox generate it automatically. But in this case, the name
would look less informative. For example "2-model-b".
So, make board code generate something usable, for example
"rpi-2-model-b"
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.barebox.org/20220203104552.3158202-6-o.rempel@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/boards/raspberry-pi/rpi-common.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c index e68857ded9..6e62d19643 100644 --- a/arch/arm/boards/raspberry-pi/rpi-common.c +++ b/arch/arm/boards/raspberry-pi/rpi-common.c @@ -378,6 +378,8 @@ static int rpi_devices_probe(struct device_d *dev) const struct rpi_machine_data *dcfg; struct regulator *reg; struct rpi_priv *priv; + const char *name, *ptr; + char *hostname; int ret; priv = xzalloc(sizeof(*priv)); @@ -391,7 +393,12 @@ static int rpi_devices_probe(struct device_d *dev) if (IS_ERR(dcfg)) goto free_priv; - barebox_set_hostname("rpi"); + /* construct short recognizable host name */ + name = of_device_get_match_compatible(priv->dev); + ptr = strchr(name, ','); + hostname = basprintf("rpi-%s", ptr ? ptr + 1 : name); + barebox_set_hostname(hostname); + free(hostname); rpi_add_led(); bcm2835_register_fb(); |