Skip to content

Commit c13f10f

Browse files
committed
Add digimend-debug tool
Fixes #285
1 parent 00a0624 commit c13f10f

File tree

3 files changed

+85
-5
lines changed

3 files changed

+85
-5
lines changed

Makefile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ DEPMOD_CONF = $(DESTDIR)/etc/depmod.d/digimend.conf
1212
DRACUT_CONF_DIR = $(DESTDIR)/usr/lib/dracut/dracut.conf.d
1313
DRACUT_CONF = $(DRACUT_CONF_DIR)/90-digimend.conf
1414
HID_REBIND = $(DESTDIR)/lib/udev/hid-rebind
15+
DIGIMEND_DEBUG = $(DESTDIR)/usr/sbin/digimend-debug
1516
XORG_CONF := $(DESTDIR)/usr/share/X11/xorg.conf.d/50-digimend.conf
1617
PACKAGE_NAME = digimend-kernel-drivers
1718
PACKAGE_VERSION = 10
@@ -51,6 +52,12 @@ xorg_conf_install:
5152
xorg_conf_uninstall:
5253
rm -vf $(XORG_CONF)
5354

55+
tools_install:
56+
install -D -m 0755 digimend-debug $(DIGIMEND_DEBUG)
57+
58+
tools_uninstall:
59+
rm -vf $(DIGIMEND_DEBUG)
60+
5461
udev_rules_install_files:
5562
install -D -m 0755 hid-rebind $(HID_REBIND)
5663
install -D -m 0644 udev.rules $(UDEV_RULES)
@@ -70,9 +77,9 @@ modules_uninstall:
7077
/lib/modules/*/extra/hid-uclogic.ko \
7178
/lib/modules/*/extra/hid-viewsonic.ko
7279

73-
install: modules modules_install depmod_conf_install dracut_conf_install udev_rules_install xorg_conf_install
80+
install: modules modules_install depmod_conf_install dracut_conf_install udev_rules_install xorg_conf_install tools_install
7481

75-
uninstall: xorg_conf_uninstall udev_rules_uninstall dracut_conf_uninstall depmod_conf_uninstall modules_uninstall
82+
uninstall: tools_uninstall xorg_conf_uninstall udev_rules_uninstall dracut_conf_uninstall depmod_conf_uninstall modules_uninstall
7683

7784
dkms_check:
7885
@if ! which dkms >/dev/null; then \
@@ -117,9 +124,9 @@ dkms_modules_uninstall: dkms_check
117124
} \
118125
done
119126

120-
dkms_install: dkms_modules_install depmod_conf_install dracut_conf_install udev_rules_install xorg_conf_install
127+
dkms_install: dkms_modules_install depmod_conf_install dracut_conf_install udev_rules_install xorg_conf_install tools_install
121128

122-
dkms_uninstall: xorg_conf_uninstall udev_rules_uninstall dracut_conf_uninstall depmod_conf_uninstall dkms_modules_uninstall
129+
dkms_uninstall: tools_uninstall xorg_conf_uninstall udev_rules_uninstall dracut_conf_uninstall depmod_conf_uninstall dkms_modules_uninstall
123130

124131
dist:
125132
git archive --format=tar.gz --prefix=$(PACKAGE)/ HEAD > $(PACKAGE).tar.gz

debian/rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ override_dh_auto_build:
3131
override_dh_auto_test:
3232

3333
override_dh_auto_install:
34-
$(MAKE) DESTDIR=$(CURDIR)/debian/digimend-dkms dkms_source_install udev_rules_install_files xorg_conf_install
34+
$(MAKE) DESTDIR=$(CURDIR)/debian/digimend-dkms dkms_source_install udev_rules_install_files xorg_conf_install tools_install
3535

3636
override_dh_dkms:
3737
dh_dkms -p digimend-dkms -V -- dkms.conf

digimend-debug

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
#
3+
# Enable/disable debug code in DIGImend kernel drivers.
4+
# Author: Nikolai Kondrashov <spbnick@gmail.com>
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 2 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
#
19+
20+
set -e -u -o pipefail
21+
22+
function usage() {
23+
local progname=`basename "$0"`
24+
echo "Usage: $progname STATUS"
25+
echo "Enable/disable debug code in DIGImend kernel drivers,"
26+
echo "making sure affected modules are loaded."
27+
echo ""
28+
echo "Arguments:"
29+
echo " STATUS 1/on/enable to enable, 0/off/disable to disable"
30+
echo ""
31+
}
32+
33+
declare -r CONTROL_FILE="/sys/kernel/debug/dynamic_debug/control"
34+
declare -r -a MODULE_LIST=("hid_uclogic")
35+
36+
if [ "$#" != 1 ]; then
37+
echo "Invalid number of arguments" >&2
38+
echo "" >&2
39+
usage >&2
40+
exit 1
41+
fi
42+
43+
case "${1,,}" in
44+
0|off|disable)
45+
op="-"
46+
;;
47+
1|on|enable)
48+
op="+"
49+
;;
50+
*)
51+
echo "Unknown status: $1" >&2
52+
echo "" >&2
53+
usage >&2
54+
exit 1
55+
;;
56+
esac
57+
58+
# Make sure modules are loaded, otherwise enabling will have no effect
59+
if ! modprobe -a "${MODULE_LIST[@]}"; then
60+
echo "Failed loading DIGImend modules." >&2
61+
echo "Make sure they're installed, and you're root or using sudo." >&2
62+
exit 1
63+
fi
64+
65+
if ! [ -r "$CONTROL_FILE" -a -w "$CONTROL_FILE" ]; then
66+
echo "Cannot access control file." >&2
67+
echo "Make sure you're root or using sudo." >&2
68+
exit 1
69+
fi
70+
71+
for MODULE in "${MODULE_LIST[@]}"; do
72+
echo "module ${MODULE} ${op}pmfl" > "$CONTROL_FILE"
73+
done

0 commit comments

Comments
 (0)