diff mbox series

bcm4908: automatically set DEVICE_DTS from device name

Message ID 20210119185307.58048-1-freifunk@adrianschmutzler.de
State Superseded
Delegated to: Adrian Schmutzler
Headers show
Series bcm4908: automatically set DEVICE_DTS from device name | expand

Commit Message

Adrian Schmutzler Jan. 19, 2021, 6:53 p.m. UTC
This sets the DTS paths automatically based on their device definition
name. Devices where this is not possible may still be served by simply
overwriting DEVICE_DTS in their respective definition.

Cc: Rafał Miłecki <rafal@milecki.pl>

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>

---

Of course, any paths which are not static may be moved from DTS_DIR
to the DEVICE_DTS line.

(Note that this will break anything that would depend on DTS_DIR
_without_ DEVICE_DTS following it. (Didn't spot anything yet.))
---
 target/linux/bcm4908/image/Makefile | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Rafał Miłecki Jan. 19, 2021, 7:12 p.m. UTC | #1
On 19.01.2021 19:53, Adrian Schmutzler wrote:
> This sets the DTS paths automatically based on their device definition
> name. Devices where this is not possible may still be served by simply
> overwriting DEVICE_DTS in their respective definition.
> 
> Cc: Rafał Miłecki <rafal@milecki.pl>
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> 
> ---
> 
> Of course, any paths which are not static may be moved from DTS_DIR
> to the DEVICE_DTS line.
> 
> (Note that this will break anything that would depend on DTS_DIR
> _without_ DEVICE_DTS following it. (Didn't spot anything yet.))

It should be possible to make final defines even simpler by using some
wildcard magic. You could avoid defining SOC then.

Please take a look at the:
target/linux/bcm53xx/image/Makefile

It has some magic² code as follows:
DEVICE_DTS := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(subst _,-,$(1)).dtb)))

If you could adopt above magic to the bcm4908 it would be great. If not
your suggested solution is probably still better than what we have now.
Adrian Schmutzler Jan. 19, 2021, 7:30 p.m. UTC | #2
> It should be possible to make final defines even simpler by using some
> wildcard magic. You could avoid defining SOC then.
> 
> Please take a look at the:
> target/linux/bcm53xx/image/Makefile
> 
> It has some magic² code as follows:
> DEVICE_DTS := $(patsubst %.dtb,%,$(notdir $(wildcard $(if
> $(IB),$(KDIR),$(DTS_DIR))/*-$(subst _,-,$(1)).dtb)))
> 
> If you could adopt above magic to the bcm4908 it would be great. If not your
> suggested solution is probably still better than what we have now.

Something inside me heavily resists against just using wildcards for a case like this, though I'm aware that this will probably allow us to remove hundreds of SOC definitions. I will think about it ...

Best

Adrian
diff mbox series

Patch

diff --git a/target/linux/bcm4908/image/Makefile b/target/linux/bcm4908/image/Makefile
index f5db38915d..bf30c5c867 100644
--- a/target/linux/bcm4908/image/Makefile
+++ b/target/linux/bcm4908/image/Makefile
@@ -13,6 +13,8 @@  define Build/bcm4908kernel
 	mv $@.new $@
 endef
 
+DTS_DIR := $(DTS_DIR)/broadcom/bcm4908
+
 define Device/Default
   KERNEL := kernel-bin | bcm4908lzma | bcm4908kernel
   KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
@@ -20,23 +22,24 @@  define Device/Default
   KERNEL_INITRAMFS := kernel-bin | bcm4908lzma | bcm4908kernel
   FILESYSTEMS := squashfs
   KERNEL_NAME := Image
+  DEVICE_DTS = $$(SOC)-$(subst _,-,$(1))
   IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
   BLOCKSIZE := 128k
   PAGESIZE := 2048
 endef
 
 define Device/asus_gt-ac5300
+  SOC := bcm4908
   DEVICE_VENDOR := Asus
   DEVICE_MODEL := GT-AC5300
-  DEVICE_DTS := broadcom/bcm4908/bcm4908-asus-gt-ac5300
   IMAGES := bin
 endef
 TARGET_DEVICES += asus_gt-ac5300
 
 define Device/netgear_r8000p
+  SOC := bcm4906
   DEVICE_VENDOR := Netgear
   DEVICE_MODEL := R8000P
-  DEVICE_DTS := broadcom/bcm4908/bcm4906-netgear-r8000p
   IMAGES := bin
 endef
 TARGET_DEVICES += netgear_r8000p