Skip to content

Commit b368e36

Browse files
ikegami-tigaw
authored andcommitted
intel: enable intel-nvme.c build without json-c dependencies checking
Only build json print codes with CONFIG_JSONC build option instead. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 16ed7c5 commit b368e36

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

plugins/intel/intel-nvme.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct nvme_vu_id_ctrl_field { /* CDR MR5 */
7474
__u8 mic_fw[4];
7575
};
7676

77+
#ifdef CONFIG_JSONC
7778
static void json_intel_id_ctrl(struct nvme_vu_id_ctrl_field *id,
7879
char *health, char *bl, char *ww, char *mic_bl, char *mic_fw,
7980
struct json_object *root)
@@ -89,6 +90,9 @@ static void json_intel_id_ctrl(struct nvme_vu_id_ctrl_field *id,
8990
json_object_add_value_string(root, "mic_bl", mic_bl);
9091
json_object_add_value_string(root, "mic_fw", mic_fw);
9192
}
93+
#else /* CONFIG_JSONC */
94+
#define json_intel_id_ctrl(id, health, bl, ww, mic_bl, mic_fw, root)
95+
#endif /* CONFIG_JSONC */
9296

9397
static void intel_id_ctrl(__u8 *vs, struct json_object *root)
9498
{
@@ -134,6 +138,7 @@ static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *pl
134138
return __id_ctrl(argc, argv, cmd, plugin, intel_id_ctrl);
135139
}
136140

141+
#ifdef CONFIG_JSONC
137142
static void show_intel_smart_log_jsn(struct nvme_additional_smart_log *smart,
138143
unsigned int nsid, const char *devname)
139144
{
@@ -256,6 +261,9 @@ static void show_intel_smart_log_jsn(struct nvme_additional_smart_log *smart,
256261
json_print_object(root, NULL);
257262
json_free_object(root);
258263
}
264+
#else /* CONFIG_JSONC */
265+
#define show_intel_smart_log_jsn(smart, nsid, devname)
266+
#endif /* CONFIG_JSONC */
259267

260268
static char *id_to_key(__u8 id)
261269
{
@@ -336,7 +344,9 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
336344
"Get Intel vendor specific additional smart log (optionally, for the specified namespace), and show it.";
337345
const char *namespace = "(optional) desired namespace";
338346
const char *raw = "Dump output in binary format";
347+
#ifdef CONFIG_JSONC
339348
const char *json = "Dump output in json format";
349+
#endif /* CONFIG_JSONC */
340350

341351
struct nvme_additional_smart_log smart_log;
342352
struct nvme_dev *dev;
@@ -355,7 +365,9 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
355365
OPT_ARGS(opts) = {
356366
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
357367
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
368+
#ifdef CONFIG_JSONC
358369
OPT_FLAG("json", 'j', &cfg.json, json),
370+
#endif /* CONFIG_JSONC */
359371
OPT_END()
360372
};
361373

@@ -683,6 +695,7 @@ static int lat_stats_log_scale(int i)
683695
* "type" : "write" or "read",
684696
* "values" : {
685697
*/
698+
#ifdef CONFIG_JSONC
686699
static void lat_stats_make_json_root(
687700
struct json_object *root, struct json_object *bucket_list,
688701
int write)
@@ -814,6 +827,7 @@ static void json_lat_stats_4_0(struct intel_lat_stats *stats,
814827
json_print_object(root, NULL);
815828
json_free_object(root);
816829
}
830+
#endif /* CONFIG_JSONC */
817831

818832
static void show_lat_stats_3_0(struct intel_lat_stats *stats)
819833
{
@@ -844,6 +858,7 @@ static void show_lat_stats_4_0(struct intel_lat_stats *stats)
844858
}
845859
}
846860

861+
#ifdef CONFIG_JSONC
847862
static void json_lat_stats_v1000_0(struct optane_lat_stats *stats, int write)
848863
{
849864
int i;
@@ -892,6 +907,7 @@ static void json_lat_stats_v1000_0(struct optane_lat_stats *stats, int write)
892907
json_free_object(root);
893908

894909
}
910+
#endif /* CONFIG_JSONC */
895911

896912
static void show_lat_stats_v1000_0(struct optane_lat_stats *stats, int write)
897913
{
@@ -925,6 +941,7 @@ static void show_lat_stats_v1000_0(struct optane_lat_stats *stats, int write)
925941

926942
}
927943

944+
#ifdef CONFIG_JSONC
928945
static void json_lat_stats(int write)
929946
{
930947
switch (media_version[MEDIA_MAJOR_IDX]) {
@@ -965,6 +982,9 @@ static void json_lat_stats(int write)
965982
}
966983
printf("\n");
967984
}
985+
#else /* CONFIG_JSONC */
986+
#define json_lat_stats(write)
987+
#endif /* CONFIG_JSONC */
968988

969989
static void print_dash_separator(int count)
970990
{
@@ -1032,7 +1052,9 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct
10321052

10331053
const char *desc = "Get Intel Latency Statistics log and show it.";
10341054
const char *raw = "Dump output in binary format";
1055+
#ifdef CONFIG_JSONC
10351056
const char *json = "Dump output in json format";
1057+
#endif /* CONFIG_JSONC */
10361058
const char *write = "Get write statistics (read default)";
10371059

10381060
struct config {
@@ -1047,7 +1069,9 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct
10471069
OPT_ARGS(opts) = {
10481070
OPT_FLAG("write", 'w', &cfg.write, write),
10491071
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
1072+
#ifdef CONFIG_JSONC
10501073
OPT_FLAG("json", 'j', &cfg.json, json),
1074+
#endif /* CONFIG_JSONC */
10511075
OPT_END()
10521076
};
10531077

plugins/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
if json_c_dep.found()
44
sources += [
5-
'plugins/intel/intel-nvme.c',
65
'plugins/micron/micron-nvme.c',
76
'plugins/nbft/nbft-plugin.c',
87
'plugins/netapp/netapp-nvme.c',
@@ -26,6 +25,7 @@ sources += [
2625
'plugins/huawei/huawei-nvme.c',
2726
'plugins/innogrit/innogrit-nvme.c',
2827
'plugins/inspur/inspur-nvme.c',
28+
'plugins/intel/intel-nvme.c',
2929
'plugins/memblaze/memblaze-nvme.c',
3030
'plugins/shannon/shannon-nvme.c',
3131
'plugins/toshiba/toshiba-nvme.c',

0 commit comments

Comments
 (0)