Commit a71418f3 authored by Federico Vaga's avatar Federico Vaga

drv: fix SDB find_device_ext

the current index variable was not correctly incremented, with
the consequence that under certain conditions the return value
was wrong.
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
Co-Developed: Dimitris Lampridis <Dimitris.Lampridis@cern.ch>
parent 63ccf423
...@@ -35,13 +35,13 @@ signed long fmc_find_sdb_device_ext(struct sdb_array *tree, ...@@ -35,13 +35,13 @@ signed long fmc_find_sdb_device_ext(struct sdb_array *tree,
c = &r->dev.sdb_component; c = &r->dev.sdb_component;
p = &c->product; p = &c->product;
if (!IS_ERR(tree->subtree[i])) if (!IS_ERR(tree->subtree[i])) {
/* FIXME: this index SHOULD be recursive, too */
res = fmc_find_sdb_device(tree->subtree[i], res = fmc_find_sdb_device(tree->subtree[i],
vid, did, sz); vid, did, sz);
if (res >= 0 && ci++ == index)
/* FIXME: this index SHOULD be recursive, too */ return res + tree->baseaddr;
if (ci == index && res >= 0) }
return res + tree->baseaddr;
if (r->empty.record_type != sdb_type_device) if (r->empty.record_type != sdb_type_device)
continue; continue;
if (__be64_to_cpu(p->vendor_id) != vid) if (__be64_to_cpu(p->vendor_id) != vid)
...@@ -53,9 +53,8 @@ signed long fmc_find_sdb_device_ext(struct sdb_array *tree, ...@@ -53,9 +53,8 @@ signed long fmc_find_sdb_device_ext(struct sdb_array *tree,
first = __be64_to_cpu(c->addr_first); first = __be64_to_cpu(c->addr_first);
if (sz) if (sz)
*sz = (typeof(*sz)) (last + 1 - first); *sz = (typeof(*sz)) (last + 1 - first);
if (ci == index) if (ci++ == index)
return first + tree->baseaddr; return first + tree->baseaddr;
ci++;
} }
return res; return res;
} }
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