From 2f0c8aa4e6710a939da64412da0bdd7bb9aa5557 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 11 Dec 2014 17:11:02 -0500 Subject: [PATCH] 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: Alex Elder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/core.c | 4 ++-- drivers/staging/greybus/greybus.h | 4 ++-- drivers/staging/greybus/greybus_id.h | 10 +++++----- drivers/staging/greybus/interface_block.c | 17 +++++++++-------- drivers/staging/greybus/interface_block.h | 5 +++-- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index 31460abd5673..66c54d7a0fcf 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -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 */ diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h index b32dd6118e30..95567b853647 100644 --- a/drivers/staging/greybus/greybus.h +++ b/drivers/staging/greybus/greybus.h @@ -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; }; diff --git a/drivers/staging/greybus/greybus_id.h b/drivers/staging/greybus/greybus_id.h index c6cd2e8fa7c1..da70aab54ab0 100644 --- a/drivers/staging/greybus/greybus_id.h +++ b/drivers/staging/greybus/greybus_id.h @@ -9,7 +9,7 @@ #include -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 */ diff --git a/drivers/staging/greybus/interface_block.c b/drivers/staging/greybus/interface_block.c index 3f173aef01c5..882763df70b7 100644 --- a/drivers/staging/greybus/interface_block.c +++ b/drivers/staging/greybus/interface_block.c @@ -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; } diff --git a/drivers/staging/greybus/interface_block.h b/drivers/staging/greybus/interface_block.h index b751ce45a24b..7a166fdf93a7 100644 --- a/drivers/staging/greybus/interface_block.h +++ b/drivers/staging/greybus/interface_block.h @@ -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); -- 2.39.5