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) ...@@ -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 greybus_driver *driver = to_greybus_driver(drv);
struct gb_interface_block *gb_ib = to_gb_interface_block(dev); 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); id = gb_ib_match_id(gb_ib, driver->id_table);
if (id) if (id)
...@@ -94,7 +94,7 @@ static int greybus_probe(struct device *dev) ...@@ -94,7 +94,7 @@ static int greybus_probe(struct device *dev)
{ {
struct greybus_driver *driver = to_greybus_driver(dev->driver); struct greybus_driver *driver = to_greybus_driver(dev->driver);
struct gb_interface_block *gb_ib = to_gb_interface_block(dev); 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; int retval;
/* match id */ /* match id */
......
...@@ -119,13 +119,13 @@ struct greybus_driver { ...@@ -119,13 +119,13 @@ struct greybus_driver {
const char *name; const char *name;
int (*probe)(struct gb_interface_block *gb_ib, 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); void (*disconnect)(struct gb_interface_block *gb_ib);
int (*suspend)(struct gb_interface_block *gb_ib, pm_message_t message); int (*suspend)(struct gb_interface_block *gb_ib, pm_message_t message);
int (*resume)(struct gb_interface_block *gb_ib); 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; struct device_driver driver;
}; };
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
struct greybus_module_id { struct greybus_interface_block_id {
__u16 match_flags; __u16 match_flags;
__u16 vendor; __u16 vendor;
__u16 product; __u16 product;
...@@ -18,9 +18,9 @@ struct greybus_module_id { ...@@ -18,9 +18,9 @@ struct greybus_module_id {
kernel_ulong_t driver_info __aligned(sizeof(kernel_ulong_t)); kernel_ulong_t driver_info __aligned(sizeof(kernel_ulong_t));
}; };
/* Used to match the greybus_module_id */ /* Used to match the greybus_interface_block_id */
#define GREYBUS_DEVICE_ID_MATCH_VENDOR BIT(0) #define GREYBUS_ID_MATCH_VENDOR BIT(0)
#define GREYBUS_DEVICE_ID_MATCH_PRODUCT BIT(1) #define GREYBUS_ID_MATCH_PRODUCT BIT(1)
#define GREYBUS_DEVICE_ID_MATCH_SERIAL BIT(2) #define GREYBUS_ID_MATCH_SERIAL BIT(2)
#endif /* __LINUX_GREYBUS_H */ #endif /* __LINUX_GREYBUS_H */
...@@ -39,33 +39,34 @@ ATTRIBUTE_GROUPS(interface_block); ...@@ -39,33 +39,34 @@ ATTRIBUTE_GROUPS(interface_block);
/* XXX This could be per-host device */ /* XXX This could be per-host device */
static DEFINE_SPINLOCK(gb_modules_lock); static DEFINE_SPINLOCK(gb_modules_lock);
static int gb_module_match_one_id(struct gb_interface_block *gb_ib, static int gb_ib_match_one_id(struct gb_interface_block *gb_ib,
const struct greybus_module_id *id) 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)) (id->vendor != gb_ib->vendor))
return 0; return 0;
if ((id->match_flags & GREYBUS_DEVICE_ID_MATCH_PRODUCT) && if ((id->match_flags & GREYBUS_ID_MATCH_PRODUCT) &&
(id->product != gb_ib->product)) (id->product != gb_ib->product))
return 0; 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)) (id->unique_id != gb_ib->unique_id))
return 0; return 0;
return 1; return 1;
} }
const struct greybus_module_id *gb_ib_match_id(struct gb_interface_block *gb_ib, const struct greybus_interface_block_id *
const struct greybus_module_id *id) gb_ib_match_id(struct gb_interface_block *gb_ib,
const struct greybus_interface_block_id *id)
{ {
if (id == NULL) if (id == NULL)
return NULL; return NULL;
for (; id->vendor || id->product || id->unique_id || for (; id->vendor || id->product || id->unique_id ||
id->driver_info; 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; return id;
} }
......
...@@ -47,8 +47,9 @@ gb_interface_block_get_drvdata(struct gb_interface_block *gb_ib) ...@@ -47,8 +47,9 @@ gb_interface_block_get_drvdata(struct gb_interface_block *gb_ib)
/* Greybus "private" definitions */ /* Greybus "private" definitions */
const struct greybus_module_id *gb_ib_match_id(struct gb_interface_block *gb_ib, const struct greybus_interface_block_id *
const struct greybus_module_id *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, struct gb_interface_block *gb_ib_find(struct greybus_host_device *hd,
u8 module_id); 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