OF-style matching can be available to any device, on any type of bus.
This patch allows any driver to provide an OF match table when CONFIG_OF
is enabled so that drivers can be bound against devices described in
the device tree.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
 
 int ibmebus_register_driver(struct of_platform_driver *drv)
 {
+       if (!drv->driver.of_match_table)
+               drv->driver.of_match_table = drv->match_table;
+
        /* If the driver uses devices that ibmebus doesn't know, add them */
-       ibmebus_create_devices(drv->match_table);
+       ibmebus_create_devices(drv->driver.of_match_table);
 
        return of_register_driver(drv, &ibmebus_bus_type);
 }
 
 static int macio_bus_match(struct device *dev, struct device_driver *drv) 
 {
        struct macio_dev * macio_dev = to_macio_device(dev);
-       struct macio_driver * macio_drv = to_macio_driver(drv);
-       const struct of_device_id * matches = macio_drv->match_table;
+       const struct of_device_id * matches = drv->of_match_table;
 
        if (!matches) 
                return 0;
 
        macio_dev_get(macio_dev);
 
-       match = of_match_device(drv->match_table, &macio_dev->ofdev);
+       match = of_match_device(drv->driver.of_match_table, &macio_dev->ofdev);
        if (match)
                error = drv->probe(macio_dev, match);
        if (error)
 
 static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
 {
        struct of_device *of_dev = to_of_device(dev);
-       struct of_platform_driver *of_drv = to_of_platform_driver(drv);
-       const struct of_device_id *matches = of_drv->match_table;
+       const struct of_device_id *matches = drv->of_match_table;
 
        if (!matches)
                return 0;
 
        of_dev_get(of_dev);
 
-       match = of_match_device(drv->match_table, of_dev);
+       match = of_match_device(drv->driver.of_match_table, of_dev);
        if (match)
                error = drv->probe(of_dev, match);
        if (error)
                drv->driver.name = drv->name;
        if (!drv->driver.owner)
                drv->driver.owner = drv->owner;
+       if (!drv->driver.of_match_table)
+               drv->driver.of_match_table = drv->match_table;
        drv->driver.bus = bus;
 
        /* register with core */
 
 
        bool suppress_bind_attrs;       /* disables bind/unbind via sysfs */
 
+#if defined(CONFIG_OF)
+       const struct of_device_id       *of_match_table;
+#endif
+
        int (*probe) (struct device *dev);
        int (*remove) (struct device *dev);
        void (*shutdown) (struct device *dev);