Commit 2f0c8aa4 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

greybus: driver matching: Greybus drivers bind to interface blocks, not modules

Because of this, rename greybus_module_id to greybus_interface_block_id.

We still need to add a way for a "class" driver to be bound to an
interface, but for now, all we really need is the vendor/product pair as
the GP Bridge interface block is going to be our main user.
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 640f13ec
......@@ -34,7 +34,7 @@ static int greybus_module_match(struct device *dev, struct device_driver *drv)
{
struct greybus_driver *driver = to_greybus_driver(drv);
struct gb_interface_block *gb_ib = to_gb_interface_block(dev);
const struct greybus_module_id *id;
const struct greybus_interface_block_id *id;
id = gb_ib_match_id(gb_ib, driver->id_table);
if (id)
......@@ -94,7 +94,7 @@ static int greybus_probe(struct device *dev)
{
struct greybus_driver *driver = to_greybus_driver(dev->driver);
struct gb_interface_block *gb_ib = to_gb_interface_block(dev);
const struct greybus_module_id *id;
const struct greybus_interface_block_id *id;
int retval;
/* match id */
......
......@@ -119,13 +119,13 @@ struct greybus_driver {
const char *name;
int (*probe)(struct gb_interface_block *gb_ib,
const struct greybus_module_id *id);
const struct greybus_interface_block_id *id);
void (*disconnect)(struct gb_interface_block *gb_ib);
int (*suspend)(struct gb_interface_block *gb_ib, pm_message_t message);
int (*resume)(struct gb_interface_block *gb_ib);
const struct greybus_module_id *id_table;
const struct greybus_interface_block_id *id_table;
struct device_driver driver;
};
......
......@@ -9,7 +9,7 @@
#include <linux/mod_devicetable.h>
struct greybus_module_id {
struct greybus_interface_block_id {
__u16 match_flags;
__u16 vendor;
__u16 product;
......@@ -18,9 +18,9 @@ struct greybus_module_id {
kernel_ulong_t driver_info __aligned(sizeof(kernel_ulong_t));
};
/* Used to match the greybus_module_id */
#define GREYBUS_DEVICE_ID_MATCH_VENDOR BIT(0)
#define GREYBUS_DEVICE_ID_MATCH_PRODUCT BIT(1)
#define GREYBUS_DEVICE_ID_MATCH_SERIAL BIT(2)
/* Used to match the greybus_interface_block_id */
#define GREYBUS_ID_MATCH_VENDOR BIT(0)
#define GREYBUS_ID_MATCH_PRODUCT BIT(1)
#define GREYBUS_ID_MATCH_SERIAL BIT(2)
#endif /* __LINUX_GREYBUS_H */
......@@ -39,33 +39,34 @@ ATTRIBUTE_GROUPS(interface_block);
/* XXX This could be per-host device */
static DEFINE_SPINLOCK(gb_modules_lock);
static int gb_module_match_one_id(struct gb_interface_block *gb_ib,
const struct greybus_module_id *id)
static int gb_ib_match_one_id(struct gb_interface_block *gb_ib,
const struct greybus_interface_block_id *id)
{
if ((id->match_flags & GREYBUS_DEVICE_ID_MATCH_VENDOR) &&
if ((id->match_flags & GREYBUS_ID_MATCH_VENDOR) &&
(id->vendor != gb_ib->vendor))
return 0;
if ((id->match_flags & GREYBUS_DEVICE_ID_MATCH_PRODUCT) &&
if ((id->match_flags & GREYBUS_ID_MATCH_PRODUCT) &&
(id->product != gb_ib->product))
return 0;
if ((id->match_flags & GREYBUS_DEVICE_ID_MATCH_SERIAL) &&
if ((id->match_flags & GREYBUS_ID_MATCH_SERIAL) &&
(id->unique_id != gb_ib->unique_id))
return 0;
return 1;
}
const struct greybus_module_id *gb_ib_match_id(struct gb_interface_block *gb_ib,
const struct greybus_module_id *id)
const struct greybus_interface_block_id *
gb_ib_match_id(struct gb_interface_block *gb_ib,
const struct greybus_interface_block_id *id)
{
if (id == NULL)
return NULL;
for (; id->vendor || id->product || id->unique_id ||
id->driver_info; id++) {
if (gb_module_match_one_id(gb_ib, id))
if (gb_ib_match_one_id(gb_ib, id))
return id;
}
......
......@@ -47,8 +47,9 @@ gb_interface_block_get_drvdata(struct gb_interface_block *gb_ib)
/* Greybus "private" definitions */
const struct greybus_module_id *gb_ib_match_id(struct gb_interface_block *gb_ib,
const struct greybus_module_id *id);
const struct greybus_interface_block_id *
gb_ib_match_id(struct gb_interface_block *gb_ib,
const struct greybus_interface_block_id *id);
struct gb_interface_block *gb_ib_find(struct greybus_host_device *hd,
u8 module_id);
......
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