[Accel-config] [PATCH v1 4/7] accel-config: Refactor handling printing of device cmd status
ramesh.thomas at intel.com
| Newsgroups | dev.linux.lists.accel-config |
|---|---|
| Message-ID | <[email protected]> |
From: Ramesh Thomas <ramesh.thomas(a)intel.com>
Create a separate function for common code printing device command
status.
Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
accfg/enable.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/accfg/enable.c b/accfg/enable.c
index 34328ca..d3968e4 100644
--- a/accfg/enable.c
+++ b/accfg/enable.c
@@ -81,6 +81,15 @@ static int dev_action_switch(struct accfg_device *device,
}
}
+static void print_device_cmd_status(struct accfg_device *device)
+{
+ const char *status;
+
+ status = accfg_device_get_cmd_status_str(device);
+ if (status)
+ fprintf(stderr, "device command status: %s\n", status);
+}
+
static int device_action(int argc, const char **argv, const char *usage,
const struct option *options, enum dev_action action,
struct accfg_ctx *ctx)
@@ -134,14 +143,10 @@ static int device_action(int argc, const char **argv, const char *usage,
else
fail++;
} else if (!fail) {
- const char *status;
-
fail_reason = rc;
fprintf(stderr, "failed in %s\n", argv[i]);
- status = accfg_device_get_cmd_status_str(device);
- if (status)
- fprintf(stderr, "device cmd err: %s.\n", status);
+ print_device_cmd_status(device);
}
}
@@ -297,13 +302,10 @@ static int wq_action(int argc, const char **argv, const char *usage,
else
fail++;
} else if (!fail) {
- const char *status;
-
fail_reason = rc;
fprintf(stderr, "failed in %s\n", wq_name);
- status = accfg_device_get_cmd_status_str(device);
- if (status)
- fprintf(stderr, "device cmd err: %s.\n", status);
+
+ print_device_cmd_status(device);
}
}
}
--
2.26.2