Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] Souped-up of_platform_device support

This patch first splits of_device.c and of_platform.c, the later containing
the bits relative to of_platform_device's. On the "breaks" side of things,
drivers uisng of_platform_device(s) need to include asm/of_platform.h now
and of_(un)register_driver is now of_(un)register_platform_driver.

In addition to a few utility functions to locate of_platform_device(s),
the main new addition is of_platform_bus_probe() which allows the platform
code to trigger an automatic creation of of_platform_devices for a whole
tree of devices.

The function acts based on the type of the various "parent" devices encountered
from a provided root, using either a default known list of bus types that can be
"probed" or a passed-in list. It will only register devices on busses matching
that list, which mean that typically, it will not register PCI devices, as
expected (since they will be picked up by the PCI layer).

This will be used by Cell platforms using 4xx-type IOs in the Axon bridge
and can be used by any embedded-type device as well.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Benjamin Herrenschmidt and committed by
Paul Mackerras
7eebde70 21fb5a1d

+480 -191
+1 -1
arch/powerpc/kernel/Makefile
··· 21 21 obj-$(CONFIG_PPC64) += vdso64/ 22 22 obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o 23 23 obj-$(CONFIG_PPC_970_NAP) += idle_power4.o 24 - obj-$(CONFIG_PPC_OF) += of_device.o prom_parse.o 24 + obj-$(CONFIG_PPC_OF) += of_device.o of_platform.o prom_parse.o 25 25 procfs-$(CONFIG_PPC64) := proc_ppc64.o 26 26 obj-$(CONFIG_PROC_FS) += $(procfs-y) 27 27 rtaspci-$(CONFIG_PPC64) := rtas_pci.o
+31 -149
arch/powerpc/kernel/of_device.c
··· 9 9 #include <asm/of_device.h> 10 10 11 11 /** 12 + * of_match_node - Tell if an device_node has a matching of_match structure 13 + * @ids: array of of device match structures to search in 14 + * @node: the of device structure to match against 15 + * 16 + * Low level utility function used by device matching. 17 + */ 18 + const struct of_device_id *of_match_node(const struct of_device_id *matches, 19 + const struct device_node *node) 20 + { 21 + while (matches->name[0] || matches->type[0] || matches->compatible[0]) { 22 + int match = 1; 23 + if (matches->name[0]) 24 + match &= node->name 25 + && !strcmp(matches->name, node->name); 26 + if (matches->type[0]) 27 + match &= node->type 28 + && !strcmp(matches->type, node->type); 29 + if (matches->compatible[0]) 30 + match &= device_is_compatible(node, 31 + matches->compatible); 32 + if (match) 33 + return matches; 34 + matches++; 35 + } 36 + return NULL; 37 + } 38 + 39 + /** 12 40 * of_match_device - Tell if an of_device structure has a matching 13 41 * of_match structure 14 42 * @ids: array of of device match structures to search in ··· 50 22 { 51 23 if (!dev->node) 52 24 return NULL; 53 - while (matches->name[0] || matches->type[0] || matches->compatible[0]) { 54 - int match = 1; 55 - if (matches->name[0]) 56 - match &= dev->node->name 57 - && !strcmp(matches->name, dev->node->name); 58 - if (matches->type[0]) 59 - match &= dev->node->type 60 - && !strcmp(matches->type, dev->node->type); 61 - if (matches->compatible[0]) 62 - match &= device_is_compatible(dev->node, 63 - matches->compatible); 64 - if (match) 65 - return matches; 66 - matches++; 67 - } 68 - return NULL; 69 - } 70 - 71 - static int of_platform_bus_match(struct device *dev, struct device_driver *drv) 72 - { 73 - struct of_device * of_dev = to_of_device(dev); 74 - struct of_platform_driver * of_drv = to_of_platform_driver(drv); 75 - const struct of_device_id * matches = of_drv->match_table; 76 - 77 - if (!matches) 78 - return 0; 79 - 80 - return of_match_device(matches, of_dev) != NULL; 25 + return of_match_node(matches, dev->node); 81 26 } 82 27 83 28 struct of_device *of_dev_get(struct of_device *dev) ··· 72 71 put_device(&dev->dev); 73 72 } 74 73 75 - 76 - static int of_device_probe(struct device *dev) 77 - { 78 - int error = -ENODEV; 79 - struct of_platform_driver *drv; 80 - struct of_device *of_dev; 81 - const struct of_device_id *match; 82 - 83 - drv = to_of_platform_driver(dev->driver); 84 - of_dev = to_of_device(dev); 85 - 86 - if (!drv->probe) 87 - return error; 88 - 89 - of_dev_get(of_dev); 90 - 91 - match = of_match_device(drv->match_table, of_dev); 92 - if (match) 93 - error = drv->probe(of_dev, match); 94 - if (error) 95 - of_dev_put(of_dev); 96 - 97 - return error; 98 - } 99 - 100 - static int of_device_remove(struct device *dev) 101 - { 102 - struct of_device * of_dev = to_of_device(dev); 103 - struct of_platform_driver * drv = to_of_platform_driver(dev->driver); 104 - 105 - if (dev->driver && drv->remove) 106 - drv->remove(of_dev); 107 - return 0; 108 - } 109 - 110 - static int of_device_suspend(struct device *dev, pm_message_t state) 111 - { 112 - struct of_device * of_dev = to_of_device(dev); 113 - struct of_platform_driver * drv = to_of_platform_driver(dev->driver); 114 - int error = 0; 115 - 116 - if (dev->driver && drv->suspend) 117 - error = drv->suspend(of_dev, state); 118 - return error; 119 - } 120 - 121 - static int of_device_resume(struct device * dev) 122 - { 123 - struct of_device * of_dev = to_of_device(dev); 124 - struct of_platform_driver * drv = to_of_platform_driver(dev->driver); 125 - int error = 0; 126 - 127 - if (dev->driver && drv->resume) 128 - error = drv->resume(of_dev); 129 - return error; 130 - } 131 - 132 - struct bus_type of_platform_bus_type = { 133 - .name = "of_platform", 134 - .match = of_platform_bus_match, 135 - .probe = of_device_probe, 136 - .remove = of_device_remove, 137 - .suspend = of_device_suspend, 138 - .resume = of_device_resume, 139 - }; 140 - 141 - static int __init of_bus_driver_init(void) 142 - { 143 - return bus_register(&of_platform_bus_type); 144 - } 145 - 146 - postcore_initcall(of_bus_driver_init); 147 - 148 - int of_register_driver(struct of_platform_driver *drv) 149 - { 150 - /* initialize common driver fields */ 151 - drv->driver.name = drv->name; 152 - drv->driver.bus = &of_platform_bus_type; 153 - 154 - /* register with core */ 155 - return driver_register(&drv->driver); 156 - } 157 - 158 - void of_unregister_driver(struct of_platform_driver *drv) 159 - { 160 - driver_unregister(&drv->driver); 161 - } 162 - 163 - 164 - static ssize_t dev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf) 74 + static ssize_t dev_show_devspec(struct device *dev, 75 + struct device_attribute *attr, char *buf) 165 76 { 166 77 struct of_device *ofdev; 167 78 ··· 121 208 device_unregister(&ofdev->dev); 122 209 } 123 210 124 - struct of_device* of_platform_device_create(struct device_node *np, 125 - const char *bus_id, 126 - struct device *parent) 127 - { 128 - struct of_device *dev; 129 - 130 - dev = kmalloc(sizeof(*dev), GFP_KERNEL); 131 - if (!dev) 132 - return NULL; 133 - memset(dev, 0, sizeof(*dev)); 134 - 135 - dev->node = of_node_get(np); 136 - dev->dma_mask = 0xffffffffUL; 137 - dev->dev.dma_mask = &dev->dma_mask; 138 - dev->dev.parent = parent; 139 - dev->dev.bus = &of_platform_bus_type; 140 - dev->dev.release = of_release_dev; 141 - 142 - strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE); 143 - 144 - if (of_device_register(dev) != 0) { 145 - kfree(dev); 146 - return NULL; 147 - } 148 - 149 - return dev; 150 - } 151 211 152 212 EXPORT_SYMBOL(of_match_device); 153 - EXPORT_SYMBOL(of_platform_bus_type); 154 - EXPORT_SYMBOL(of_register_driver); 155 - EXPORT_SYMBOL(of_unregister_driver); 156 213 EXPORT_SYMBOL(of_device_register); 157 214 EXPORT_SYMBOL(of_device_unregister); 158 215 EXPORT_SYMBOL(of_dev_get); 159 216 EXPORT_SYMBOL(of_dev_put); 160 - EXPORT_SYMBOL(of_platform_device_create); 161 217 EXPORT_SYMBOL(of_release_dev);
+372
arch/powerpc/kernel/of_platform.c
··· 1 + /* 2 + * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. 3 + * <benh@kernel.crashing.org> 4 + * 5 + * This program is free software; you can redistribute it and/or 6 + * modify it under the terms of the GNU General Public License 7 + * as published by the Free Software Foundation; either version 8 + * 2 of the License, or (at your option) any later version. 9 + * 10 + */ 11 + 12 + #undef DEBUG 13 + 14 + #include <linux/string.h> 15 + #include <linux/kernel.h> 16 + #include <linux/init.h> 17 + #include <linux/module.h> 18 + #include <linux/mod_devicetable.h> 19 + #include <linux/slab.h> 20 + 21 + #include <asm/errno.h> 22 + #include <asm/dcr.h> 23 + #include <asm/of_device.h> 24 + #include <asm/of_platform.h> 25 + 26 + 27 + /* 28 + * The list of OF IDs below is used for matching bus types in the 29 + * system whose devices are to be exposed as of_platform_devices. 30 + * 31 + * This is the default list valid for most platforms. This file provides 32 + * functions who can take an explicit list if necessary though 33 + * 34 + * The search is always performed recursively looking for children of 35 + * the provided device_node and recursively if such a children matches 36 + * a bus type in the list 37 + */ 38 + 39 + static struct of_device_id of_default_bus_ids[] = { 40 + { .type = "soc", }, 41 + { .compatible = "soc", }, 42 + { .type = "spider", }, 43 + { .type = "axon", }, 44 + { .type = "plb5", }, 45 + { .type = "plb4", }, 46 + { .type = "opb", }, 47 + {}, 48 + }; 49 + 50 + /* 51 + * 52 + * OF platform device type definition & base infrastructure 53 + * 54 + */ 55 + 56 + static int of_platform_bus_match(struct device *dev, struct device_driver *drv) 57 + { 58 + struct of_device * of_dev = to_of_device(dev); 59 + struct of_platform_driver * of_drv = to_of_platform_driver(drv); 60 + const struct of_device_id * matches = of_drv->match_table; 61 + 62 + if (!matches) 63 + return 0; 64 + 65 + return of_match_device(matches, of_dev) != NULL; 66 + } 67 + 68 + static int of_platform_device_probe(struct device *dev) 69 + { 70 + int error = -ENODEV; 71 + struct of_platform_driver *drv; 72 + struct of_device *of_dev; 73 + const struct of_device_id *match; 74 + 75 + drv = to_of_platform_driver(dev->driver); 76 + of_dev = to_of_device(dev); 77 + 78 + if (!drv->probe) 79 + return error; 80 + 81 + of_dev_get(of_dev); 82 + 83 + match = of_match_device(drv->match_table, of_dev); 84 + if (match) 85 + error = drv->probe(of_dev, match); 86 + if (error) 87 + of_dev_put(of_dev); 88 + 89 + return error; 90 + } 91 + 92 + static int of_platform_device_remove(struct device *dev) 93 + { 94 + struct of_device * of_dev = to_of_device(dev); 95 + struct of_platform_driver * drv = to_of_platform_driver(dev->driver); 96 + 97 + if (dev->driver && drv->remove) 98 + drv->remove(of_dev); 99 + return 0; 100 + } 101 + 102 + static int of_platform_device_suspend(struct device *dev, pm_message_t state) 103 + { 104 + struct of_device * of_dev = to_of_device(dev); 105 + struct of_platform_driver * drv = to_of_platform_driver(dev->driver); 106 + int error = 0; 107 + 108 + if (dev->driver && drv->suspend) 109 + error = drv->suspend(of_dev, state); 110 + return error; 111 + } 112 + 113 + static int of_platform_device_resume(struct device * dev) 114 + { 115 + struct of_device * of_dev = to_of_device(dev); 116 + struct of_platform_driver * drv = to_of_platform_driver(dev->driver); 117 + int error = 0; 118 + 119 + if (dev->driver && drv->resume) 120 + error = drv->resume(of_dev); 121 + return error; 122 + } 123 + 124 + struct bus_type of_platform_bus_type = { 125 + .name = "of_platform", 126 + .match = of_platform_bus_match, 127 + .probe = of_platform_device_probe, 128 + .remove = of_platform_device_remove, 129 + .suspend = of_platform_device_suspend, 130 + .resume = of_platform_device_resume, 131 + }; 132 + EXPORT_SYMBOL(of_platform_bus_type); 133 + 134 + static int __init of_bus_driver_init(void) 135 + { 136 + return bus_register(&of_platform_bus_type); 137 + } 138 + 139 + postcore_initcall(of_bus_driver_init); 140 + 141 + int of_register_platform_driver(struct of_platform_driver *drv) 142 + { 143 + /* initialize common driver fields */ 144 + drv->driver.name = drv->name; 145 + drv->driver.bus = &of_platform_bus_type; 146 + 147 + /* register with core */ 148 + return driver_register(&drv->driver); 149 + } 150 + EXPORT_SYMBOL(of_register_platform_driver); 151 + 152 + void of_unregister_platform_driver(struct of_platform_driver *drv) 153 + { 154 + driver_unregister(&drv->driver); 155 + } 156 + EXPORT_SYMBOL(of_unregister_platform_driver); 157 + 158 + static void of_platform_make_bus_id(struct of_device *dev) 159 + { 160 + struct device_node *node = dev->node; 161 + char *name = dev->dev.bus_id; 162 + const u32 *reg; 163 + u64 addr; 164 + 165 + /* 166 + * If it's a DCR based device, use 'd' for native DCRs 167 + * and 'D' for MMIO DCRs. 168 + */ 169 + #ifdef CONFIG_PPC_DCR 170 + reg = get_property(node, "dcr-reg", NULL); 171 + if (reg) { 172 + #ifdef CONFIG_PPC_DCR_NATIVE 173 + snprintf(name, BUS_ID_SIZE, "d%x.%s", 174 + *reg, node->name); 175 + #else /* CONFIG_PPC_DCR_NATIVE */ 176 + addr = of_translate_dcr_address(node, *reg, NULL); 177 + if (addr != OF_BAD_ADDR) { 178 + snprintf(name, BUS_ID_SIZE, 179 + "D%llx.%s", (unsigned long long)addr, 180 + node->name); 181 + return; 182 + } 183 + #endif /* !CONFIG_PPC_DCR_NATIVE */ 184 + } 185 + #endif /* CONFIG_PPC_DCR */ 186 + 187 + /* 188 + * For MMIO, get the physical address 189 + */ 190 + reg = get_property(node, "reg", NULL); 191 + if (reg) { 192 + addr = of_translate_address(node, reg); 193 + if (addr != OF_BAD_ADDR) { 194 + snprintf(name, BUS_ID_SIZE, 195 + "%llx.%s", (unsigned long long)addr, 196 + node->name); 197 + return; 198 + } 199 + } 200 + 201 + /* 202 + * No BusID, use the node name and pray 203 + */ 204 + snprintf(name, BUS_ID_SIZE, "%s", node->name); 205 + } 206 + 207 + struct of_device* of_platform_device_create(struct device_node *np, 208 + const char *bus_id, 209 + struct device *parent) 210 + { 211 + struct of_device *dev; 212 + 213 + dev = kmalloc(sizeof(*dev), GFP_KERNEL); 214 + if (!dev) 215 + return NULL; 216 + memset(dev, 0, sizeof(*dev)); 217 + 218 + dev->node = of_node_get(np); 219 + dev->dma_mask = 0xffffffffUL; 220 + dev->dev.dma_mask = &dev->dma_mask; 221 + dev->dev.parent = parent; 222 + dev->dev.bus = &of_platform_bus_type; 223 + dev->dev.release = of_release_dev; 224 + 225 + if (bus_id) 226 + strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE); 227 + else 228 + of_platform_make_bus_id(dev); 229 + 230 + if (of_device_register(dev) != 0) { 231 + kfree(dev); 232 + return NULL; 233 + } 234 + 235 + return dev; 236 + } 237 + EXPORT_SYMBOL(of_platform_device_create); 238 + 239 + 240 + 241 + /** 242 + * of_platform_bus_create - Create an OF device for a bus node and all its 243 + * children. Optionally recursively instanciate matching busses. 244 + * @bus: device node of the bus to instanciate 245 + * @matches: match table, NULL to use the default, OF_NO_DEEP_PROBE to 246 + * disallow recursive creation of child busses 247 + */ 248 + static int of_platform_bus_create(struct device_node *bus, 249 + struct of_device_id *matches, 250 + struct device *parent) 251 + { 252 + struct device_node *child; 253 + struct of_device *dev; 254 + int rc = 0; 255 + 256 + for (child = NULL; (child = of_get_next_child(bus, child)); ) { 257 + pr_debug(" create child: %s\n", child->full_name); 258 + dev = of_platform_device_create(child, NULL, parent); 259 + if (dev == NULL) 260 + rc = -ENOMEM; 261 + else if (!of_match_node(matches, child)) 262 + continue; 263 + if (rc == 0) { 264 + pr_debug(" and sub busses\n"); 265 + rc = of_platform_bus_create(child, matches, &dev->dev); 266 + } if (rc) { 267 + of_node_put(child); 268 + break; 269 + } 270 + } 271 + return rc; 272 + } 273 + 274 + /** 275 + * of_platform_bus_probe - Probe the device-tree for platform busses 276 + * @root: parent of the first level to probe or NULL for the root of the tree 277 + * @matches: match table, NULL to use the default 278 + * @parent: parent to hook devices from, NULL for toplevel 279 + * 280 + * Note that children of the provided root are not instanciated as devices 281 + * unless the specified root itself matches the bus list and is not NULL. 282 + */ 283 + 284 + int of_platform_bus_probe(struct device_node *root, 285 + struct of_device_id *matches, 286 + struct device *parent) 287 + { 288 + struct device_node *child; 289 + struct of_device *dev; 290 + int rc = 0; 291 + 292 + if (matches == NULL) 293 + matches = of_default_bus_ids; 294 + if (matches == OF_NO_DEEP_PROBE) 295 + return -EINVAL; 296 + if (root == NULL) 297 + root = of_find_node_by_path("/"); 298 + else 299 + of_node_get(root); 300 + 301 + pr_debug("of_platform_bus_probe()\n"); 302 + pr_debug(" starting at: %s\n", root->full_name); 303 + 304 + /* Do a self check of bus type, if there's a match, create 305 + * children 306 + */ 307 + if (of_match_node(matches, root)) { 308 + pr_debug(" root match, create all sub devices\n"); 309 + dev = of_platform_device_create(root, NULL, parent); 310 + if (dev == NULL) { 311 + rc = -ENOMEM; 312 + goto bail; 313 + } 314 + pr_debug(" create all sub busses\n"); 315 + rc = of_platform_bus_create(root, matches, &dev->dev); 316 + goto bail; 317 + } 318 + for (child = NULL; (child = of_get_next_child(root, child)); ) { 319 + if (!of_match_node(matches, child)) 320 + continue; 321 + 322 + pr_debug(" match: %s\n", child->full_name); 323 + dev = of_platform_device_create(child, NULL, parent); 324 + if (dev == NULL) 325 + rc = -ENOMEM; 326 + else 327 + rc = of_platform_bus_create(child, matches, &dev->dev); 328 + if (rc) { 329 + of_node_put(child); 330 + break; 331 + } 332 + } 333 + bail: 334 + of_node_put(root); 335 + return rc; 336 + } 337 + EXPORT_SYMBOL(of_platform_bus_probe); 338 + 339 + static int of_dev_node_match(struct device *dev, void *data) 340 + { 341 + return to_of_device(dev)->node == data; 342 + } 343 + 344 + struct of_device *of_find_device_by_node(struct device_node *np) 345 + { 346 + struct device *dev; 347 + 348 + dev = bus_find_device(&of_platform_bus_type, 349 + NULL, np, of_dev_node_match); 350 + if (dev) 351 + return to_of_device(dev); 352 + return NULL; 353 + } 354 + EXPORT_SYMBOL(of_find_device_by_node); 355 + 356 + static int of_dev_phandle_match(struct device *dev, void *data) 357 + { 358 + phandle *ph = data; 359 + return to_of_device(dev)->node->linux_phandle == *ph; 360 + } 361 + 362 + struct of_device *of_find_device_by_phandle(phandle ph) 363 + { 364 + struct device *dev; 365 + 366 + dev = bus_find_device(&of_platform_bus_type, 367 + NULL, &ph, of_dev_phandle_match); 368 + if (dev) 369 + return to_of_device(dev); 370 + return NULL; 371 + } 372 + EXPORT_SYMBOL(of_find_device_by_phandle);
+1
arch/powerpc/platforms/powermac/setup.c
··· 70 70 #include <asm/pmac_feature.h> 71 71 #include <asm/time.h> 72 72 #include <asm/of_device.h> 73 + #include <asm/of_platform.h> 73 74 #include <asm/mmu_context.h> 74 75 #include <asm/iommu.h> 75 76 #include <asm/smu.h>
+2 -1
drivers/macintosh/smu.c
··· 46 46 #include <asm/abs_addr.h> 47 47 #include <asm/uaccess.h> 48 48 #include <asm/of_device.h> 49 + #include <asm/of_platform.h> 49 50 50 51 #define VERSION "0.7" 51 52 #define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp." ··· 654 653 * I'm a bit too far from figuring out how that works with those 655 654 * new chipsets, but that will come back and bite us 656 655 */ 657 - of_register_driver(&smu_of_platform_driver); 656 + of_register_platform_driver(&smu_of_platform_driver); 658 657 return 0; 659 658 } 660 659
+1 -1
drivers/macintosh/therm_adt746x.c
··· 30 30 #include <asm/io.h> 31 31 #include <asm/system.h> 32 32 #include <asm/sections.h> 33 - #include <asm/of_device.h> 33 + #include <asm/of_platform.h> 34 34 35 35 #undef DEBUG 36 36
+3 -2
drivers/macintosh/therm_pm72.c
··· 129 129 #include <asm/sections.h> 130 130 #include <asm/of_device.h> 131 131 #include <asm/macio.h> 132 + #include <asm/of_platform.h> 132 133 133 134 #include "therm_pm72.h" 134 135 ··· 2237 2236 return -ENODEV; 2238 2237 } 2239 2238 2240 - of_register_driver(&fcu_of_platform_driver); 2239 + of_register_platform_driver(&fcu_of_platform_driver); 2241 2240 2242 2241 return 0; 2243 2242 } 2244 2243 2245 2244 static void __exit therm_pm72_exit(void) 2246 2245 { 2247 - of_unregister_driver(&fcu_of_platform_driver); 2246 + of_unregister_platform_driver(&fcu_of_platform_driver); 2248 2247 2249 2248 if (of_dev) 2250 2249 of_device_unregister(of_dev);
+4 -3
drivers/macintosh/therm_windtunnel.c
··· 36 36 #include <linux/i2c.h> 37 37 #include <linux/slab.h> 38 38 #include <linux/init.h> 39 + 39 40 #include <asm/prom.h> 40 41 #include <asm/machdep.h> 41 42 #include <asm/io.h> 42 43 #include <asm/system.h> 43 44 #include <asm/sections.h> 44 - #include <asm/of_device.h> 45 + #include <asm/of_platform.h> 45 46 #include <asm/macio.h> 46 47 47 48 #define LOG_TEMP 0 /* continously log temperature */ ··· 512 511 return -ENODEV; 513 512 } 514 513 515 - of_register_driver( &therm_of_driver ); 514 + of_register_platform_driver( &therm_of_driver ); 516 515 return 0; 517 516 } 518 517 519 518 static void __exit 520 519 g4fan_exit( void ) 521 520 { 522 - of_unregister_driver( &therm_of_driver ); 521 + of_unregister_platform_driver( &therm_of_driver ); 523 522 524 523 if( x.of_dev ) 525 524 of_device_unregister( x.of_dev );
+3 -2
drivers/video/platinumfb.c
··· 34 34 #include <asm/prom.h> 35 35 #include <asm/pgtable.h> 36 36 #include <asm/of_device.h> 37 + #include <asm/of_platform.h> 37 38 38 39 #include "macmodes.h" 39 40 #include "platinumfb.h" ··· 683 682 return -ENODEV; 684 683 platinumfb_setup(option); 685 684 #endif 686 - of_register_driver(&platinum_driver); 685 + of_register_platform_driver(&platinum_driver); 687 686 688 687 return 0; 689 688 } 690 689 691 690 static void __exit platinumfb_exit(void) 692 691 { 693 - of_unregister_driver(&platinum_driver); 692 + of_unregister_platform_driver(&platinum_driver); 694 693 } 695 694 696 695 MODULE_LICENSE("GPL");
+2 -32
include/asm-powerpc/of_device.h
··· 6 6 #include <linux/mod_devicetable.h> 7 7 #include <asm/prom.h> 8 8 9 - /* 10 - * The of_platform_bus_type is a bus type used by drivers that do not 11 - * attach to a macio or similar bus but still use OF probing 12 - * mechanism 13 - */ 14 - extern struct bus_type of_platform_bus_type; 15 9 16 10 /* 17 11 * The of_device is a kind of "base class" that is a superset of ··· 20 26 }; 21 27 #define to_of_device(d) container_of(d, struct of_device, dev) 22 28 29 + extern const struct of_device_id *of_match_node( 30 + const struct of_device_id *matches, const struct device_node *node); 23 31 extern const struct of_device_id *of_match_device( 24 32 const struct of_device_id *matches, const struct of_device *dev); 25 33 26 34 extern struct of_device *of_dev_get(struct of_device *dev); 27 35 extern void of_dev_put(struct of_device *dev); 28 36 29 - /* 30 - * An of_platform_driver driver is attached to a basic of_device on 31 - * the "platform bus" (of_platform_bus_type) 32 - */ 33 - struct of_platform_driver 34 - { 35 - char *name; 36 - struct of_device_id *match_table; 37 - struct module *owner; 38 - 39 - int (*probe)(struct of_device* dev, const struct of_device_id *match); 40 - int (*remove)(struct of_device* dev); 41 - 42 - int (*suspend)(struct of_device* dev, pm_message_t state); 43 - int (*resume)(struct of_device* dev); 44 - int (*shutdown)(struct of_device* dev); 45 - 46 - struct device_driver driver; 47 - }; 48 - #define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver) 49 - 50 - extern int of_register_driver(struct of_platform_driver *drv); 51 - extern void of_unregister_driver(struct of_platform_driver *drv); 52 37 extern int of_device_register(struct of_device *ofdev); 53 38 extern void of_device_unregister(struct of_device *ofdev); 54 - extern struct of_device *of_platform_device_create(struct device_node *np, 55 - const char *bus_id, 56 - struct device *parent); 57 39 extern void of_release_dev(struct device *dev); 58 40 59 41 #endif /* __KERNEL__ */
+60
include/asm-powerpc/of_platform.h
··· 1 + /* 2 + * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. 3 + * <benh@kernel.crashing.org> 4 + * 5 + * This program is free software; you can redistribute it and/or 6 + * modify it under the terms of the GNU General Public License 7 + * as published by the Free Software Foundation; either version 8 + * 2 of the License, or (at your option) any later version. 9 + * 10 + */ 11 + 12 + #include <asm/of_device.h> 13 + 14 + /* 15 + * The of_platform_bus_type is a bus type used by drivers that do not 16 + * attach to a macio or similar bus but still use OF probing 17 + * mechanism 18 + */ 19 + extern struct bus_type of_platform_bus_type; 20 + 21 + /* 22 + * An of_platform_driver driver is attached to a basic of_device on 23 + * the "platform bus" (of_platform_bus_type) 24 + */ 25 + struct of_platform_driver 26 + { 27 + char *name; 28 + struct of_device_id *match_table; 29 + struct module *owner; 30 + 31 + int (*probe)(struct of_device* dev, 32 + const struct of_device_id *match); 33 + int (*remove)(struct of_device* dev); 34 + 35 + int (*suspend)(struct of_device* dev, pm_message_t state); 36 + int (*resume)(struct of_device* dev); 37 + int (*shutdown)(struct of_device* dev); 38 + 39 + struct device_driver driver; 40 + }; 41 + #define to_of_platform_driver(drv) \ 42 + container_of(drv,struct of_platform_driver, driver) 43 + 44 + /* Platform drivers register/unregister */ 45 + extern int of_register_platform_driver(struct of_platform_driver *drv); 46 + extern void of_unregister_platform_driver(struct of_platform_driver *drv); 47 + 48 + /* Platform devices and busses creation */ 49 + extern struct of_device *of_platform_device_create(struct device_node *np, 50 + const char *bus_id, 51 + struct device *parent); 52 + /* pseudo "matches" value to not do deep probe */ 53 + #define OF_NO_DEEP_PROBE ((struct of_device_id *)-1) 54 + 55 + extern int of_platform_bus_probe(struct device_node *root, 56 + struct of_device_id *matches, 57 + struct device *parent); 58 + 59 + extern struct of_device *of_find_device_by_node(struct device_node *np); 60 + extern struct of_device *of_find_device_by_phandle(phandle ph);