]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
plugin/memblaze: use kernel base types instead own defined types
author黄锦华 <jinhua.huang@memblaze.com>
Fri, 18 Nov 2022 08:34:06 +0000 (16:34 +0800)
committerDaniel Wagner <dwagner@suse.de>
Mon, 21 Nov 2022 09:02:00 +0000 (10:02 +0100)
The plugin uses already kernel based types in the data struct
definition. So there is no need to use self defined types.

Signed-off-by: jinhua.huang <jinhua.huang@memblaze.com>
plugins/memblaze/memblaze-nvme.c
plugins/memblaze/memblaze-utils.h

index a9116abaa9f29a4370e022ab3a64d66025d1f5dc..fb46841920e7dc588c09398eaa92ceba70dbc5b3 100644 (file)
@@ -107,7 +107,7 @@ static __u64 raw_2_u64(const __u8 *buf, size_t len)
     return le64_to_cpu(val);
 }
 
-static void get_memblaze_new_smart_info(struct nvme_p4_smart_log *smart, int index, u8 *nm_val, u8 *raw_val)
+static void get_memblaze_new_smart_info(struct nvme_p4_smart_log *smart, int index, __u8 *nm_val, __u8 *raw_val)
 {
     memcpy(nm_val, smart->itemArr[index].nmVal, NM_SIZE);
     memcpy(raw_val, smart->itemArr[index].rawVal, RAW_SIZE);
@@ -117,8 +117,8 @@ static void show_memblaze_smart_log_new(struct nvme_memblaze_smart_log *s,
     unsigned int nsid, const char *devname)
 {
     struct nvme_p4_smart_log *smart = (struct nvme_p4_smart_log *)s;
-    u8 *nm = malloc(NM_SIZE * sizeof(u8));
-    u8 *raw = malloc(RAW_SIZE * sizeof(u8));
+    __u8 *nm = malloc(NM_SIZE * sizeof(__u8));
+    __u8 *raw = malloc(RAW_SIZE * sizeof(__u8));
 
     if (!nm) {
         if (raw)
@@ -141,7 +141,7 @@ static void show_memblaze_smart_log_new(struct nvme_memblaze_smart_log *s,
 
     get_memblaze_new_smart_info(smart, RAISIN_SI_VD_WEARLEVELING_COUNT, nm, raw);
     printf("%-31s : %3d%%       %s%u%s%u%s%u\n", "wear_leveling", *nm,
-        "min: ", *(u16 *)raw, ", max: ", *(u16 *)(raw+2), ", avg: ", *(u16 *)(raw+4));
+        "min: ", *(__u16 *)raw, ", max: ", *(__u16 *)(raw+2), ", avg: ", *(__u16 *)(raw+4));
 
     get_memblaze_new_smart_info(smart, RAISIN_SI_VD_E2E_DECTECTION_COUNT, nm, raw);
     printf("%-31s: %3d%%       %"PRIu64"\n", "end_to_end_error_detection_count", *nm, int48_to_long(raw));
@@ -182,15 +182,15 @@ static void show_memblaze_smart_log_new(struct nvme_memblaze_smart_log *s,
 
     get_memblaze_new_smart_info(smart, RAISIN_SI_VD_TEMPT_SINCE_BORN, nm, raw);
     printf("%-32s: %3d%%       %s%u%s%u%s%u\n", "tempt_since_born",  *nm,
-        "max: ", *(u16 *)raw, ", min: ", *(u16 *)(raw+2), ", curr: ", *(u16 *)(raw+4));
+        "max: ", *(__u16 *)raw, ", min: ", *(__u16 *)(raw+2), ", curr: ", *(__u16 *)(raw+4));
 
     get_memblaze_new_smart_info(smart, RAISIN_SI_VD_POWER_CONSUMPTION, nm, raw);
     printf("%-32s: %3d%%       %s%u%s%u%s%u\n", "power_consumption",  *nm,
-        "max: ", *(u16 *)raw, ", min: ", *(u16 *)(raw+2), ", curr: ", *(u16 *)(raw+4));
+        "max: ", *(__u16 *)raw, ", min: ", *(__u16 *)(raw+2), ", curr: ", *(__u16 *)(raw+4));
 
     get_memblaze_new_smart_info(smart, RAISIN_SI_VD_TEMPT_SINCE_BOOTUP, nm, raw);
-    printf("%-32s: %3d%%       %s%u%s%u%s%u\n", "tempt_since_bootup",  *nm, "max: ", *(u16 *)raw,
-        ", min: ", *(u16 *)(raw+2), ", curr: ", *(u16 *)(raw+4));
+    printf("%-32s: %3d%%       %s%u%s%u%s%u\n", "tempt_since_bootup",  *nm, "max: ", *(__u16 *)raw,
+        ", min: ", *(__u16 *)(raw+2), ", curr: ", *(__u16 *)(raw+4));
 
     get_memblaze_new_smart_info(smart, RAISIN_SI_VD_READ_FAIL, nm, raw);
     printf("%-32s: %3d%%       %"PRIu64"\n", "read_fail_count", *nm, int48_to_long(raw));
@@ -305,8 +305,8 @@ static void show_memblaze_smart_log_old(struct nvme_memblaze_smart_log *smart,
 
      if ( IS_PAPAYA(fw_ver_local) ) {
         struct nvme_p4_smart_log *s = (struct nvme_p4_smart_log *)smart;
-        u8 *nm = malloc(NM_SIZE * sizeof(u8));
-        u8 *raw = malloc(RAW_SIZE * sizeof(u8));
+        __u8 *nm = malloc(NM_SIZE * sizeof(__u8));
+        __u8 *raw = malloc(RAW_SIZE * sizeof(__u8));
 
        if (!nm) {
             if (raw)
@@ -327,7 +327,7 @@ static void show_memblaze_smart_log_old(struct nvme_memblaze_smart_log *smart,
 
         get_memblaze_new_smart_info(s, WEARLEVELING_COUNT, nm, raw);
         printf("%-31s                                 : %3d%%       %s%u%s%u%s%u\n",
-                       "wear_leveling", *nm, "min: ", *(u16 *)raw, ", max: ", *(u16 *)(raw+2), ", avg: ", *(u16 *)(raw+4));
+                       "wear_leveling", *nm, "min: ", *(__u16 *)raw, ", max: ", *(__u16 *)(raw+2), ", avg: ", *(__u16 *)(raw+4));
 
         get_memblaze_new_smart_info(s, TOTAL_WRITE, nm, raw);
         printf("%-32s                                : %3d%%       %"PRIu64"\n",
index 3e5cd67307d6ff4c564318b0e2aafa0c9409c61d..f64a11515644f4585cad5cca73e5d631086e95b2 100644 (file)
@@ -9,9 +9,6 @@
 #define NM_SIZE                 2
 #define RAW_SIZE                7
 
-typedef unsigned char           u8;
-typedef unsigned short          u16;
-
 // Intel Format & new format
 /* Raisin Additional smart external ID */
 #define RAISIN_SI_VD_PROGRAM_FAIL_ID                        0xAB
@@ -136,18 +133,18 @@ struct nvme_memblaze_smart_log_item {
 
 struct nvme_memblaze_smart_log {
     struct nvme_memblaze_smart_log_item items[NR_SMART_ITEMS];
-    u8 resv[SMART_INFO_OLD_SIZE - sizeof(struct nvme_memblaze_smart_log_item) * NR_SMART_ITEMS];
+    __u8 resv[SMART_INFO_OLD_SIZE - sizeof(struct nvme_memblaze_smart_log_item) * NR_SMART_ITEMS];
 };
 
 // Intel Format & new format
 struct nvme_p4_smart_log_item
 {
     /* Item identifier */
-    u8 id[ID_SIZE];
+    __u8 id[ID_SIZE];
     /* Normalized value or percentage. In the range from 0 to 100. */
-    u8 nmVal[NM_SIZE];
+    __u8 nmVal[NM_SIZE];
     /* raw value */
-    u8 rawVal[RAW_SIZE];
+    __u8 rawVal[RAW_SIZE];
 };
 
 struct nvme_p4_smart_log
@@ -159,7 +156,7 @@ struct nvme_p4_smart_log
      * because micron's getlogpage request,the size of many commands have changed to 4k.
      * request size > user malloc size,casuing parameters that are closed in momery are dirty.
      */
-    u8 resv[SMART_INFO_NEW_SIZE - sizeof(struct nvme_p4_smart_log_item) * NR_SMART_ITEMS];
+    __u8 resv[SMART_INFO_NEW_SIZE - sizeof(struct nvme_p4_smart_log_item) * NR_SMART_ITEMS];
 };
 
 // base
@@ -222,4 +219,3 @@ struct nvme_p4_smart_log
     }
 
 #endif // __MEMBLAZE_UTILS_H__
-