diff mbox series

[OpenWrt-Devel,3/3] base-files: move find_mtd_chardev() to /lib/functions.sh

Message ID 20200313161122.32858-3-freifunk@adrianschmutzler.de
State Under Review
Delegated to: Adrian Schmutzler
Headers show
Series [OpenWrt-Devel,1/3] base-files: do not source system.sh in functions.sh | expand

Commit Message

Adrian Schmutzler March 13, 2020, 4:11 p.m. UTC
While find_mtd_index() and find_mtd_part() are located in
/lib/functions.sh, find_mtd_chardev() has been located in
/lib/functions/system.sh.

Move the latter to the former file to keep similar functions
together.

While at it, fix some corresponding includes.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
 package/base-files/Makefile                               | 2 +-
 package/base-files/files/lib/functions.sh                 | 8 ++++++++
 package/base-files/files/lib/functions/system.sh          | 8 --------
 .../ath79/base-files/lib/functions/mikrotik-caldata.sh    | 2 ++
 .../linux/lantiq/xrx200/base-files/etc/board.d/02_network | 1 +
 5 files changed, 12 insertions(+), 9 deletions(-)

Comments

mans0n March 16, 2020, 4:07 p.m. UTC | #1
On 2020-03-14 01:11, Adrian Schmutzler wrote:
> While find_mtd_index() and find_mtd_part() are located in
> /lib/functions.sh, find_mtd_chardev() has been located in
> /lib/functions/system.sh.
> 
> Move the latter to the former file to keep similar functions
> together.

Umm, what about mtd_get_part_size()? It also seems more related to mtd 
rather than macaddr.

> 
> While at it, fix some corresponding includes.
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> ---
>   package/base-files/Makefile                               | 2 +-
>   package/base-files/files/lib/functions.sh                 | 8 ++++++++
>   package/base-files/files/lib/functions/system.sh          | 8 --------
>   .../ath79/base-files/lib/functions/mikrotik-caldata.sh    | 2 ++
>   .../linux/lantiq/xrx200/base-files/etc/board.d/02_network | 1 +
>   5 files changed, 12 insertions(+), 9 deletions(-)
>
diff mbox series

Patch

diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 8e252153fe..87c43fdc0c 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -12,7 +12,7 @@  include $(INCLUDE_DIR)/version.mk
 include $(INCLUDE_DIR)/feeds.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=215
+PKG_RELEASE:=216
 PKG_FLAGS:=nonshared
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index a77b669709..0438e9e25a 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -302,6 +302,14 @@  find_mtd_part() {
 	echo "${INDEX:+$PREFIX$INDEX}"
 }
 
+find_mtd_chardev() {
+	local INDEX=$(find_mtd_index "$1")
+	local PREFIX=/dev/mtd
+
+	[ -d /dev/mtd ] && PREFIX=/dev/mtd/
+	echo "${INDEX:+$PREFIX$INDEX}"
+}
+
 group_add() {
 	local name="$1"
 	local gid="$2"
diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index c7aa7bf75c..b5c68acb15 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -53,14 +53,6 @@  get_mac_label() {
 	echo $macaddr
 }
 
-find_mtd_chardev() {
-	local INDEX=$(find_mtd_index "$1")
-	local PREFIX=/dev/mtd
-
-	[ -d /dev/mtd ] && PREFIX=/dev/mtd/
-	echo "${INDEX:+$PREFIX$INDEX}"
-}
-
 mtd_get_mac_ascii() {
 	local mtdname="$1"
 	local key="$2"
diff --git a/target/linux/ath79/base-files/lib/functions/mikrotik-caldata.sh b/target/linux/ath79/base-files/lib/functions/mikrotik-caldata.sh
index 9c4016ee5d..81e262d874 100644
--- a/target/linux/ath79/base-files/lib/functions/mikrotik-caldata.sh
+++ b/target/linux/ath79/base-files/lib/functions/mikrotik-caldata.sh
@@ -4,6 +4,8 @@ 
 # Helper function to extract MAC addresses and calibration data for MikroTik
 #
 
+. /lib/functions/caldata.sh
+
 mikrotik_caldata_extract() {
 	local part=$1
 	local offset=$(($2))
diff --git a/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network b/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network
index f39898263d..6bb52ccf0c 100755
--- a/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network
+++ b/target/linux/lantiq/xrx200/base-files/etc/board.d/02_network
@@ -3,6 +3,7 @@ 
 # Copyright (C) 2011-2015 OpenWrt.org
 #
 
+. /lib/functions.sh
 . /lib/functions/uci-defaults.sh
 . /lib/functions/system.sh
 . /lib/functions/lantiq.sh