Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bug of incorrect use of DEVICE variable in ethernet #172

Open
wants to merge 1 commit into
base: lmt-upstream
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 41 additions & 43 deletions usr/share/laptop-mode-tools/modules/ethernet
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,6 @@ if [ x$CONTROL_ETHERNET = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_ETHE
IPTOOL=/bin/false
fi


# Determine speed capability of physical device
speed=`$MIITOOL -v $DEVICE 2>/dev/null | grep capabilities | tr ' ' '\n' |\
sort -n | sed -ne '/^1.*/p' | cut -d "b" -f1`
if [ -z "$speed" ]; then
speed=0;
fi
max_s=0;
min_s=100000;
for s in $speed;
do
if [ $s -gt $max_s ]; then
max_s=$s
fi
if [ $s -lt $min_s ]; then
min_s=$s
fi
done
MAX_SPEED=$max_s;

case "$THROTTLE_SPEED" in
"slowest")
THROTTLE_SPEED=$min_s
;;
"fastest")
THROTTLE_SPEED=$max_s
;;
esac

# Carrier detection
if $IPTOOL link show $DEVICE | grep -q NO-CARRIER; then
carrier="false";
else
carrier="true";
fi


# What state we are in
if [ $ON_AC -eq 1 ]; then
if [ "$ACTIVATE" -eq 1 ]; then
Expand All @@ -76,12 +39,6 @@ if [ x$CONTROL_ETHERNET = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_ETHE
THROTTLE_ETHERNET="$NOLM_AC_THROTTLE_ETHERNET"
fi

# One off a case.
# So that when back on AC, we can resume the speed back to MAX.
if [ x$THROTTLE_ETHERNET = x0 ]; then
THROTTLE_SPEED=$MAX_SPEED;
fi

if [ x$DISABLE_ETHERNET_ON_BATTERY = x1 ]; then
# We are ON_AC and Disable feature is requested
# So we might be required to re-enable the device.
Expand All @@ -104,6 +61,47 @@ if [ x$CONTROL_ETHERNET = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_ETHE
for DEVICE in $ETHERNET_DEVICES ; do
log "VERBOSE" "ethernet: $DEVICE"

# Determine speed capability of physical device
speed=`$MIITOOL -v $DEVICE 2>/dev/null | grep capabilities | tr ' ' '\n' |\
sort -n | sed -ne '/^1.*/p' | cut -d "b" -f1`
if [ -z "$speed" ]; then
speed=0;
fi
max_s=0;
min_s=100000;
for s in $speed;
do
if [ $s -gt $max_s ]; then
max_s=$s
fi
if [ $s -lt $min_s ]; then
min_s=$s
fi
done
MAX_SPEED=$max_s;

case "$THROTTLE_SPEED" in
"slowest")
THROTTLE_SPEED=$min_s
;;
"fastest")
THROTTLE_SPEED=$max_s
;;
esac

# Carrier detection
if $IPTOOL link show $DEVICE | grep -q NO-CARRIER; then
carrier="false";
else
carrier="true";
fi

# One off a case.
# So that when back on AC, we can resume the speed back to MAX.
if [ $ON_AC -eq 1 -a x$THROTTLE_ETHERNET = x0 ]; then
THROTTLE_SPEED=$MAX_SPEED;
fi

# Wakeup-on-LAN handling
if [ x$DISABLE_WAKEUP_ON_LAN = x1 ] ; then
ret=`$ETHTOOL -s $DEVICE wol d 2>&1`
Expand Down