Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: laptop-mode-tools_1.52/usr/share/laptop-mode-tools/modules/usb-autosuspend

Issue 4853002: laptop-mode accepts lists of devices and modules (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/laptop-mode-tools.git
Patch Set: Added more comments, removed echo, added rule file Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « laptop-mode-tools_1.52/usr/sbin/laptop_mode ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #! /bin/sh 1 #! /bin/sh
2 # 2 #
3 # Laptop mode tools module: usb-autosuspend. 3 # Laptop mode tools module: usb-autosuspend.
4 # 4 #
5 5
6 blacklisted() { 6 blacklisted() {
7 for usbid in $AUTOSUSPEND_USBID_BLACKLIST; do 7 for usbid in $AUTOSUSPEND_USBID_BLACKLIST; do
8 if ! echo $usbid | grep -q ':'; then 8 if ! echo $usbid | grep -q ':'; then
9 log "MSG" "WARNING: Invalid entry \"$usbid\" in AUTOSUSP END_USBID_BLACKLIST." 9 log "MSG" "WARNING: Invalid entry \"$usbid\" in AUTOSUSP END_USBID_BLACKLIST."
10 fi 10 fi
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 if [ $ON_AC -eq 1 ]; then 43 if [ $ON_AC -eq 1 ]; then
44 if [ "$ACTIVATE" -eq 1 ]; then 44 if [ "$ACTIVATE" -eq 1 ]; then
45 SUSPEND_USB_DEVICES="$LM_AC_SUSPEND_USB" 45 SUSPEND_USB_DEVICES="$LM_AC_SUSPEND_USB"
46 else 46 else
47 SUSPEND_USB_DEVICES="$NOLM_AC_SUSPEND_USB" 47 SUSPEND_USB_DEVICES="$NOLM_AC_SUSPEND_USB"
48 fi 48 fi
49 else 49 else
50 SUSPEND_USB_DEVICES="$BATT_SUSPEND_USB" 50 SUSPEND_USB_DEVICES="$BATT_SUSPEND_USB"
51 fi 51 fi
52 52
53 if [ -d /sys/bus/usb/devices ]; then
54 if [ "$DEVICES" != "" ]; then
55 # If a list of devices has been provided, operate on only the
56 # listed USB devices.
57 DEVICE_LIST=""
58 for DEVICE in $DEVICES; do
59 DEVICE_LIST="$DEVICE_LIST $DEVICE"
60 done
61 else
62 # If no list was provided, operate on all USB devices
63 DEVICE_LIST=/sys/bus/usb/devices/*
64 fi
65 else
66 # This will rarely happen.
67 log "VERBOSE" "There are no USB devices."
68 fi
69
53 if [ x$SUSPEND_USB_DEVICES = x1 ]; then 70 if [ x$SUSPEND_USB_DEVICES = x1 ]; then
54 if [ -f /sys/module/usbcore/parameters/autosuspend ]; then 71 if [ -f /sys/module/usbcore/parameters/autosuspend ]; then
55 echo $AUTOSUSPEND_TIMEOUT > /sys/module/usbcore/parameters/autosus pend 72 echo $AUTOSUSPEND_TIMEOUT > /sys/module/usbcore/parameters/autosus pend
56 log "VERBOSE" "Enabling autosuspend mode for USBCORE Controller, w ith timeout $AUTOSUSPEND_TIMEOUT." 73 log "VERBOSE" "Enabling autosuspend mode for USBCORE Controller, w ith timeout $AUTOSUSPEND_TIMEOUT."
57 else 74 else
58 log "VERBOSE" "Not enabling autosuspend mode for USBCORE Controlle r. Not Supported" 75 log "VERBOSE" "Not enabling autosuspend mode for USBCORE Controlle r. Not Supported"
59 fi 76 fi
60 » if [ -d /sys/bus/usb/devices ]; then 77 » if [ "$DEVICE_LIST" != "" ]; then
61 » for usb_device in /sys/bus/usb/devices/*; 78 » for usb_device in $DEVICE_LIST;
62 do 79 do
63 usb_device=`basename $usb_device`; 80 usb_device=`basename $usb_device`;
64 if ! blacklisted /sys/bus/usb/devices/$usb_device; then 81 if ! blacklisted /sys/bus/usb/devices/$usb_device; then
65 if ! blacklisted_by_type /sys/bus/usb/devices/$usb_devic e; then 82 if ! blacklisted_by_type /sys/bus/usb/devices/$usb_devic e; then
66 if [ -f /sys/bus/usb/devices/$usb_device/power/autosus pend ]; then 83 if [ -f /sys/bus/usb/devices/$usb_device/power/autosus pend ]; then
67 echo $AUTOSUSPEND_TIMEOUT > /sys/bus/usb/devic es/$usb_device/power/autosuspend; 84 echo $AUTOSUSPEND_TIMEOUT > /sys/bus/usb/devic es/$usb_device/power/autosuspend;
68 log "VERBOSE" "Enabling auto suspend mode for usb device $usb_device." 85 log "VERBOSE" "Enabling auto suspend mode for usb device $usb_device."
69 else 86 else
70 log "VERBOSE" "Not enabling auto suspend mode for usb device $usb_device" 87 log "VERBOSE" "Not enabling auto suspend mode for usb device $usb_device"
71 fi 88 fi
72 89
73 if [ -f /sys/bus/usb/devices/$usb_device/power/level ] ; then 90 if [ -f /sys/bus/usb/devices/$usb_device/power/level ] ; then
74 echo "auto" > /sys/bus/usb/devices/$usb_device /power/level; 91 echo "auto" > /sys/bus/usb/devices/$usb_device /power/level;
75 log "VERBOSE" "Enabling auto power level for u sb device $usb_device." 92 log "VERBOSE" "Enabling auto power level for u sb device $usb_device."
76 else 93 else
77 log "VERBOSE" "Not enabling auto power level f or usb device $usb_device" 94 log "VERBOSE" "Not enabling auto power level f or usb device $usb_device"
78 fi 95 fi
79 else 96 else
80 log "VERBOSE" "Device $usb_device has blacklisted driv er type, skipping auto suspend." 97 log "VERBOSE" "Device $usb_device has blacklisted driv er type, skipping auto suspend."
81 fi 98 fi
82 else 99 else
83 log "VERBOSE" "USB device $usbid is in the autosuspend blacklist." 100 log "VERBOSE" "USB device $usbid is in the autosuspend blacklist."
84 fi 101 fi
85 done 102 done
86 else
87 # This will rarely happen.
88 log "VERBOSE" "There are no USB devices."
89 fi 103 fi
90 else 104 else
91 AUTOSUSPEND_TIMEOUT=0 105 AUTOSUSPEND_TIMEOUT=0
92 if [ -f /sys/module/usbcore/parameters/autosuspend ]; then 106 if [ -f /sys/module/usbcore/parameters/autosuspend ]; then
93 echo $AUTOSUSPEND_TIMEOUT > /sys/module/usbcore/parameters/autosus pend 107 echo $AUTOSUSPEND_TIMEOUT > /sys/module/usbcore/parameters/autosus pend
94 log "VERBOSE" "Disabling autosuspend mode for USBCORE Controller, with timeout $AUTOSUSPEND_TIMEOUT." 108 log "VERBOSE" "Disabling autosuspend mode for USBCORE Controller, with timeout $AUTOSUSPEND_TIMEOUT."
95 else 109 else
96 log "VERBOSE" "Not disabling autosuspend mode for USBCORE Controll er. Not Supported" 110 log "VERBOSE" "Not disabling autosuspend mode for USBCORE Controll er. Not Supported"
97 fi 111 fi
98 » if [ -d /sys/bus/usb/devices ]; then 112 » if [ "$DEVICE_LIST" != "" ]; then
99 » for usb_device in /sys/bus/usb/devices/*; 113 » for usb_device in $DEVICE_LIST;
100 do 114 do
101 usb_device=`basename $usb_device`; 115 usb_device=`basename $usb_device`;
102 if [ -f /sys/bus/usb/devices/$usb_device/power/autosuspend ]; then 116 if [ -f /sys/bus/usb/devices/$usb_device/power/autosuspend ]; then
103 echo $AUTOSUSPEND_TIMEOUT > /sys/bus/usb/devices/$usb_devi ce/power/autosuspend; 117 echo $AUTOSUSPEND_TIMEOUT > /sys/bus/usb/devices/$usb_devi ce/power/autosuspend;
104 log "VERBOSE" "Disabling auto suspend mode for usb device $usb_device." 118 log "VERBOSE" "Disabling auto suspend mode for usb device $usb_device."
105 else 119 else
106 log "VERBOSE" "Not disabling auto suspend mode for usb dev ice $usb_device" 120 log "VERBOSE" "Not disabling auto suspend mode for usb dev ice $usb_device"
107 fi 121 fi
108 122
109 if [ -f /sys/bus/usb/devices/$usb_device/power/level ]; then 123 if [ -f /sys/bus/usb/devices/$usb_device/power/level ]; then
110 echo "on" > /sys/bus/usb/devices/$usb_device/power/level; 124 echo "on" > /sys/bus/usb/devices/$usb_device/power/level;
111 log "VERBOSE" "Enabling ON power level for usb device $usb _device." 125 log "VERBOSE" "Enabling ON power level for usb device $usb _device."
112 else 126 else
113 log "VERBOSE" "Not enabling ON power level for usb device $usb_device" 127 log "VERBOSE" "Not enabling ON power level for usb device $usb_device"
114 fi 128 fi
115 done 129 done
116 else
117 # This will rarely happen.
118 log "VERBOSE" "There are no USB devices."
119 fi 130 fi
120 fi 131 fi
121 else 132 else
122 log "VERBOSE" "USB autosuspend is disabled." 133 log "VERBOSE" "USB autosuspend is disabled."
123 fi 134 fi
124 135
OLDNEW
« no previous file with comments | « laptop-mode-tools_1.52/usr/sbin/laptop_mode ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698