mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-20 19:41:47 +00:00
Add the find-driver script
The script is meant to identify the driver and kernel module responsible for exporting a given hardware monitoring chip. Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
This commit is contained in:
1 parent
35d2443488
commit
c755805cef
2 files changed
+113
No files matched your search
@@ -0,0 +1,25 @@
|
|||||||
|
This directory contains tools which may help with debugging lm_sensors.
|
||||||
|
|
||||||
|
find-driver
|
||||||
|
===========
|
||||||
|
If the 'sensors' program does not report useful values for certain hardware
|
||||||
|
monitoring inputs, the problem in most cases is not in lm_sensors. lm_sensors
|
||||||
|
only reads values exported by the Linux kernel. Finding the driver responsible
|
||||||
|
for exporting the particular hardware monitoring chip may help to diagnose
|
||||||
|
the problem further. It is possible that there is a bug in the driver, however
|
||||||
|
it is even more likely that the input is simply not used on your board.
|
||||||
|
Nonetheless, identifying the driver may help you identify the piece of hardware
|
||||||
|
that reports the bogus value.
|
||||||
|
|
||||||
|
This script finds the driver and kernel module responsible for exporting
|
||||||
|
a hardware monitoring chip in sysfs. It should be given the chip name (as
|
||||||
|
reported by the 'sensors' program) as argument. For example:
|
||||||
|
|
||||||
|
$ sensors
|
||||||
|
thinkpad-isa-0000
|
||||||
|
Adapter: ISA adapter
|
||||||
|
fan1: 0 RPM
|
||||||
|
|
||||||
|
$ ./find-driver thinkpad-isa-0000
|
||||||
|
Driver: thinkpad_hwmon
|
||||||
|
Module: thinkpad_acpi
|
||||||
Executable
+88
@@ -0,0 +1,88 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# find-driver - find the driver exporting a chip as reported by 'sensors'
|
||||||
|
# Copyright (C) 2018 Ondřej Lysoněk
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
shopt -s nullglob
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
echo "Usage: $0 <chip name>" >&2
|
||||||
|
echo >&2
|
||||||
|
echo 'Chip name is a string in the format <chip>-<bus>-<address>' >&2
|
||||||
|
echo 'as reported by the "sensors" program. For example the chip' >&2
|
||||||
|
echo 'name can be "coretemp-isa-0000" or "acpitz-virtual-0".' >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_chip() {
|
||||||
|
echo "$1" | sed -r -e 's/^(.+)-[^-]+-[^-]+$/\1/'
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$#" -lt 1 ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
ARG=$1; shift
|
||||||
|
if [ "$ARG" = "-h" ] || [ "$ARG" = "--help" ]; then
|
||||||
|
usage
|
||||||
|
test "$#" -eq 0
|
||||||
|
exit
|
||||||
|
elif [ "$ARG" = "-d" ] || [ "$ARG" = "--debug" ]; then
|
||||||
|
test "$#" -eq 1 || { usage; exit 1; }
|
||||||
|
set -x
|
||||||
|
CHIP=$(get_chip "$1")
|
||||||
|
else
|
||||||
|
test "$#" -eq 0 || { usage; exit 1; }
|
||||||
|
CHIP=$(get_chip "$ARG")
|
||||||
|
fi
|
||||||
|
|
||||||
|
DEVICE=
|
||||||
|
for i in /sys/class/hwmon/hwmon*; do
|
||||||
|
NAME=
|
||||||
|
if [ -f "$i/name" ]; then
|
||||||
|
NAME=$(cat "$i/name")
|
||||||
|
elif [ -L "$i/device" ]; then
|
||||||
|
TARGET=$(readlink -f "$i/device")
|
||||||
|
if [ -f "$TARGET/name" ]; then
|
||||||
|
NAME=$(cat "$TARGET/name")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "$NAME" = "$CHIP" ]; then
|
||||||
|
DEVICE="$i"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
test -n "$DEVICE" || { echo 'Chip not found.' >&2; exit 1; }
|
||||||
|
|
||||||
|
DRIVER=unknown
|
||||||
|
MODULE=unknown
|
||||||
|
while true; do
|
||||||
|
if [ -L "$DEVICE/driver" ]; then
|
||||||
|
DRIVER_DIR=$(readlink -f "$DEVICE/driver")
|
||||||
|
DRIVER=$(basename "$DRIVER_DIR")
|
||||||
|
if [ -L "$DRIVER_DIR/module" ]; then
|
||||||
|
MODULE=$(basename $(readlink "$DRIVER_DIR/module"))
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
elif [ -L "$DEVICE/device" ]; then
|
||||||
|
DEVICE=$(readlink -f "$DEVICE/device")
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Driver: $DRIVER"
|
||||||
|
echo "Module: $MODULE"
|
||||||
Reference in new issue
Block a user