greybus: driver matching: Greybus drivers bind to interface blocks, not modules
authorGreg Kroah-Hartman <greg@kroah.com>
Thu, 11 Dec 2014 22:11:02 +0000 (17:11 -0500)
committerGreg Kroah-Hartman <greg@kroah.com>
Fri, 12 Dec 2014 00:53:59 +0000 (19:53 -0500)
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 <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/core.c
drivers/staging/greybus/greybus.h
drivers/staging/greybus/greybus_id.h
drivers/staging/greybus/interface_block.c
drivers/staging/greybus/interface_block.h

index 31460ab..66c54d7 100644 (file)
@@ -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 */
index b32dd61..95567b8 100644 (file)
@@ -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;
 };
index c6cd2e8..da70aab 100644 (file)
@@ -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 */
index 3f173ae..882763d 100644 (file)
@@ -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;
        }
 
index b751ce4..7a166fd 100644 (file)
@@ -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);