busybox: add mdev hotplug handlers

Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
Javier Viguera 2012-11-29 18:47:00 +01:00
parent 972963f83f
commit 219110cc76
5 changed files with 240 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
}