All of lore.kernel.org
 help / color / mirror / Atom feed
* [Accel-config] [PATCH v1 4/7] accel-config: Refactor handling printing of device cmd status
@ 2021-03-02 17:44 ramesh.thomas
  0 siblings, 0 replies; only message in thread
From: ramesh.thomas @ 2021-03-02 17:44 UTC (permalink / raw)
  To: accel-config

[-- Attachment #1: Type: text/plain, Size: 1801 bytes --]

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-02 17:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02 17:44 [Accel-config] [PATCH v1 4/7] accel-config: Refactor handling printing of device cmd status ramesh.thomas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.