[3/3] istep: Run all sub-steps if minor is 0
diff mbox series

Message ID 20190704081133.7818-4-amitay@ozlabs.org
State New
Headers show
Series
  • Improve istep command usability
Related show

Checks

Context Check Description
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (6a4185ca278930693a6edb6d003267f74df3d2e8)

Commit Message

Amitay Isaacs July 4, 2019, 8:11 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 src/istep.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

Comments

Alistair Popple July 11, 2019, 5:41 a.m. UTC | #1
Better than my shell script :-)

Reviewed-by: Alistair Popple <alistair@popple.id.au>

On Thursday, 4 July 2019 6:11:33 PM AEST Amitay Isaacs wrote:
> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> ---
>  src/istep.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/src/istep.c b/src/istep.c
> index a141a31..a04c45d 100644
> --- a/src/istep.c
> +++ b/src/istep.c
> @@ -36,6 +36,7 @@ static int istep(uint32_t major, uint32_t minor)
>  {
>  	struct pdbg_target *sbefifo;
>  	int count = 0, i, rc;
> +	int first = minor, last = minor;
> 
>  	for_each_path_target_class("sbefifo", sbefifo) {
>  		if (pdbg_target_status(sbefifo) == PDBG_TARGET_ENABLED)
> @@ -56,6 +57,12 @@ static int istep(uint32_t major, uint32_t minor)
>  		if (istep_data[i].major != major)
>  			continue;
> 
> +		if (minor == 0) {
> +			first = istep_data[i].minor_first;
> +			last = istep_data[i].minor_last;
> +			break;
> +		}
> +
>  		if (minor < istep_data[i].minor_first ||
>  		    minor > istep_data[i].minor_last) {
>  			fprintf(stderr, "Istep %d minor should be %d to %d\n",
> @@ -66,10 +73,15 @@ static int istep(uint32_t major, uint32_t minor)
>  		}
>  	}
> 
> -	rc = sbe_istep(sbefifo, major, minor);
> -	if (!rc)
> -		count++;
> +	for (i = first; i <= last ; i++) {
> +		printf("Running istep %d.%d\n", major, i);
> +		rc = sbe_istep(sbefifo, major, i);
> +		if (rc)
> +			goto fail;
> +	}
> +	count++;
> 
> +fail:
>  	return count;
>  }
>  OPTCMD_DEFINE_CMD_WITH_ARGS(istep, istep, (DATA32, DATA32));

Patch
diff mbox series

diff --git a/src/istep.c b/src/istep.c
index a141a31..a04c45d 100644
--- a/src/istep.c
+++ b/src/istep.c
@@ -36,6 +36,7 @@  static int istep(uint32_t major, uint32_t minor)
 {
 	struct pdbg_target *sbefifo;
 	int count = 0, i, rc;
+	int first = minor, last = minor;
 
 	for_each_path_target_class("sbefifo", sbefifo) {
 		if (pdbg_target_status(sbefifo) == PDBG_TARGET_ENABLED)
@@ -56,6 +57,12 @@  static int istep(uint32_t major, uint32_t minor)
 		if (istep_data[i].major != major)
 			continue;
 
+		if (minor == 0) {
+			first = istep_data[i].minor_first;
+			last = istep_data[i].minor_last;
+			break;
+		}
+
 		if (minor < istep_data[i].minor_first ||
 		    minor > istep_data[i].minor_last) {
 			fprintf(stderr, "Istep %d minor should be %d to %d\n",
@@ -66,10 +73,15 @@  static int istep(uint32_t major, uint32_t minor)
 		}
 	}
 
-	rc = sbe_istep(sbefifo, major, minor);
-	if (!rc)
-		count++;
+	for (i = first; i <= last ; i++) {
+		printf("Running istep %d.%d\n", major, i);
+		rc = sbe_istep(sbefifo, major, i);
+		if (rc)
+			goto fail;
+	}
+	count++;
 
+fail:
 	return count;
 }
 OPTCMD_DEFINE_CMD_WITH_ARGS(istep, istep, (DATA32, DATA32));