Skip to contentSkip to conversation

accel-config: Skip printing error if cmd status register is not set

PATCH In review ramesh.thomas at intel.com 2 participants 4 messages Feb 23, 2021

lore
Share & tools
lore

ramesh.thomas at intel.com

#0 lore raw

PATCH 1/1 accel-config: Skip printing error if cmd status register is not set

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Library functions do their own checking and return errors without issuing commands to the hardware. Command status register retrieved from "cmd_status" sysfs attribute may not be set in such cases. Return NULL from function that retrieves the error status to indicate this.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
accfg/lib/libaccfg.c +1 -1
index ae862f8..7d5e9f4 100644
@@ -1469,7 +1469,7 @@ ACCFG_EXPORT const char * accfg_device_get_cmd_status_str(struct accfg_device *d
 	const char *stat_str;
 
 	status = accfg_device_get_cmd_status(device);
-	if (status < 0)
+	if (status <= 0)
 		return NULL;
 
 	if (status > ACCFG_CMD_STATUS_MAX)
Signature · 1 line
2.26.2
#1 lore raw
Quoted 17 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Library functions do their own checking and return errors without issuing commands to the hardware. Command status register retrieved from "cmd_status" sysfs attribute may not be set in such cases. Return NULL from function that retrieves the error status to indicate this.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
  accfg/lib/libaccfg.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
accfg/lib/libaccfg.c +0 -0
index ae862f8..7d5e9f4 100644

accfg/lib/libaccfg.c ACCFG_EXPORT const char * accfg_device_get_cmd_status_str(struct accfg_device *d · line 1472

Quoted 5 lines
accfg/lib/libaccfg.c +1 -1
@@ -1469,7 +1469,7 @@ ACCFG_EXPORT const char * accfg_device_get_cmd_status_str(struct accfg_device *d
  	const char *stat_str;
 
  	status = accfg_device_get_cmd_status(device);
-	if (status < 0)
+	if (status <= 0)

Would it be better to just return CMD_SUCCESS or something?

Quoted 3 lines
accfg/lib/libaccfg.c +0 -0
  		return NULL;
 
  	if (status > ACCFG_CMD_STATUS_MAX)
#2 lore raw
Quoted 21 lines · Dave Jiang
Quoted 19 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Library functions do their own checking and return errors without issuing commands to the hardware. Command status register retrieved from "cmd_status" sysfs attribute may not be set in such cases. Return NULL from function that retrieves the error status to indicate this.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
  accfg/lib/libaccfg.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
accfg/lib/libaccfg.c +0 -0
index ae862f8..7d5e9f4 100644
@@ -1469,7 +1469,7 @@ ACCFG_EXPORT const char * accfg_device_get_cmd_status_str(struct accfg_device *d
  	const char *stat_str;
 
Quoted 5 lines

accfg/lib/libaccfg.c ACCFG_EXPORT const char * accfg_device_get_cmd_status_str(struct accfg_device *d · line 1472

Quoted 3 lines
accfg/lib/libaccfg.c +1 -1
  	status = accfg_device_get_cmd_status(device);
-	if (status < 0)
+	if (status <= 0)

Would it be better to just return CMD_SUCCESS or something?

This function returns a string error message. The calling places assume that if the string is not NULL then it is an error. They don't display the message if it is NULL. I do like the idea of it returning 0 = Success. I can make this function return only the integer error code and create another function to return the string. That way the caller can decide whether or not to display the error message if it is "Success".

Quoted 6 lines
Quoted 5 lines
accfg/lib/libaccfg.c +0 -0
  		return NULL;
 
  	if (status > ACCFG_CMD_STATUS_MAX)
#3 lore raw
Quoted 25 lines · Ramesh
Quoted 20 lines · Dave Jiang
Quoted 19 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Library functions do their own checking and return errors without issuing commands to the hardware. Command status register retrieved from "cmd_status" sysfs attribute may not be set in such cases. Return NULL from function that retrieves the error status to indicate this.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
   accfg/lib/libaccfg.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
accfg/lib/libaccfg.c +0 -0
index ae862f8..7d5e9f4 100644
@@ -1469,7 +1469,7 @@ ACCFG_EXPORT const char * accfg_device_get_cmd_status_str(struct accfg_device *d
   const char *stat_str;
 
Quoted 4 lines

accfg/lib/libaccfg.c ACCFG_EXPORT const char * accfg_device_get_cmd_status_str(struct accfg_device *d · line 1472

Quoted 3 lines
accfg/lib/libaccfg.c +1 -1
   status = accfg_device_get_cmd_status(device);
-if (status < 0)
+if (status <= 0)

Would it be better to just return CMD_SUCCESS or something?

Quoted 6 lines

This function returns a string error message. The calling places assume that if the string is not NULL then it is an error. They don't display the message if it is NULL. I do like the idea of it returning 0 = Success. I can make this function return only the integer error code and create another function to return the string. That way the caller can decide whether or not to display the error message if it is "Success".

Sounds good!

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
accfg/lib/libaccfg.c +0 -0
   return NULL;
 
   if (status > ACCFG_CMD_STATUS_MAX)