Commit 501cc8bd authored by Viresh Kumar's avatar Viresh Kumar Committed by Greg Kroah-Hartman

greybus: Fix probing of gpbridge devices

The gpbridge core tries to match the driver's id-table against all
CPorts available within the bundle for which the gpbridge bus was
created. The gpbdev here is unique for a cport_desc and only a single
cport_desc->protocol_id should be matched with the driver's id-table.

Fix it.

Tested on EVT 1.5 with a special manifest for GP module, where multiple
CPorts are part of the same Bridged PHY bundle.

Fixes: 75223f666687 ("gpbridge: implement gpbridge "bus" logic")
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent e4e55360
...@@ -57,44 +57,27 @@ static int gpbdev_uevent(struct device *dev, struct kobj_uevent_env *env) ...@@ -57,44 +57,27 @@ static int gpbdev_uevent(struct device *dev, struct kobj_uevent_env *env)
} }
static const struct gpbridge_device_id * static const struct gpbridge_device_id *
gpbdev_match_cport(struct greybus_descriptor_cport *cport_desc, gpbdev_match_id(struct gpbridge_device *gpbdev, struct gpbridge_driver *gpbdrv)
const struct gpbridge_device_id *id)
{ {
const struct gpbridge_device_id *id = gpbdrv->id_table;
if (!id) if (!id)
return NULL; return NULL;
for (; id->protocol_id; id++) for (; id->protocol_id; id++)
if (id->protocol_id == cport_desc->protocol_id) if (id->protocol_id == gpbdev->cport_desc->protocol_id)
return id; return id;
return NULL; return NULL;
} }
static const struct gpbridge_device_id *gpbdev_match_id(struct gb_bundle *bundle,
const struct gpbridge_device_id *id_table)
{
const struct gpbridge_device_id *id;
int i;
if (!id_table || !bundle || bundle->num_cports == 0)
return NULL;
for (i = 0; i < bundle->num_cports; i++) {
id = gpbdev_match_cport(&bundle->cport_desc[i], id_table);
if (id)
return id;
}
return NULL;
}
static int gpbdev_match(struct device *dev, struct device_driver *drv) static int gpbdev_match(struct device *dev, struct device_driver *drv)
{ {
struct gpbridge_driver *gpbdrv = to_gpbridge_driver(drv); struct gpbridge_driver *gpbdrv = to_gpbridge_driver(drv);
struct gpbridge_device *gpbdev = to_gpbridge_dev(dev); struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
const struct gpbridge_device_id *id; const struct gpbridge_device_id *id;
id = gpbdev_match_id(gpbdev->bundle, gpbdrv->id_table); id = gpbdev_match_id(gpbdev, gpbdrv);
if (id) if (id)
return 1; return 1;
...@@ -107,7 +90,7 @@ static int gpbdev_probe(struct device *dev) ...@@ -107,7 +90,7 @@ static int gpbdev_probe(struct device *dev)
struct gpbridge_device *gpbdev = to_gpbridge_dev(dev); struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
const struct gpbridge_device_id *id; const struct gpbridge_device_id *id;
id = gpbdev_match_id(gpbdev->bundle, gpbdrv->id_table); id = gpbdev_match_id(gpbdev, gpbdrv);
if (!id) if (!id)
return -ENODEV; return -ENODEV;
......
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