Commit c085d660 authored by Federico Vaga's avatar Federico Vaga Committed by Federico Vaga

kernel: fail only when all FMC prepare fail

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 28431f5d
...@@ -189,6 +189,8 @@ int svec_fmc_prepare(struct svec_dev *svec, unsigned int fmc_slot) ...@@ -189,6 +189,8 @@ int svec_fmc_prepare(struct svec_dev *svec, unsigned int fmc_slot)
struct fmc_device *fmc; struct fmc_device *fmc;
int ret = 0; int ret = 0;
svec->fmcs[fmc_slot] = NULL;
if (fmc_slot >= SVEC_N_SLOTS) if (fmc_slot >= SVEC_N_SLOTS)
return -EINVAL; return -EINVAL;
...@@ -257,13 +259,22 @@ int svec_fmc_prepare(struct svec_dev *svec, unsigned int fmc_slot) ...@@ -257,13 +259,22 @@ int svec_fmc_prepare(struct svec_dev *svec, unsigned int fmc_slot)
int svec_fmc_create(struct svec_dev *svec, struct fmc_gateware *gw) int svec_fmc_create(struct svec_dev *svec, struct fmc_gateware *gw)
{ {
int i; int i;
int error = 0; int error = 0, err_cnt = 0;
/* fmc structures filling */ /* fmc structures filling */
for (i = 0; i < svec->fmcs_n; i++) { for (i = 0; i < svec->fmcs_n; i++) {
error = svec_fmc_prepare(svec, i); error = svec_fmc_prepare(svec, i);
if (error) if (error) {
goto failed; err_cnt++;
dev_err(svec->dev,
"Cannot create FMC device for FMC slot %d\n",
i + 1);
}
}
/* Fail only when all FMC preparations fail */
if (err_cnt == svec->fmcs_n) {
error = -ENODEV;
goto failed;
} }
/* fmc device creation */ /* fmc device creation */
...@@ -281,13 +292,15 @@ int svec_fmc_create(struct svec_dev *svec, struct fmc_gateware *gw) ...@@ -281,13 +292,15 @@ int svec_fmc_create(struct svec_dev *svec, struct fmc_gateware *gw)
/* scan SDB. Do not report errors, we don't care, SDB is not /* scan SDB. Do not report errors, we don't care, SDB is not
mandatory for the carrier board */ mandatory for the carrier board */
for (i = 0; i < svec->fmcs_n; i++) for (i = 0; i < svec->fmcs_n; i++)
fmc_scan_sdb_tree(svec->fmcs[i], 0); if (svec->fmcs[i])
fmc_scan_sdb_tree(svec->fmcs[i], 0);
return 0; return 0;
failed: failed:
for (i = 0; i < svec->fmcs_n; i++) for (i = 0; i < svec->fmcs_n; i++)
kfree(svec->fmcs[i]); if (svec->fmcs[i])
kfree(svec->fmcs[i]);
/* FIXME: free fmc allocations. */ /* FIXME: free fmc allocations. */
return error; return error;
......
Markdown is supported
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