@@ -87,6 +87,22 @@ NDCTL_EXPORT double ndctl_decode_smart_temperature(unsigned int temp)
return t;
}
+NDCTL_EXPORT unsigned int ndctl_encode_smart_temperature(double temp)
+{
+ bool negative = false;
+ unsigned int t;
+
+ if (temp < 0) {
+ negative = true;
+ temp *= -1;
+ }
+ t = temp;
+ t *= 16;
+ if (negative)
+ t |= (1 << 15);
+ return t;
+}
+
struct ndctl_ctx;
/**
@@ -322,6 +322,7 @@ global:
ndctl_cmd_smart_threshold_set_ctrl_temperature;
ndctl_cmd_smart_threshold_set_spares;
ndctl_decode_smart_temperature;
+ ndctl_encode_smart_temperature;
ndctl_dimm_cmd_new_smart_inject;
ndctl_cmd_smart_inject_media_temperature;
ndctl_cmd_smart_inject_spares;
@@ -76,6 +76,7 @@ size_t ndctl_min_namespace_size(void);
size_t ndctl_sizeof_namespace_index(void);
size_t ndctl_sizeof_namespace_label(void);
double ndctl_decode_smart_temperature(unsigned int temp);
+unsigned int ndctl_encode_smart_temperature(double temp);
struct ndctl_ctx;
struct ndctl_ctx *ndctl_ref(struct ndctl_ctx *ctx);
This provides for encoding of a human-readable temperature value into the format expected by the smart command Cc: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> --- ndctl/lib/libndctl.c | 16 ++++++++++++++++ ndctl/lib/libndctl.sym | 1 + ndctl/libndctl.h | 1 + 3 files changed, 18 insertions(+)