[PATCH 3/3] vin-tests: Refactor mc_get_dev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Kieran Bingham <kieran.bingham+renesas@xxxxxxxxxxxxxxxx>

Rather that using shell parsing of each file when looking for a device
node, use a combination of grep and sed to identify the device.

This is a remarkable speed optimisation for this code segment.

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@xxxxxxxxxxxxxxxx>
---
 scripts/vin-tests.sh | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/scripts/vin-tests.sh b/scripts/vin-tests.sh
index 7c81aa51c1c5..2e6214bc95e6 100644
--- a/scripts/vin-tests.sh
+++ b/scripts/vin-tests.sh
@@ -99,17 +99,9 @@ mc_get_mdev() {
 }
 
 mc_get_dev() {
-    name=$1
-    mdev=$(mc_get_mdev)
-
-    for dev in  /sys/class/video4linux/*; do
-        if [[ "$(cat $dev/name)" == "$name" ]]; then
-            basename $dev
-            return 0
-        fi
-    done
-
-    error "Can't find device"
+    name="$1"
+    grep -l "$name" /sys/class/video4linux/video*/name | \
+	    sed 's#.*video4linux\(.*\)/name#/dev\1#g'
 }
 
 mc_log() {
-- 
2.7.4




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux