tools/leds/get_led_device_info.sh
Source file repositories/reference/linux-study-clean/tools/leds/get_led_device_info.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/leds/get_led_device_info.sh- Extension
.sh- Size
- 5841 bytes
- Lines
- 202
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
while (i <= NF - 2) { \
printf $i"/"; \
i++; \
}; \
}')
led_defs_path=$linux_top/$led_common_defs_path
elif [ $num_args -eq 2 ]; then
led_defs_path=`realpath $2`
else
echo "Usage: get_led_device_info.sh LED_CDEV_PATH [LED_COMMON_DEFS_PATH]"
exit 1
fi
if [ ! -f $led_defs_path ]; then
echo "$led_defs_path doesn't exist"
exit 1
fi
led_cdev_path=`echo $1 | sed s'/\/$//'`
ls "$led_cdev_path/brightness" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Device \"$led_cdev_path\" does not exist."
exit 1
fi
bus=`readlink $led_cdev_path/device/subsystem | sed s'/.*\///'`
usb_subdev=`readlink $led_cdev_path | grep usb | sed s'/\(.*usb[0-9]*\/[0-9]*-[0-9]*\)\/.*/\1/'`
ls "$led_cdev_path/device/of_node/compatible" > /dev/null 2>&1
of_node_missing=$?
if [ "$bus" = "input" ]; then
input_node=`readlink $led_cdev_path/device | sed s'/.*\///'`
if [ ! -z "$usb_subdev" ]; then
bus="usb"
fi
fi
if [ "$bus" = "usb" ]; then
usb_interface=`readlink $led_cdev_path | sed s'/.*\(usb[0-9]*\)/\1/' | cut -d\/ -f3`
cd $led_cdev_path/../$usb_subdev
driver=`readlink $usb_interface/driver | sed s'/.*\///'`
if [ -d "$usb_interface/ieee80211" ]; then
wifi_phy=`ls -l $usb_interface/ieee80211 | grep phy | awk '{print $9}'`
fi
idVendor=`cat idVendor`
idProduct=`cat idProduct`
manufacturer=`cat manufacturer`
product=`cat product`
elif [ "$bus" = "input" ]; then
cd $led_cdev_path
product=`cat device/name`
driver=`cat device/device/driver/description`
elif [ $of_node_missing -eq 0 ]; then
cd $led_cdev_path
compatible=`cat device/of_node/compatible`
if [ "$compatible" = "gpio-leds" ]; then
driver="leds-gpio"
elif [ "$compatible" = "pwm-leds" ]; then
driver="leds-pwm"
else
manufacturer=`echo $compatible | awk -F, '{print $1}'`
product=`echo $compatible | awk -F, '{print $2}'`
fi
else
echo "Unknown device type."
exit 1
fi
printf "\n#####################################\n"
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.