From 219110cc76b4bda57a5635b1eab89ca7bc07989f Mon Sep 17 00:00:00 2001 From: Javier Viguera Date: Thu, 29 Nov 2012 18:47:00 +0100 Subject: [PATCH] busybox: add mdev hotplug handlers Signed-off-by: Javier Viguera --- .../recipes-core/busybox/busybox-1.20.2/adc | 35 +++++++++ .../recipes-core/busybox/busybox-1.20.2/mmc | 73 +++++++++++++++++++ .../recipes-core/busybox/busybox-1.20.2/sd | 73 +++++++++++++++++++ .../recipes-core/busybox/busybox-1.20.2/ts | 41 +++++++++++ .../recipes-core/busybox/busybox_1.20.2.bb | 18 +++++ 5 files changed, 240 insertions(+) create mode 100755 meta-digi-del/recipes-core/busybox/busybox-1.20.2/adc create mode 100755 meta-digi-del/recipes-core/busybox/busybox-1.20.2/mmc create mode 100755 meta-digi-del/recipes-core/busybox/busybox-1.20.2/sd create mode 100755 meta-digi-del/recipes-core/busybox/busybox-1.20.2/ts diff --git a/meta-digi-del/recipes-core/busybox/busybox-1.20.2/adc b/meta-digi-del/recipes-core/busybox/busybox-1.20.2/adc new file mode 100755 index 000000000..d2bed4f1d --- /dev/null +++ b/meta-digi-del/recipes-core/busybox/busybox-1.20.2/adc @@ -0,0 +1,35 @@ +#!/bin/sh +#=============================================================================== +# +# adc +# +# Copyright (C) 2009 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# !Description: handle ADC nodes +# +#=============================================================================== + +dev_table=" +/dev/adc d 755 0 0 +/dev/adc/ c 644 0 0 %s 0 0 1 %s +" + +case "${ACTION}" in +add) + major="$(sed -ne 's,\([^[:blank:]\+]\)[[:blank:]].*adc.*,\1,g;T;p' /proc/devices)" + [ "${MDEV}" = "s3c2443-adc" ] && channels="10" + [ "${MDEV}" = "adc-ns9215" ] && channels="8" + if [ -n "${major}" -a -n "${channels}" ]; then + printf "${dev_table}" "${major}" "${channels}" | makedevs / >/dev/null 2>&1 + fi + ;; +remove) + [ -d "/dev/adc" ] && rm -rf /dev/adc + ;; +esac diff --git a/meta-digi-del/recipes-core/busybox/busybox-1.20.2/mmc b/meta-digi-del/recipes-core/busybox/busybox-1.20.2/mmc new file mode 100755 index 000000000..a44812c28 --- /dev/null +++ b/meta-digi-del/recipes-core/busybox/busybox-1.20.2/mmc @@ -0,0 +1,73 @@ +#!/bin/sh +#=============================================================================== +# +# mmc +# +# Copyright (C) 2009 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# !Description: mount/umount mmc/sd cards +# +#=============================================================================== + +SCRIPTNAME="$(basename ${0})" + +usage() { + [ "${SCRIPTNAME}" = "mmc-mount" ] && printf "\nMount mmc storage drives\n" + [ "${SCRIPTNAME}" = "mmc-umount" ] && printf "\nUmount mmc storage drives\n" + printf "\nUsage: ${SCRIPTNAME} [OPTIONS]\n\n" +} + +while getopts "" c; do + case "${c}" in + *) + usage + exit + ;; + esac +done + +if [ "${SCRIPTNAME}" = "mmc" ]; then + # Script run via mdev + case "${ACTION}" in + add) + # Create mountpoint and mount the mmc device + if mkdir -p /media/${MDEV} && ! mountpoint -q /media/${MDEV}; then + mount /dev/${MDEV} /media/${MDEV} + fi + ;; + remove) + # Umount and then remove mountpoint + if grep -q "/dev/${MDEV}[[:blank:]]" /proc/mounts; then + mdir=$(sed -ne "s,/dev/${MDEV}[[:blank:]]\+\([^[:blank:]]\+\)[[:blank:]].*,\1,g;T;p" /proc/mounts) + umount "${mdir}" + rmdir -- "${mdir}" 2>/dev/null + fi + ;; + esac +elif [ "${SCRIPTNAME}" = "mmc-mount" ]; then + # Script run via command line [mmc-mount] + for i in /sys/block/mmcblk[0-9]/mmcblk[0-9]p[1-9]*; do + [ "${i}" = "/sys/block/mmcblk[0-9]/mmcblk[0-9]p[1-9]*" ] && continue + device="$(basename ${i})" + if mkdir -p /media/${device} && ! mountpoint -q /media/${device}; then + echo -n "Mounting /dev/${device} on /media/${device}: " + mount /dev/${device} /media/${device} + echo "done." + fi + done +elif [ "${SCRIPTNAME}" = "mmc-umount" ]; then + # Script run via command line [mmc-umount] + for i in /media/mmcblk*; do + [ "${i}" = "/media/mmcblk*" ] && continue + if mountpoint -q $i; then + umount "$i" + rmdir -- "$i" 2>/dev/null + fi + done +fi diff --git a/meta-digi-del/recipes-core/busybox/busybox-1.20.2/sd b/meta-digi-del/recipes-core/busybox/busybox-1.20.2/sd new file mode 100755 index 000000000..d31785bd9 --- /dev/null +++ b/meta-digi-del/recipes-core/busybox/busybox-1.20.2/sd @@ -0,0 +1,73 @@ +#!/bin/sh +#=============================================================================== +# +# sd +# +# Copyright (C) 2009 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# !Description: mount/umount SCSI disk devices +# +#=============================================================================== + +SCRIPTNAME="$(basename ${0})" + +usage() { + [ "${SCRIPTNAME}" = "usbmount" ] && printf "\nMount usb storage drives\n" + [ "${SCRIPTNAME}" = "usbumount" ] && printf "\nUmount usb storage drives\n" + printf "\nUsage: ${SCRIPTNAME} [OPTIONS]\n\n" +} + +while getopts "" c; do + case "${c}" in + *) + usage + exit + ;; + esac +done + +if [ "${SCRIPTNAME}" = "sd" ]; then + # Script run via mdev + case "${ACTION}" in + add) + # Create mountpoint and mount the sd device + if mkdir -p /media/${MDEV} && ! mountpoint -q /media/${MDEV}; then + mount /dev/${MDEV} /media/${MDEV} + fi + ;; + remove) + # Umount and then remove mountpoint + if grep -q "/dev/${MDEV}[[:blank:]]" /proc/mounts; then + mdir=$(sed -ne "s,/dev/${MDEV}[[:blank:]]\+\([^[:blank:]]\+\)[[:blank:]].*,\1,g;T;p" /proc/mounts) + umount "${mdir}" + rmdir -- "${mdir}" 2>/dev/null + fi + ;; + esac +elif [ "${SCRIPTNAME}" = "usbmount" ]; then + # Script run via command line [usbmount] + for i in /sys/block/sd[a-z]/sd[a-z][1-9]*; do + [ "${i}" = "/sys/block/sd[a-z]/sd[a-z][1-9]*" ] && continue + device="$(basename ${i})" + if mkdir -p /media/${device} && ! mountpoint -q /media/${device}; then + echo -n "Mounting /dev/${device} on /media/${device}: " + mount /dev/${device} /media/${device} + echo "done." + fi + done +elif [ "${SCRIPTNAME}" = "usbumount" ]; then + # Script run via command line [usbumount] + for i in /media/sd*; do + [ "${i}" = "/media/sd*" ] && continue + if mountpoint -q $i; then + umount "$i" + rmdir -- "$i" 2>/dev/null + fi + done +fi diff --git a/meta-digi-del/recipes-core/busybox/busybox-1.20.2/ts b/meta-digi-del/recipes-core/busybox/busybox-1.20.2/ts new file mode 100755 index 000000000..e518ccc2e --- /dev/null +++ b/meta-digi-del/recipes-core/busybox/busybox-1.20.2/ts @@ -0,0 +1,41 @@ +#!/bin/sh +#=============================================================================== +# +# ts +# +# Copyright (C) 2010 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# !Description: symlink touchscreen devices +# +# i.MX5X: +# ts0 -> mxc_ts (i.MX51) +# ts0 -> da9052-tsi (i.MX53) +# ts1 -> ADS784x (Fusion and ADS cannot be enabled simultaneously) +# ts1 -> Fusion touch +# +#=============================================================================== + +# ${ACTION} is empty on scanning mode (mdev -s), exit otherwise +[ -n "${ACTION}" ] && exit + +mdev=$(basename ${MDEV}) + +if echo "${DEL_PLATFORM}" | grep -qs 'mx5'; then + if grep -qs 'mxc_ts' /sys/class/input/${mdev}/device/name; then + ln -sf ${mdev} /dev/input/ts0 + elif grep -qs 'tsi' /sys/class/input/${mdev}/device/name; then + ln -sf ${mdev} /dev/input/ts0 + elif grep -qs 'ADS784x' /sys/class/input/${mdev}/device/name; then + ln -sf ${mdev} /dev/input/ts1 + elif grep -qs 'fusion' /sys/class/input/${mdev}/device/name; then + ln -sf ${mdev} /dev/input/ts1 + fi +else + grep -qs '[Tt]ouch' /sys/class/input/${mdev}/device/name && ln -sf ${mdev} /dev/input/ts0 +fi diff --git a/meta-digi-del/recipes-core/busybox/busybox_1.20.2.bb b/meta-digi-del/recipes-core/busybox/busybox_1.20.2.bb index 95fbc7097..6ca9b964c 100644 --- a/meta-digi-del/recipes-core/busybox/busybox_1.20.2.bb +++ b/meta-digi-del/recipes-core/busybox/busybox_1.20.2.bb @@ -20,9 +20,27 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ file://busybox-udhcpc \ file://mdev \ file://mdev.conf \ + file://adc \ + file://mmc \ + file://sd \ + file://ts \ " SRC_URI[tarball.md5sum] = "e025414bc6cd79579cc7a32a45d3ae1c" SRC_URI[tarball.sha256sum] = "eb13ff01dae5618ead2ef6f92ba879e9e0390f9583bd545d8789d27cf39b6882" +FILES_${PN}-mdev += "${base_libdir}/mdev/adc ${base_libdir}/mdev/mmc ${base_libdir}/mdev/sd ${base_libdir}/mdev/ts" + EXTRA_OEMAKE += "ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX}" + +do_install_append() { + if grep "CONFIG_MDEV=y" ${WORKDIR}/defconfig; then + if grep "CONFIG_FEATURE_MDEV_CONF=y" ${WORKDIR}/defconfig; then + install -d ${D}${base_libdir}/mdev + install -m 0755 ${WORKDIR}/adc ${D}${base_libdir}/mdev/adc + install -m 0755 ${WORKDIR}/mmc ${D}${base_libdir}/mdev/mmc + install -m 0755 ${WORKDIR}/sd ${D}${base_libdir}/mdev/sd + install -m 0755 ${WORKDIR}/ts ${D}${base_libdir}/mdev/ts + fi + fi +}