From 579875cdcbd028b73e09b077dc13138e867ba27d Mon Sep 17 00:00:00 2001 From: Matthias Hentges Date: Wed, 6 Jun 2007 02:27:38 +0000 Subject: usb-gadget-mode: Add usb-gadget mode: An initscript to load the configured USB gadget module on boot --- packages/usb-gadget-mode/files/.mtn2git_empty | 0 .../usb-gadget-mode/files/spitz/.mtn2git_empty | 0 packages/usb-gadget-mode/files/usb-gadget | 59 ++++++++++++++++++++++ packages/usb-gadget-mode/files/usb-gadget.conf | 3 ++ packages/usb-gadget-mode/files/usb-gadget.init | 16 ++++++ 5 files changed, 78 insertions(+) create mode 100644 packages/usb-gadget-mode/files/.mtn2git_empty create mode 100644 packages/usb-gadget-mode/files/spitz/.mtn2git_empty create mode 100755 packages/usb-gadget-mode/files/usb-gadget create mode 100644 packages/usb-gadget-mode/files/usb-gadget.conf create mode 100755 packages/usb-gadget-mode/files/usb-gadget.init (limited to 'packages/usb-gadget-mode/files') diff --git a/packages/usb-gadget-mode/files/.mtn2git_empty b/packages/usb-gadget-mode/files/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/usb-gadget-mode/files/spitz/.mtn2git_empty b/packages/usb-gadget-mode/files/spitz/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/usb-gadget-mode/files/usb-gadget b/packages/usb-gadget-mode/files/usb-gadget new file mode 100755 index 0000000000..611703f09d --- /dev/null +++ b/packages/usb-gadget-mode/files/usb-gadget @@ -0,0 +1,59 @@ +#! /bin/sh +# +# Copyright Matthias Hentges (c) 2007 +# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the license) +# +# Filename: usb-gadget +# Date: 20070606 (YMD) +# +################################################################################# +# +# 20070606 - v0.0.1 - Initial release + +CONF_FILE="/etc/usb-gadget.conf" + +die() { + echo "ERROR: $1" + exit 1 +} + +go() { + test -e "$CONF_FILE" && . "$CONF_FILE" + + case "$USB_MODE" in + networking) setup_usb g_ether "$MODULE_OPTIONS" ;; + storage) setup_usb g_file_storage "$MODULE_OPTIONS" ;; + none) unload_usb_gadgets ;; + esac + +} + +setup_usb() { + + if ! ( lsmod | grep -q "$1" ) + then + unload_usb_gadgets + echo "Loading [$1]" + modprobe "$1" "$MODULE_OPTIONS" + else + echo "Already loaded: [$1]" + fi +} + +unload_usb_gadgets() { + KERNEL_VERSION="`uname -r`" + GADGET_MODULES="`find /lib/modules/$KERNEL_VERSION/kernel/drivers/usb/gadget -name "*g_*"`" + + for module in $GADGET_MODULES + do + MODULE_NAME="`basename $module | sed "s/\.ko//"`" + + if ( lsmod | grep -q "$MODULE_NAME" ) + then + echo "Unloading [$MODULE_NAME]" + rmmod "$module" + fi + done +} + +go diff --git a/packages/usb-gadget-mode/files/usb-gadget.conf b/packages/usb-gadget-mode/files/usb-gadget.conf new file mode 100644 index 0000000000..3b5ebd6433 --- /dev/null +++ b/packages/usb-gadget-mode/files/usb-gadget.conf @@ -0,0 +1,3 @@ +USB_MODE="" +MODULE_OPTIONS="" + diff --git a/packages/usb-gadget-mode/files/usb-gadget.init b/packages/usb-gadget-mode/files/usb-gadget.init new file mode 100755 index 0000000000..7bf456b652 --- /dev/null +++ b/packages/usb-gadget-mode/files/usb-gadget.init @@ -0,0 +1,16 @@ +#! /bin/sh +# +# Copyright Matthias Hentges (c) 2007 +# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the license) +# +# Filename: usb-gadget.init +# Date: 20070606 (YMD) +# +################################################################################# +# +# 20070606 - v0.0.1 - Initial release + +case "$1" in +start) usb-gadget ;; +esac + -- cgit v1.2.3 From 17e36de1bc84f625ac59e7180038923b09657057 Mon Sep 17 00:00:00 2001 From: Matthias Hentges Date: Wed, 6 Jun 2007 02:31:09 +0000 Subject: usb-gadget-mode: Add default configuration (g_ether) for akita, spitz, tosa, c7x0 and collie --- packages/usb-gadget-mode/files/akita/.mtn2git_empty | 0 packages/usb-gadget-mode/files/akita/usb-gadget.conf | 3 +++ packages/usb-gadget-mode/files/c7x0/.mtn2git_empty | 0 packages/usb-gadget-mode/files/c7x0/usb-gadget.conf | 3 +++ packages/usb-gadget-mode/files/collie/.mtn2git_empty | 0 packages/usb-gadget-mode/files/collie/usb-gadget.conf | 3 +++ packages/usb-gadget-mode/files/tosa/.mtn2git_empty | 0 packages/usb-gadget-mode/files/tosa/usb-gadget.conf | 3 +++ 8 files changed, 12 insertions(+) create mode 100644 packages/usb-gadget-mode/files/akita/.mtn2git_empty create mode 100644 packages/usb-gadget-mode/files/akita/usb-gadget.conf create mode 100644 packages/usb-gadget-mode/files/c7x0/.mtn2git_empty create mode 100644 packages/usb-gadget-mode/files/c7x0/usb-gadget.conf create mode 100644 packages/usb-gadget-mode/files/collie/.mtn2git_empty create mode 100644 packages/usb-gadget-mode/files/collie/usb-gadget.conf create mode 100644 packages/usb-gadget-mode/files/tosa/.mtn2git_empty create mode 100644 packages/usb-gadget-mode/files/tosa/usb-gadget.conf (limited to 'packages/usb-gadget-mode/files') diff --git a/packages/usb-gadget-mode/files/akita/.mtn2git_empty b/packages/usb-gadget-mode/files/akita/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/usb-gadget-mode/files/akita/usb-gadget.conf b/packages/usb-gadget-mode/files/akita/usb-gadget.conf new file mode 100644 index 0000000000..717687d4c3 --- /dev/null +++ b/packages/usb-gadget-mode/files/akita/usb-gadget.conf @@ -0,0 +1,3 @@ +USB_MODE="networking" +MODULE_OPTIONS="" + diff --git a/packages/usb-gadget-mode/files/c7x0/.mtn2git_empty b/packages/usb-gadget-mode/files/c7x0/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/usb-gadget-mode/files/c7x0/usb-gadget.conf b/packages/usb-gadget-mode/files/c7x0/usb-gadget.conf new file mode 100644 index 0000000000..717687d4c3 --- /dev/null +++ b/packages/usb-gadget-mode/files/c7x0/usb-gadget.conf @@ -0,0 +1,3 @@ +USB_MODE="networking" +MODULE_OPTIONS="" + diff --git a/packages/usb-gadget-mode/files/collie/.mtn2git_empty b/packages/usb-gadget-mode/files/collie/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/usb-gadget-mode/files/collie/usb-gadget.conf b/packages/usb-gadget-mode/files/collie/usb-gadget.conf new file mode 100644 index 0000000000..717687d4c3 --- /dev/null +++ b/packages/usb-gadget-mode/files/collie/usb-gadget.conf @@ -0,0 +1,3 @@ +USB_MODE="networking" +MODULE_OPTIONS="" + diff --git a/packages/usb-gadget-mode/files/tosa/.mtn2git_empty b/packages/usb-gadget-mode/files/tosa/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/usb-gadget-mode/files/tosa/usb-gadget.conf b/packages/usb-gadget-mode/files/tosa/usb-gadget.conf new file mode 100644 index 0000000000..717687d4c3 --- /dev/null +++ b/packages/usb-gadget-mode/files/tosa/usb-gadget.conf @@ -0,0 +1,3 @@ +USB_MODE="networking" +MODULE_OPTIONS="" + -- cgit v1.2.3 From 93e4b32cc494bffacdcc216924eb9aaa6a9861cd Mon Sep 17 00:00:00 2001 From: Matthias Hentges Date: Wed, 6 Jun 2007 23:24:07 +0000 Subject: usb-gadget-mode: Move /etc/usb-gadget.conf to /etc/default/usb-gadget as suggested on the ML --- packages/usb-gadget-mode/files/usb-gadget | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/usb-gadget-mode/files') diff --git a/packages/usb-gadget-mode/files/usb-gadget b/packages/usb-gadget-mode/files/usb-gadget index 611703f09d..4fdc429f5b 100755 --- a/packages/usb-gadget-mode/files/usb-gadget +++ b/packages/usb-gadget-mode/files/usb-gadget @@ -10,7 +10,7 @@ # # 20070606 - v0.0.1 - Initial release -CONF_FILE="/etc/usb-gadget.conf" +CONF_FILE="/etc/default/usb-gadget" die() { echo "ERROR: $1" -- cgit v1.2.3