Skip to contentSkip to conversation

msft: Add xlat_firmware_status for JEDEC Byte Addressable Energy Backed DSM

PATCH In review redhairer 2 participants 2 messages Jan 9, 2021 – Jan 13, 2021 libnvdimm: non-volatile memory device

lore
Share & tools
lore

redhairer

author
#0 lore raw

PATCH 1/1 msft: Add xlat_firmware_status for JEDEC Byte Addressable Energy Backed DSM

From: Redhairer Li <[email protected]>

Translate the status codes of the result of JEDEC Byte Addressable Energy Backed DSM to generic errno style error codes.

---
 ndctl/lib/msft.c | 22 ++++++++++++++++++++++
 ndctl/lib/msft.h |  6 ++++++
 2 files changed, 28 insertions(+)
ndctl/lib/msft.c +22 -0
index 145872c..3112799 100644
@@ -149,10 +149,32 @@ static unsigned int msft_cmd_smart_get_life_used(struct ndctl_cmd *cmd)
 	return 100 - CMD_MSFT_SMART(cmd)->nvm_lifetime;
 }
 
+static int msft_cmd_xlat_firmware_status(struct ndctl_cmd *cmd)
+{
+	unsigned int status;
+
+	status = cmd->get_firmware_status(cmd) & NDN_MSFT_STATUS_MASK;
+
+	/* Common statuses */
+	switch (status) {
+	case NDN_MSFT_STATUS_SUCCESS:
+		return 0;
+	case NDN_MSFT_STATUS_NOTSUPP:
+		return -EOPNOTSUPP;
+	case NDN_MSFT_STATUS_INVALPARM:
+		return -EINVAL;
+	case NDN_MSFT_STATUS_I2CERR:
+		return -EIO;
+	}
+
+	return -ENOMSG;
+}
+
 struct ndctl_dimm_ops * const msft_dimm_ops = &(struct ndctl_dimm_ops) {
 	.new_smart = msft_dimm_cmd_new_smart,
 	.smart_get_flags = msft_cmd_smart_get_flags,
 	.smart_get_health = msft_cmd_smart_get_health,
 	.smart_get_media_temperature = msft_cmd_smart_get_media_temperature,
 	.smart_get_life_used = msft_cmd_smart_get_life_used,
+	.xlat_firmware_status = msft_cmd_xlat_firmware_status,
 };
ndctl/lib/msft.h +6 -0
index 7cfd26f..978cc11 100644
@@ -50,4 +50,10 @@ struct ndn_pkg_msft {
 	union ndn_msft_cmd	u;
 } __attribute__((packed));
 
+#define NDN_MSFT_STATUS_MASK		0xffff
+#define NDN_MSFT_STATUS_SUCCESS	0
+#define NDN_MSFT_STATUS_NOTSUPP	1
+#define NDN_MSFT_STATUS_INVALPARM	2
+#define NDN_MSFT_STATUS_I2CERR		3
+
 #endif /* __NDCTL_MSFT_H__ */
Signature · 4 lines
2.27.0.windows.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Reviewed-by on v1 1/1
#1 lore raw

[ notify Vishal ]

Quoted 7 lines · redhairer

From: Redhairer Li <[email protected]>

Translate the status codes of the result of JEDEC Byte Addressable Energy Backed DSM to generic errno style error codes.

Looks good to me:

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]