[PATCH] tools:leds: add support for platform acpi led devices

Shuah Khan posted 1 patch 2 years, 8 months ago
tools/leds/get_led_device_info.sh | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
[PATCH] tools:leds: add support for platform acpi led devices
Posted by Shuah Khan 2 years, 8 months ago
Add support to parse platform acpi led devices. Use modalias
to extract product and driver name as defined in:

Documentation/ABI/testing/sysfs-bus-platform

Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
 tools/leds/get_led_device_info.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/leds/get_led_device_info.sh b/tools/leds/get_led_device_info.sh
index ccfa442db5fe..a085a8ffe7c9 100755
--- a/tools/leds/get_led_device_info.sh
+++ b/tools/leds/get_led_device_info.sh
@@ -72,8 +72,13 @@ elif [ $of_node_missing -eq 0 ]; then
 		manufacturer=`echo $compatible | awk -F, '{print $1}'`
 		product=`echo $compatible | awk -F, '{print $2}'`
 	fi
+elif [ "$bus" = "platform" ]; then
+	cd $led_cdev_path
+	product=`cat device/modalias | awk -F: '{print $2}'`
+	driver=`cat device/modalias | awk -F: '{print $2}'`
+	expected_devname=`cat device/modalias | awk -F: '{print $1}'`
 else
-	echo "Unknown device type."
+	echo "Unknown/unsupported device type." $bus
 	exit 1
 fi
 
@@ -112,7 +117,6 @@ printf "# LED class device name validation #\n"
 printf "####################################\n\n"
 
 led_name=`echo $led_cdev_path | sed s'/.*\///'`
-
 num_sections=`echo $led_name | awk -F: '{print NF}'`
 
 if [ $num_sections -eq 1 ]; then
@@ -161,6 +165,8 @@ if [ ! -z "$devicename" ]; then
 	if [ ! -z "$expected_devname" ]; then
 		if [ "$devicename" = "$expected_devname" ]; then
 			print_msg_ok "$S_DEV" "$devicename"
+		elif [ "$bus" = "platform" ]; then
+			print_msg_ok "$S_DEV" "$devicename"
 		else
 			print_msg_failed "$S_DEV" "$devicename" "Expected: $expected_devname"
 		fi
-- 
2.34.1