@@ -203,8 +203,8 @@ static auto expandLocationCode(const string& unexpanded, const Parsed& vpdMap,
203
203
}
204
204
catch (const exception & e)
205
205
{
206
- cerr << " Failed to expand location code with exception: " << e. what ()
207
- << " \n " ;
206
+ std:: cerr << " Failed to expand location code with exception: "
207
+ << e. what () << " \n " ;
208
208
}
209
209
return expanded;
210
210
}
@@ -262,12 +262,12 @@ static void populateFruSpecificInterfaces(const T& map,
262
262
}
263
263
else
264
264
{
265
- cerr << " Unknown Keyword[" << kw << " ] found " ;
265
+ std:: cerr << " Unknown Keyword[" << kw << " ] found " ;
266
266
}
267
267
}
268
268
else
269
269
{
270
- cerr << " Unknown Variant found " ;
270
+ std:: cerr << " Unknown Variant found " ;
271
271
}
272
272
}
273
273
else
@@ -508,29 +508,30 @@ static void preAction(const nlohmann::json& json, const string& file)
508
508
{
509
509
// Now bind the device
510
510
string bind = json[" frus" ][file].at (0 ).value (" devAddress" , " " );
511
- cout << " Binding device " << bind << std::endl;
511
+ std:: cout << " Binding device " << bind << std::endl;
512
512
string bindCmd = string (" echo \" " ) + bind +
513
513
string (" \" > /sys/bus/i2c/drivers/at24/bind" );
514
- cout << bindCmd << std::endl;
514
+ std:: cout << bindCmd << std::endl;
515
515
executeCmd (bindCmd);
516
516
517
517
// Check if device showed up (test for file)
518
518
if (!fs::exists (file))
519
519
{
520
- cerr << " EEPROM " << file
521
- << " does not exist. Take failure action" << std::endl;
520
+ std::cerr << " EEPROM " << file
521
+ << " does not exist. Take failure action"
522
+ << std::endl;
522
523
// If not, then take failure postAction
523
524
executePostFailAction (json, file);
524
525
}
525
526
}
526
527
else
527
528
{
528
529
// missing required informations
529
- cerr << " VPD inventory JSON missing basic informations of "
530
- " preAction "
531
- " for this FRU : ["
532
- << file << " ]. Executing executePostFailAction."
533
- << std::endl;
530
+ std:: cerr << " VPD inventory JSON missing basic informations of "
531
+ " preAction "
532
+ " for this FRU : ["
533
+ << file << " ]. Executing executePostFailAction."
534
+ << std::endl;
534
535
535
536
// Take failure postAction
536
537
executePostFailAction (json, file);
@@ -1354,6 +1355,7 @@ int main(int argc, char** argv)
1354
1355
json js{};
1355
1356
Binary vpdVector{};
1356
1357
string file{};
1358
+ string driver{};
1357
1359
// map to hold additional data in case of logging pel
1358
1360
PelAdditionalData additionalData{};
1359
1361
@@ -1366,12 +1368,16 @@ int main(int argc, char** argv)
1366
1368
1367
1369
try
1368
1370
{
1369
- App app{" ibm-read-vpd - App to read IPZ format VPD, parse it and store "
1370
- " in DBUS" };
1371
+ App app{" ibm-read-vpd - App to read IPZ/Jedec format VPD, parse it and "
1372
+ " store it in DBUS" };
1371
1373
1372
1374
app.add_option (" -f, --file" , file, " File containing VPD (IPZ/KEYWORD)" )
1373
1375
->required ();
1374
1376
1377
+ app.add_option (" --driver" , driver,
1378
+ " Driver used by kernel (at24,at25,ee1004)" )
1379
+ ->required ();
1380
+
1375
1381
CLI11_PARSE (app, argc, argv);
1376
1382
1377
1383
// PEL severity should be ERROR in case of any system VPD failure
@@ -1380,6 +1386,23 @@ int main(int argc, char** argv)
1380
1386
pelSeverity = PelSeverity::ERROR;
1381
1387
}
1382
1388
1389
+ // Check if input file is not empty.
1390
+ if ((file.empty ()) || (driver.empty ()))
1391
+ {
1392
+ std::cerr << " Encountered empty input parameter file [" << file
1393
+ << " ] driver [" << driver << " ]" << std::endl;
1394
+ return 0 ;
1395
+ }
1396
+
1397
+ // Check if currently supported driver or not
1398
+ if ((driver != at24driver) && (driver != at25driver) &&
1399
+ (driver != ee1004driver))
1400
+ {
1401
+ std::cerr << " The driver [" << driver << " ] is not supported."
1402
+ << std::endl;
1403
+ return 0 ;
1404
+ }
1405
+
1383
1406
auto jsonToParse = INVENTORY_JSON_DEFAULT;
1384
1407
1385
1408
// If the symlink exists, it means it has been setup for us, switch the
@@ -1416,31 +1439,34 @@ int main(int argc, char** argv)
1416
1439
if (file.find (" /ahb:apb" ) != string::npos)
1417
1440
{
1418
1441
// Translate udev path to a generic /sys/bus/.. file path.
1419
- udevToGenericPath (file);
1442
+ udevToGenericPath (file, driver );
1420
1443
1421
1444
if ((js[" frus" ].find (file) != js[" frus" ].end ()) &&
1422
1445
(file == systemVpdFilePath))
1423
1446
{
1424
- // We have already collected system VPD, skip.
1447
+ std::cout << " We have already collected system VPD, skiping."
1448
+ << std::endl;
1425
1449
return 0 ;
1426
1450
}
1427
1451
}
1428
1452
1429
1453
if (file.empty ())
1430
1454
{
1431
- cerr << " The EEPROM path <" << file << " > is not valid." ;
1455
+ std:: cerr << " The EEPROM path <" << file << " > is not valid." ;
1432
1456
return 0 ;
1433
1457
}
1434
1458
if (js[" frus" ].find (file) == js[" frus" ].end ())
1435
1459
{
1460
+ std::cerr << " The EEPROM path [" << file
1461
+ << " ] is not found in the json." << std::endl;
1436
1462
return 0 ;
1437
1463
}
1438
1464
1439
1465
if (!fs::exists (file))
1440
1466
{
1441
- cout << " Device path: " << file
1442
- << " does not exist. Spurious udev event? Exiting."
1443
- << std::endl;
1467
+ std:: cout << " Device path: " << file
1468
+ << " does not exist. Spurious udev event? Exiting."
1469
+ << std::endl;
1444
1470
return 0 ;
1445
1471
}
1446
1472
@@ -1464,15 +1490,16 @@ int main(int argc, char** argv)
1464
1490
if (" xyz.openbmc_project.State.Chassis.PowerState.On" ==
1465
1491
getPowerState ())
1466
1492
{
1467
- cout << " This VPD cannot be read when power is ON" << std::endl;
1493
+ std::cout << " This VPD cannot be read when power is ON"
1494
+ << std::endl;
1468
1495
return 0 ;
1469
1496
}
1470
1497
}
1471
1498
1472
1499
// Check if this VPD should be recollected at all
1473
1500
if (!needsRecollection (js, file))
1474
1501
{
1475
- cout << " Skip VPD recollection for: " << file << std::endl;
1502
+ std:: cout << " Skip VPD recollection for: " << file << std::endl;
1476
1503
return 0 ;
1477
1504
}
1478
1505
@@ -1517,7 +1544,7 @@ int main(int argc, char** argv)
1517
1544
additionalData.emplace (" DESCRIPTION" , ex.what ());
1518
1545
createPEL (additionalData, pelSeverity, errIntfForJsonFailure, nullptr );
1519
1546
1520
- cerr << ex.what () << " \n " ;
1547
+ std:: cerr << ex.what () << " \n " ;
1521
1548
rc = -1 ;
1522
1549
}
1523
1550
catch (const VpdEccException& ex)
@@ -1527,21 +1554,21 @@ int main(int argc, char** argv)
1527
1554
INVENTORY_PATH + baseFruInventoryPath);
1528
1555
createPEL (additionalData, pelSeverity, errIntfForEccCheckFail, nullptr );
1529
1556
dumpBadVpd (file, vpdVector);
1530
- cerr << ex.what () << " \n " ;
1557
+ std:: cerr << ex.what () << " \n " ;
1531
1558
rc = -1 ;
1532
1559
}
1533
1560
catch (const VpdDataException& ex)
1534
1561
{
1535
1562
if (isThisPcieOnPass1planar (js, file))
1536
1563
{
1537
- cout << " Pcie_device [" << file
1538
- << " ]'s VPD is not valid on PASS1 planar.Ignoring.\n " ;
1564
+ std:: cout << " Pcie_device [" << file
1565
+ << " ]'s VPD is not valid on PASS1 planar.Ignoring.\n " ;
1539
1566
rc = 0 ;
1540
1567
}
1541
1568
else if (!(isPresent (js, file).value_or (true )))
1542
1569
{
1543
- cout << " FRU at: " << file
1544
- << " is not detected present. Ignore parser error.\n " ;
1570
+ std:: cout << " FRU at: " << file
1571
+ << " is not detected present. Ignore parser error.\n " ;
1545
1572
rc = 0 ;
1546
1573
}
1547
1574
else
@@ -1563,7 +1590,7 @@ int main(int argc, char** argv)
1563
1590
catch (const exception & e)
1564
1591
{
1565
1592
dumpBadVpd (file, vpdVector);
1566
- cerr << e.what () << " \n " ;
1593
+ std:: cerr << e.what () << " \n " ;
1567
1594
rc = -1 ;
1568
1595
}
1569
1596
0 commit comments