From patchwork Tue Dec 11 14:00:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 27 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 63E9160B0C for ; Tue, 11 Dec 2018 14:59:49 +0100 (CET) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8E1F455A for ; Tue, 11 Dec 2018 14:59:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1544536788; bh=zir8mpyr7m2qO/0Wahve29zbxJ27Sekcs6lxWSsshp8=; h=From:To:Subject:Date:From; b=Owe98mTMcIVkwpA+GLC30uZ59q/oUrzHXsGETGbH94O0osu05RPANNwyQJb+S97VM rz/NgWFTj08WiAyizASfEbhoPTNDsnucqm+l8ZbB/lFfT9xpZEU2RoJKgjUvpBtjLW GVkdu2BIZc272PxE/3eaB7cd8VAu947DIGSSyguo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 11 Dec 2018 16:00:26 +0200 Message-Id: <20181211140028.25241-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] utils: ipu3: Abort when sensor or media device isn't found X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Dec 2018 13:59:49 -0000 Calling exit from a function only exits from the function, it doesn't abort the whole script. Propagate the errors to stop operation when the sensor or media device can't be found. Signed-off-by: Laurent Pinchart --- utils/ipu3/ipu3-capture.sh | 16 ++++++---------- utils/ipu3/ipu3-process.sh | 6 +++--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/utils/ipu3/ipu3-capture.sh b/utils/ipu3/ipu3-capture.sh index af189da3f8d8..ba6147b49799 100755 --- a/utils/ipu3/ipu3-capture.sh +++ b/utils/ipu3/ipu3-capture.sh @@ -20,7 +20,8 @@ find_sensor() { bus=$(grep "$sensor_name" /sys/class/video4linux/v4l-subdev*/name | cut -d ' ' -f 2) if [[ -z $bus ]]; then - return + echo "Sensor '$sensor_name' not found." >&2 + exit 1 fi echo "$sensor_name $bus" @@ -36,8 +37,8 @@ find_media_device() { done if [[ -z $mdev ]] ; then - echo "IPU3 media device not found." >&2 - exit 1 + echo "IPU3 media device not found." >&2 + exit 1 fi echo $mdev @@ -170,13 +171,8 @@ fi sensor_name=$1 -sensor=$(find_sensor $sensor_name) -if [[ -z $sensor ]] ; then - echo "Sensor '$sensor_name' not found." >&2 - exit 1 -fi - -mdev=$(find_media_device) +sensor=$(find_sensor $sensor_name) || exit +mdev=$(find_media_device) || exit mediactl="media-ctl -d $mdev" parse_pipeline $sensor diff --git a/utils/ipu3/ipu3-process.sh b/utils/ipu3/ipu3-process.sh index 6412aea4a3e7..78a7937fca70 100755 --- a/utils/ipu3/ipu3-process.sh +++ b/utils/ipu3/ipu3-process.sh @@ -23,8 +23,8 @@ find_media_device() { done if [[ -z $mdev ]] ; then - echo "IPU3 media device not found." >&2 - exit 1 + echo "IPU3 media device not found." >&2 + exit 1 fi echo $mdev @@ -173,7 +173,7 @@ fi out_size=${out_size:-$in_size} vf_size=${vf_size:-$in_size} -mdev=$(find_media_device) +mdev=$(find_media_device) || exit mediactl="media-ctl -d $mdev" echo "Using device $mdev"