From 4159054fbbf8a7176eaf3dd4467c5b0db70769d0 Mon Sep 17 00:00:00 2001
From: Sungbo Eo <mans0n@gorani.run>
Date: Thu, 5 Mar 2020 23:22:47 +0900
Subject: [PATCH] kernel: make kmod-hwmon-core selected by dependent modules

Currently kmod-hwmon-* will not get into images unless kmod-hwmon-core is added
to DEVICE_PACKAGES as well. By changing the dependencies from "depends on" to
"select", we do not have the issue anymore.

Furthermore, we can remove most occurrences of the package from DEVICE_PACKAGES
and similar variables, as it is now pulled by dependent modules such as:
- kmod-hwmon-gpiofan
- kmod-hwmon-lm63
- kmod-hwmon-lm75
- kmod-hwmon-lm85
- kmod-hwmon-lm90

Signed-off-by: Sungbo Eo <mans0n@gorani.run>
[do not touch ar71xx, adjust line wrapping]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
 package/kernel/hwmon-gsc/Makefile               | 2 +-
 package/kernel/linux/modules/hwmon.mk           | 2 +-
 target/linux/kirkwood/image/Makefile            | 5 ++---
 target/linux/mpc85xx/image/Makefile             | 2 +-
 target/linux/oxnas/image/ox820.mk               | 2 +-
 target/linux/oxnas/ox820/profiles/00-default.mk | 5 ++---
 6 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/package/kernel/hwmon-gsc/Makefile b/package/kernel/hwmon-gsc/Makefile
index 454f685f8f4..95f6fab4c09 100644
--- a/package/kernel/hwmon-gsc/Makefile
+++ b/package/kernel/hwmon-gsc/Makefile
@@ -8,7 +8,7 @@ include $(INCLUDE_DIR)/package.mk
 
 define KernelPackage/hwmon-gsc
   SUBMENU:=Hardware Monitoring Support
-  DEPENDS:=@TARGET_imx6||TARGET_cns3xxx kmod-hwmon-core +kmod-i2c-core
+  DEPENDS:=@TARGET_imx6||TARGET_cns3xxx +kmod-hwmon-core +kmod-i2c-core
   TITLE:=Driver for the Gateworks System Controller
   AUTOLOAD:=$(call AutoLoad,60,gsc)
   FILES:=$(PKG_BUILD_DIR)/gsc.ko
diff --git a/package/kernel/linux/modules/hwmon.mk b/package/kernel/linux/modules/hwmon.mk
index c0a477856e9..73b448022de 100644
--- a/package/kernel/linux/modules/hwmon.mk
+++ b/package/kernel/linux/modules/hwmon.mk
@@ -26,7 +26,7 @@ $(eval $(call KernelPackage,hwmon-core))
 
 define AddDepends/hwmon
   SUBMENU:=$(HWMON_MENU)
-  DEPENDS:=kmod-hwmon-core $(1)
+  DEPENDS:=+kmod-hwmon-core $(1)
 endef
 
 define KernelPackage/hwmon-ads1015
diff --git a/target/linux/kirkwood/image/Makefile b/target/linux/kirkwood/image/Makefile
index 7de62d13ca1..67dd53af702 100644
--- a/target/linux/kirkwood/image/Makefile
+++ b/target/linux/kirkwood/image/Makefile
@@ -65,7 +65,7 @@ define Device/iom_ix2-200
   DEVICE_VENDOR := Iomega
   DEVICE_MODEL := StorCenter ix2-200
   DEVICE_DTS := kirkwood-iomega_ix2_200
-  DEVICE_PACKAGES := kmod-gpio-button-hotplug kmod-hwmon-core kmod-hwmon-lm63
+  DEVICE_PACKAGES := kmod-gpio-button-hotplug kmod-hwmon-lm63
   DEVICE_TYPE:=nas
   PAGESIZE := 512
   SUBPAGESIZE := 256
@@ -137,8 +137,7 @@ TARGET_DEVICES += seagate_goflexhome
 define Device/zyxel_nsa310b
   DEVICE_VENDOR := ZyXEL
   DEVICE_MODEL := NSA310b
-  DEVICE_PACKAGES := kmod-r8169 kmod-gpio-button-hotplug kmod-hwmon-core \
-	kmod-hwmon-lm85
+  DEVICE_PACKAGES := kmod-r8169 kmod-gpio-button-hotplug kmod-hwmon-lm85
   BOARD_NAME := nsa310b
 endef
 TARGET_DEVICES += zyxel_nsa310b
diff --git a/target/linux/mpc85xx/image/Makefile b/target/linux/mpc85xx/image/Makefile
index 98fe51c7e9e..40002c13c47 100644
--- a/target/linux/mpc85xx/image/Makefile
+++ b/target/linux/mpc85xx/image/Makefile
@@ -111,7 +111,7 @@ define Device/freescale_p2020rdb
   DEVICE_VENDOR := Freescale
   DEVICE_MODEL := P2020RDB
   DEVICE_DTS_DIR := $(DTS_DIR)/fsl
-  DEVICE_PACKAGES := kmod-hwmon-core kmod-hwmon-lm90 kmod-rtc-ds1307 \
+  DEVICE_PACKAGES := kmod-hwmon-lm90 kmod-rtc-ds1307 \
 	kmod-gpio-pca953x kmod-eeprom-at24
   BLOCKSIZE := 128k
   KERNEL := kernel-bin | gzip | \
diff --git a/target/linux/oxnas/image/ox820.mk b/target/linux/oxnas/image/ox820.mk
index 41ab3e230a6..c0e0733f8e6 100644
--- a/target/linux/oxnas/image/ox820.mk
+++ b/target/linux/oxnas/image/ox820.mk
@@ -71,7 +71,7 @@ define Device/shuttle_kd20
   KERNEL_INITRAMFS = kernel-bin | append-dtb | uImage none | omninas-factory | encrypt-3des sohmuntitnlaes
   DEVICE_PACKAGES := kmod-usb2-oxnas kmod-ata-oxnas-sata kmod-usb-ledtrig-usbport \
                      kmod-usb3 kmod-i2c-gpio kmod-rtc-pcf8563 kmod-gpio-beeper \
-                     kmod-hwmon-core kmod-hwmon-gpiofan \
+                     kmod-hwmon-gpiofan \
                      kmod-md-mod kmod-md-raid0 kmod-md-raid1 kmod-fs-ext4 kmod-fs-xfs
 endef
 TARGET_DEVICES += shuttle_kd20
diff --git a/target/linux/oxnas/ox820/profiles/00-default.mk b/target/linux/oxnas/ox820/profiles/00-default.mk
index fedf7300884..c68d7cd9d60 100644
--- a/target/linux/oxnas/ox820/profiles/00-default.mk
+++ b/target/linux/oxnas/ox820/profiles/00-default.mk
@@ -9,9 +9,8 @@ define Profile/Default
 	NAME:=Default Profile
 	PRIORITY:=1
 	PACKAGES:=\
-		kmod-i2c-gpio kmod-gpio-beeper kmod-hwmon-core \
-		kmod-hwmon-gpiofan kmod-rtc-pcf8563 kmod-rtc-ds1307 \
-		kmod-usb3
+		kmod-i2c-gpio kmod-gpio-beeper kmod-hwmon-gpiofan \
+		kmod-rtc-pcf8563 kmod-rtc-ds1307 kmod-usb3
 endef
 
 define Profile/Default/Description
-- 
GitLab