From b4729ce51687624531b0788a8fd4137e778d1ec3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E9=94=A6=E5=8D=8E?= Date: Fri, 18 Nov 2022 16:34:06 +0800 Subject: [PATCH] plugin/memblaze: use kernel base types instead own defined types 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 --- plugins/memblaze/memblaze-nvme.c | 22 +++++++++++----------- plugins/memblaze/memblaze-utils.h | 14 +++++--------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/plugins/memblaze/memblaze-nvme.c b/plugins/memblaze/memblaze-nvme.c index a9116aba..fb468419 100644 --- a/plugins/memblaze/memblaze-nvme.c +++ b/plugins/memblaze/memblaze-nvme.c @@ -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", diff --git a/plugins/memblaze/memblaze-utils.h b/plugins/memblaze/memblaze-utils.h index 3e5cd673..f64a1151 100644 --- a/plugins/memblaze/memblaze-utils.h +++ b/plugins/memblaze/memblaze-utils.h @@ -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__ - -- 2.50.1