summaryrefslogtreecommitdiff
path: root/package/mmc_over_gpio/files/mmc_over_gpio.init
diff options
context:
space:
mode:
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2008-11-17 23:22:27 +0000
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>2008-11-17 23:22:27 +0000
commitf82ba8711581cb007b8f2b49cc033eaabc03c0bf (patch)
tree919d77b20d506f5acef4b0c71cb8421fee88bed3 /package/mmc_over_gpio/files/mmc_over_gpio.init
parent4454a35bc042239402d1eabaa0904a4c134e38eb (diff)
make mmc_over_gpio init uci-aware
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@13273 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/mmc_over_gpio/files/mmc_over_gpio.init')
-rw-r--r--package/mmc_over_gpio/files/mmc_over_gpio.init27
1 files changed, 23 insertions, 4 deletions
diff --git a/package/mmc_over_gpio/files/mmc_over_gpio.init b/package/mmc_over_gpio/files/mmc_over_gpio.init
index e276dfd1ca..121c80398c 100644
--- a/package/mmc_over_gpio/files/mmc_over_gpio.init
+++ b/package/mmc_over_gpio/files/mmc_over_gpio.init
@@ -8,7 +8,7 @@ CONFIGFS_DIR="/config/gpiommc"
add_device() {
local dir="$CONFIGFS_DIR/$1"
- mkdir $dir
+ mkdir -p $dir
[ $? -eq 0 ] || return 1
echo $2 > $dir/gpio_data_in
[ $? -eq 0 ] || return 1
@@ -50,15 +50,34 @@ mount_configfs() {
return 0
}
+start_service() {
+ local section="$1"
+ config_get "name" "$section" "name"
+ config_get "DI_pin" "$section" "DI_pin"
+ config_get "DO_pin" "$section" "DO_pin"
+ config_get "CLK_pin" "$section" "CLK_pin"
+ config_get "CS_pin" "$section" "CS_pin"
+ config_get "mode" "$section" "mode"
+ config_get_bool "enabled" "$section" "enabled" '1'
+ [ "$enabled" -gt 0 ] && add_device "$name" $DI_pin $DO_pin $CLK_pin $CS_pin $mode &
+}
+
+stop_service() {
+ local section="$1"
+ config_get "name" "$section" "name"
+ remove_device "$name"
+}
+
start() {
# Make sure configfs is mounted
mount_configfs
[ $? -eq 0 ] || return 1
- #FIXME we should use a config file, but I dunno how that parser works.
- add_device "default" 5 4 3 7 0
+ config_load "mmc_over_gpio"
+ config_foreach start_service "mmc_over_gpio"
}
stop() {
- remove_device "default"
+ config_load "mmc_over_gpio"
+ config_foreach stop_service "mmc_over_gpio"
}