Skip to content

Commit 2477065

Browse files
djbwstellarhopper
authored andcommitted
tools/testing/nvdimm: Cleanup dimm index passing
The ND_CMD_CALL path only applies to the nfit_test0 emulated DIMMs. Cleanup occurrences of (i - t->dcr_idx) since that offset fixup only applies to cases where nfit_test1 needs a bus-local index. Cc: Vishal Verma <[email protected]> Cc: Dave Jiang <[email protected]> Cc: Ira Weiny <[email protected]> Signed-off-by: Dan Williams <[email protected]> Signed-off-by: Vishal Verma <[email protected]>
1 parent 6450ddb commit 2477065

File tree

1 file changed

+18
-16
lines changed
  • tools/testing/nvdimm/test

1 file changed

+18
-16
lines changed

tools/testing/nvdimm/test/nfit.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,11 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
12241224
i = get_dimm(nfit_mem, func);
12251225
if (i < 0)
12261226
return i;
1227+
if (i >= NUM_DCR) {
1228+
dev_WARN_ONCE(&t->pdev.dev, 1,
1229+
"ND_CMD_CALL only valid for nfit_test0\n");
1230+
return -EINVAL;
1231+
}
12271232

12281233
switch (func) {
12291234
case NVDIMM_INTEL_GET_SECURITY_STATE:
@@ -1252,11 +1257,11 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
12521257
break;
12531258
case NVDIMM_INTEL_OVERWRITE:
12541259
rc = nd_intel_test_cmd_overwrite(t,
1255-
buf, buf_len, i - t->dcr_idx);
1260+
buf, buf_len, i);
12561261
break;
12571262
case NVDIMM_INTEL_QUERY_OVERWRITE:
12581263
rc = nd_intel_test_cmd_query_overwrite(t,
1259-
buf, buf_len, i - t->dcr_idx);
1264+
buf, buf_len, i);
12601265
break;
12611266
case NVDIMM_INTEL_SET_MASTER_PASSPHRASE:
12621267
rc = nd_intel_test_cmd_master_set_pass(t,
@@ -1272,48 +1277,45 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
12721277
break;
12731278
case ND_INTEL_FW_GET_INFO:
12741279
rc = nd_intel_test_get_fw_info(t, buf,
1275-
buf_len, i - t->dcr_idx);
1280+
buf_len, i);
12761281
break;
12771282
case ND_INTEL_FW_START_UPDATE:
12781283
rc = nd_intel_test_start_update(t, buf,
1279-
buf_len, i - t->dcr_idx);
1284+
buf_len, i);
12801285
break;
12811286
case ND_INTEL_FW_SEND_DATA:
12821287
rc = nd_intel_test_send_data(t, buf,
1283-
buf_len, i - t->dcr_idx);
1288+
buf_len, i);
12841289
break;
12851290
case ND_INTEL_FW_FINISH_UPDATE:
12861291
rc = nd_intel_test_finish_fw(t, buf,
1287-
buf_len, i - t->dcr_idx);
1292+
buf_len, i);
12881293
break;
12891294
case ND_INTEL_FW_FINISH_QUERY:
12901295
rc = nd_intel_test_finish_query(t, buf,
1291-
buf_len, i - t->dcr_idx);
1296+
buf_len, i);
12921297
break;
12931298
case ND_INTEL_SMART:
12941299
rc = nfit_test_cmd_smart(buf, buf_len,
1295-
&t->smart[i - t->dcr_idx]);
1300+
&t->smart[i]);
12961301
break;
12971302
case ND_INTEL_SMART_THRESHOLD:
12981303
rc = nfit_test_cmd_smart_threshold(buf,
12991304
buf_len,
1300-
&t->smart_threshold[i -
1301-
t->dcr_idx]);
1305+
&t->smart_threshold[i]);
13021306
break;
13031307
case ND_INTEL_SMART_SET_THRESHOLD:
13041308
rc = nfit_test_cmd_smart_set_threshold(buf,
13051309
buf_len,
1306-
&t->smart_threshold[i -
1307-
t->dcr_idx],
1308-
&t->smart[i - t->dcr_idx],
1310+
&t->smart_threshold[i],
1311+
&t->smart[i],
13091312
&t->pdev.dev, t->dimm_dev[i]);
13101313
break;
13111314
case ND_INTEL_SMART_INJECT:
13121315
rc = nfit_test_cmd_smart_inject(buf,
13131316
buf_len,
1314-
&t->smart_threshold[i -
1315-
t->dcr_idx],
1316-
&t->smart[i - t->dcr_idx],
1317+
&t->smart_threshold[i],
1318+
&t->smart[i],
13171319
&t->pdev.dev, t->dimm_dev[i]);
13181320
break;
13191321
default:

0 commit comments

Comments
 (0)