Skip to content
Snippets Groups Projects
Commit 2bcf98aa authored by Federico Vaga's avatar Federico Vaga
Browse files

lib: check mezzanine presence before EEPROM read/write


Signed-off-by: default avatarFederico Vaga <federico.vaga@cern.ch>
parent da454cc4
No related merge requests found
......@@ -20,6 +20,7 @@ struct fmc_tkn;
#define __FMC_ERR_MIN 4096
enum fmc_error_numbers {
FMC_ERR_SLOT_NODEV = __FMC_ERR_MIN,
FMC_ERR_NOPRES,
__FMC_ERR_MAX,
};
......
......@@ -56,6 +56,7 @@ struct fmc_carrier {
static const char *fmc_error_string[] = {
[FMC_ERR_SLOT_NODEV - __FMC_ERR_MIN] = "Slot number not found",
[FMC_ERR_NOPRES - __FMC_ERR_MIN] = "FMC Module not present",
};
/**
......@@ -447,6 +448,11 @@ int fmc_slot_eeprom_read(struct fmc_tkn *tkn, unsigned int slot_n,
int fd;
int ret;
if (!fmc_slot_is_present(tkn, slot_n)) {
errno = FMC_ERR_NOPRES;
return -1;
}
snprintf(path, MAX_PATH_LEN,
"/sys/class/fmc/fmc-carrier-%u/fmc-slot-%u.%u/fru_eeprom/eeprom",
carrier->id, carrier->id, slot_n);
......@@ -480,6 +486,11 @@ int fmc_slot_eeprom_write(struct fmc_tkn *tkn, unsigned int slot_n,
int fd;
int ret;
if (!fmc_slot_is_present(tkn, slot_n)) {
errno = FMC_ERR_NOPRES;
return -1;
}
snprintf(path, MAX_PATH_LEN,
"/sys/class/fmc/fmc-carrier-%u/fmc-slot-%u.%u/fru_eeprom/eeprom",
carrier->id, carrier->id, slot_n);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment