2014-01-30 12:05:14

by Alessandro Rubini

[permalink] [raw]
Subject: [PATCH 1/2] FMC: support carriers with no mezzanine

At registration and unregistration time, I was checking fmc->flags
for FMC_DEVICE_NO_MEZZANINE, to skip initialization and cleanup for
empty slots. The check was wrong ("==" instead of "&") but
registration failed anyways (as expected) because we had no EEPROM.

This commit fixes one such checks and removes the other, so to
actually accept slots with no mezzanines. That's because the carrier
may offer some support anyways (the SPEC does), and working on the
carrier with no mezzanine-specific driver is common during
development.

Signed-off-by: Alessandro Rubini <[email protected]>
Acked-by: Juan David Gonzalez Cobas <[email protected]>
---
drivers/fmc/fmc-core.c | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/drivers/fmc/fmc-core.c b/drivers/fmc/fmc-core.c
index 5f0a15c..b8a594c 100644
--- a/drivers/fmc/fmc-core.c
+++ b/drivers/fmc/fmc-core.c
@@ -153,7 +153,7 @@ int fmc_device_register_n(struct fmc_device **devs, int n)
ret = -EINVAL;
break;
}
- if (fmc->flags == FMC_DEVICE_NO_MEZZANINE) {
+ if (fmc->flags & FMC_DEVICE_NO_MEZZANINE) {
dev_info(fmc->hwdev, "absent mezzanine in slot %d\n",
fmc->slot_id);
continue;
@@ -188,9 +188,6 @@ int fmc_device_register_n(struct fmc_device **devs, int n)
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;

@@ -262,8 +259,6 @@ 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]);
--
1.7.7.2


2014-01-30 12:05:29

by Alessandro Rubini

[permalink] [raw]
Subject: [PATCH 2/2] FMC: show_sdb_tree: fix offset calculation

The code reported wrong addresses in the sdb dumps. All sdb addresses
are relative, but the code was adding the base address twice. Bug
exposed by a gateware image with two bridge levels.

Thanks David for reporting the problem.

Signed-off-by: Alessandro Rubini <[email protected]>
Reported-by: Juan David Gonzalez Cobas <[email protected]>
Tested-by: Juan David Gonzalez Cobas <[email protected]>
---
drivers/fmc/fmc-sdb.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/fmc/fmc-sdb.c b/drivers/fmc/fmc-sdb.c
index 79adc39..69f42d7 100644
--- a/drivers/fmc/fmc-sdb.c
+++ b/drivers/fmc/fmc-sdb.c
@@ -153,20 +153,17 @@ EXPORT_SYMBOL(fmc_reprogram);
static void __fmc_show_sdb_tree(const struct fmc_device *fmc,
const struct sdb_array *arr)
{
+ unsigned long base = arr->baseaddr;
int i, j, n = arr->len, level = arr->level;
- const struct sdb_array *ap;

for (i = 0; i < n; i++) {
- unsigned long base;
union sdb_record *r;
struct sdb_product *p;
struct sdb_component *c;
r = &arr->record[i];
c = &r->dev.sdb_component;
p = &c->product;
- base = 0;
- for (ap = arr; ap; ap = ap->parent)
- base += ap->baseaddr;
+
dev_info(&fmc->dev, "SDB: ");

for (j = 0; j < level; j++)
--
1.7.7.2