Linux Renesas SOC kernel development
 help / color / mirror / Atom feed
From: Kieran Bingham <kbingham@kernel.org>
To: niklas.soderlund@ragnatech.se
Cc: linux-renesas-soc@vger.kernel.org,
	kieran.bingham@ideasonboard.com,
	Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Subject: [PATCH 3/3] vin-tests: Refactor mc_get_dev
Date: Wed, 15 Nov 2017 14:38:31 +0000	[thread overview]
Message-ID: <1510756711-6488-4-git-send-email-kbingham@kernel.org> (raw)
In-Reply-To: <1510756711-6488-1-git-send-email-kbingham@kernel.org>

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

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@ideasonboard.com>
---
 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

  parent reply	other threads:[~2017-11-15 14:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-15 14:38 [PATCH 0/3] [VIN-Tests] minor updates Kieran Bingham
2017-11-15 14:38 ` [PATCH 1/3] tools: 8camera-status: Fix write failure mis-allocations Kieran Bingham
2017-11-15 16:31   ` Niklas Söderlund
2017-11-15 14:38 ` [PATCH 2/3] tools: 8camera-status: Expand to 9 cameras Kieran Bingham
2017-11-15 16:31   ` Niklas Söderlund
2017-11-15 14:38 ` Kieran Bingham [this message]
2017-11-15 16:51   ` [PATCH 3/3] vin-tests: Refactor mc_get_dev Niklas Söderlund
2017-11-16 10:54     ` Kieran Bingham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1510756711-6488-4-git-send-email-kbingham@kernel.org \
    --to=kbingham@kernel.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund@ragnatech.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox