Commit b7036bfd authored by Alessandro Rubini's avatar Alessandro Rubini

kernel/fmc-core: ignore empty slots on register/unregister

Multi-slot boards like the svec may have one ore more empty slots.
This patch makes the core ignore empty slots, but otherwise succeed.
Carriers are not expected to register completely-empty mezzanine sets
(but if that happens registration succeeds with no effect).

Change suggested by David Cobas.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 3b4f5ee3
......@@ -152,6 +152,11 @@ int fmc_device_register_n(struct fmc_device **devs, int n)
pr_err("%s: device has no hwdev pointer\n", __func__);
return -EINVAL;
}
if (fmc->flags == FMC_DEVICE_NO_MEZZANINE) {
dev_info(fmc->hwdev, "absent mezzanine in slot %d\n",
fmc->slot_id);
continue;
}
if (!fmc->eeprom) {
dev_err(fmc->hwdev, "no eeprom provided to fmc bus\n");
ret = -EINVAL;
......@@ -178,6 +183,10 @@ int fmc_device_register_n(struct fmc_device **devs, int n)
/* Validation is ok. Now init and register the devices */
for (i = 0; i < n; i++) {
fmc = devarray[i];
if (fmc->flags == FMC_DEVICE_NO_MEZZANINE)
continue; /* dev_info already done above */
fmc->nr_slots = n; /* each slot must know how many are there */
fmc->devarray = devarray;
......@@ -249,6 +258,8 @@ void fmc_device_unregister_n(struct fmc_device **devs, int n)
kfree(devs[0]->devarray);
for (i = 0; i < n; i++) {
if (devs[i]->flags == FMC_DEVICE_NO_MEZZANINE)
continue;
sysfs_remove_bin_file(&devs[i]->dev.kobj, &fmc_eeprom_attr);
device_del(&devs[i]->dev);
fmc_free_id_info(devs[i]);
......
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