Skip to content

Commit 7f0b2a7

Browse files
ikegami-tigaw
authored andcommitted
feat: add FEAT_ARGS to use instead of NVME_ARGS
Includes save and sel options for all nvme feat plugin commands. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 57ea893 commit 7f0b2a7

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

plugins/feat/feat-nvme.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ struct perfc_config {
1919
char *paid;
2020
__u16 attrl;
2121
char *vs_data;
22-
bool save;
2322
__u8 sel;
2423
};
2524

@@ -119,24 +118,21 @@ static int feat_power_mgmt(int argc, char **argv, struct command *cmd, struct pl
119118
struct config {
120119
__u8 ps;
121120
__u8 wh;
122-
bool save;
123121
__u8 sel;
124122
};
125123

126124
struct config cfg = { 0 };
127125

128-
NVME_ARGS(opts,
126+
FEAT_ARGS(opts,
129127
OPT_BYTE("ps", 'p', &cfg.ps, ps),
130-
OPT_BYTE("wh", 'w', &cfg.wh, wh),
131-
OPT_FLAG("save", 's', &cfg.save, save),
132-
OPT_BYTE("sel", 'S', &cfg.sel, sel));
128+
OPT_BYTE("wh", 'w', &cfg.wh, wh));
133129

134130
err = parse_and_open(&dev, argc, argv, POWER_MGMT_DESC, opts);
135131
if (err)
136132
return err;
137133

138134
if (argconfig_parse_seen(opts, "ps"))
139-
err = power_mgmt_set(dev, fid, cfg.ps, cfg.wh, cfg.save);
135+
err = power_mgmt_set(dev, fid, cfg.ps, cfg.wh, argconfig_parse_seen(opts, "save"));
140136
else
141137
err = feat_get(dev, fid, 0, cfg.sel, power_mgmt_feat);
142138

@@ -228,16 +224,14 @@ static int feat_perfc(int argc, char **argv, struct command *cmd, struct plugin
228224

229225
struct perfc_config cfg = { 0 };
230226

231-
NVME_ARGS(opts,
227+
FEAT_ARGS(opts,
232228
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_optional),
233229
OPT_BYTE("attri", 'a', &cfg.attri, attri),
234230
OPT_FLAG("rvspa", 'r', &cfg.rvspa, rvspa),
235231
OPT_BYTE("r4karl", 'R', &cfg.r4karl, r4karl),
236232
OPT_STR("paid", 'p', &cfg.paid, paid),
237233
OPT_SHRT("attrl", 'A', &cfg.attrl, attrl),
238-
OPT_FILE("vs-data", 'V', &cfg.vs_data, vs_data),
239-
OPT_FLAG("save", 's', &cfg.save, save),
240-
OPT_BYTE("sel", 'S', &cfg.sel, sel));
234+
OPT_FILE("vs-data", 'V', &cfg.vs_data, vs_data));
241235

242236
err = parse_and_open(&dev, argc, argv, PERFC_DESC, opts);
243237
if (err)
@@ -298,24 +292,21 @@ static int feat_hctm(int argc, char **argv, struct command *cmd, struct plugin *
298292
struct config {
299293
__u16 tmt1;
300294
__u16 tmt2;
301-
bool save;
302295
__u8 sel;
303296
};
304297

305298
struct config cfg = { 0 };
306299

307-
NVME_ARGS(opts,
300+
FEAT_ARGS(opts,
308301
OPT_SHRT("tmt1", 't', &cfg.tmt1, TMT(1)),
309-
OPT_SHRT("tmt2", 'T', &cfg.tmt2, TMT(2)),
310-
OPT_FLAG("save", 's', &cfg.save, save),
311-
OPT_BYTE("sel", 'S', &cfg.sel, sel));
302+
OPT_SHRT("tmt2", 'T', &cfg.tmt2, TMT(2)));
312303

313304
err = parse_and_open(&dev, argc, argv, HCTM_DESC, opts);
314305
if (err)
315306
return err;
316307

317308
if (argconfig_parse_seen(opts, "tmt1") || argconfig_parse_seen(opts, "tmt2"))
318-
err = hctm_set(dev, fid, cfg.tmt1, cfg.tmt2, cfg.save);
309+
err = hctm_set(dev, fid, cfg.tmt1, cfg.tmt2, argconfig_parse_seen(opts, "save"));
319310
else
320311
err = feat_get(dev, fid, 0, cfg.sel, hctm_feat);
321312

plugins/feat/feat-nvme.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#define PERFC_DESC "Get and set perf characteristics feature"
1515
#define HCTM_DESC "Get and set host controlled thermal management feature"
1616

17+
#define FEAT_ARGS(n, ...) \
18+
NVME_ARGS(n, ##__VA_ARGS__, OPT_FLAG("save", 's', NULL, save), \
19+
OPT_BYTE("sel", 'S', &cfg.sel, sel))
20+
1721
PLUGIN(NAME("feat", "NVMe feature extensions", FEAT_PLUGIN_VERSION),
1822
COMMAND_LIST(
1923
ENTRY("power-mgmt", POWER_MGMT_DESC, feat_power_mgmt)

0 commit comments

Comments
 (0)