diff options
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 9d4f6a963936..49ab53ce92dc 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/pm.h> | 21 | #include <linux/pm.h> |
22 | #include <asm/semaphore.h> | 22 | #include <asm/semaphore.h> |
23 | #include <asm/atomic.h> | 23 | #include <asm/atomic.h> |
24 | #include <asm/device.h> | ||
24 | 25 | ||
25 | #define DEVICE_NAME_SIZE 50 | 26 | #define DEVICE_NAME_SIZE 50 |
26 | #define DEVICE_NAME_HALF __stringify(20) /* Less than half to accommodate slop */ | 27 | #define DEVICE_NAME_HALF __stringify(20) /* Less than half to accommodate slop */ |
@@ -42,6 +43,8 @@ struct bus_type { | |||
42 | struct klist klist_devices; | 43 | struct klist klist_devices; |
43 | struct klist klist_drivers; | 44 | struct klist klist_drivers; |
44 | 45 | ||
46 | struct blocking_notifier_head bus_notifier; | ||
47 | |||
45 | struct bus_attribute * bus_attrs; | 48 | struct bus_attribute * bus_attrs; |
46 | struct device_attribute * dev_attrs; | 49 | struct device_attribute * dev_attrs; |
47 | struct driver_attribute * drv_attrs; | 50 | struct driver_attribute * drv_attrs; |
@@ -75,6 +78,29 @@ int __must_check bus_for_each_drv(struct bus_type *bus, | |||
75 | struct device_driver *start, void *data, | 78 | struct device_driver *start, void *data, |
76 | int (*fn)(struct device_driver *, void *)); | 79 | int (*fn)(struct device_driver *, void *)); |
77 | 80 | ||
81 | /* | ||
82 | * Bus notifiers: Get notified of addition/removal of devices | ||
83 | * and binding/unbinding of drivers to devices. | ||
84 | * In the long run, it should be a replacement for the platform | ||
85 | * notify hooks. | ||
86 | */ | ||
87 | struct notifier_block; | ||
88 | |||
89 | extern int bus_register_notifier(struct bus_type *bus, | ||
90 | struct notifier_block *nb); | ||
91 | extern int bus_unregister_notifier(struct bus_type *bus, | ||
92 | struct notifier_block *nb); | ||
93 | |||
94 | /* All 4 notifers below get called with the target struct device * | ||
95 | * as an argument. Note that those functions are likely to be called | ||
96 | * with the device semaphore held in the core, so be careful. | ||
97 | */ | ||
98 | #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */ | ||
99 | #define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */ | ||
100 | #define BUS_NOTIFY_BOUND_DRIVER 0x00000003 /* driver bound to device */ | ||
101 | #define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be | ||
102 | unbound */ | ||
103 | |||
78 | /* driverfs interface for exporting bus attributes */ | 104 | /* driverfs interface for exporting bus attributes */ |
79 | 105 | ||
80 | struct bus_attribute { | 106 | struct bus_attribute { |
@@ -343,10 +369,11 @@ struct device { | |||
343 | void *driver_data; /* data private to the driver */ | 369 | void *driver_data; /* data private to the driver */ |
344 | void *platform_data; /* Platform specific data, device | 370 | void *platform_data; /* Platform specific data, device |
345 | core doesn't touch it */ | 371 | core doesn't touch it */ |
346 | void *firmware_data; /* Firmware specific data (e.g. ACPI, | ||
347 | BIOS data),reserved for device core*/ | ||
348 | struct dev_pm_info power; | 372 | struct dev_pm_info power; |
349 | 373 | ||
374 | #ifdef CONFIG_NUMA | ||
375 | int numa_node; /* NUMA node this device is close to */ | ||
376 | #endif | ||
350 | u64 *dma_mask; /* dma mask (if dma'able device) */ | 377 | u64 *dma_mask; /* dma mask (if dma'able device) */ |
351 | u64 coherent_dma_mask;/* Like dma_mask, but for | 378 | u64 coherent_dma_mask;/* Like dma_mask, but for |
352 | alloc_coherent mappings as | 379 | alloc_coherent mappings as |
@@ -358,6 +385,8 @@ struct device { | |||
358 | 385 | ||
359 | struct dma_coherent_mem *dma_mem; /* internal for coherent mem | 386 | struct dma_coherent_mem *dma_mem; /* internal for coherent mem |
360 | override */ | 387 | override */ |
388 | /* arch specific additions */ | ||
389 | struct dev_archdata archdata; | ||
361 | 390 | ||
362 | /* class_device migration path */ | 391 | /* class_device migration path */ |
363 | struct list_head node; | 392 | struct list_head node; |
@@ -368,6 +397,25 @@ struct device { | |||
368 | void (*release)(struct device * dev); | 397 | void (*release)(struct device * dev); |
369 | }; | 398 | }; |
370 | 399 | ||
400 | #ifdef CONFIG_NUMA | ||
401 | static inline int dev_to_node(struct device *dev) | ||
402 | { | ||
403 | return dev->numa_node; | ||
404 | } | ||
405 | static inline void set_dev_node(struct device *dev, int node) | ||
406 | { | ||
407 | dev->numa_node = node; | ||
408 | } | ||
409 | #else | ||
410 | static inline int dev_to_node(struct device *dev) | ||
411 | { | ||
412 | return -1; | ||
413 | } | ||
414 | static inline void set_dev_node(struct device *dev, int node) | ||
415 | { | ||
416 | } | ||
417 | #endif | ||
418 | |||
371 | static inline void * | 419 | static inline void * |
372 | dev_get_drvdata (struct device *dev) | 420 | dev_get_drvdata (struct device *dev) |
373 | { | 421 | { |
@@ -395,7 +443,10 @@ extern int __must_check device_add(struct device * dev); | |||
395 | extern void device_del(struct device * dev); | 443 | extern void device_del(struct device * dev); |
396 | extern int device_for_each_child(struct device *, void *, | 444 | extern int device_for_each_child(struct device *, void *, |
397 | int (*fn)(struct device *, void *)); | 445 | int (*fn)(struct device *, void *)); |
446 | extern struct device *device_find_child(struct device *, void *data, | ||
447 | int (*match)(struct device *, void *)); | ||
398 | extern int device_rename(struct device *dev, char *new_name); | 448 | extern int device_rename(struct device *dev, char *new_name); |
449 | extern int device_move(struct device *dev, struct device *new_parent); | ||
399 | 450 | ||
400 | /* | 451 | /* |
401 | * Manual binding of a device to driver. See drivers/base/bus.c | 452 | * Manual binding of a device to driver. See drivers/base/bus.c |
@@ -415,8 +466,6 @@ extern struct device *device_create(struct class *cls, struct device *parent, | |||
415 | __attribute__((format(printf,4,5))); | 466 | __attribute__((format(printf,4,5))); |
416 | extern void device_destroy(struct class *cls, dev_t devt); | 467 | extern void device_destroy(struct class *cls, dev_t devt); |
417 | 468 | ||
418 | extern int virtual_device_parent(struct device *dev); | ||
419 | |||
420 | /* | 469 | /* |
421 | * Platform "fixup" functions - allow the platform to have their say | 470 | * Platform "fixup" functions - allow the platform to have their say |
422 | * about devices and actions that the general device layer doesn't | 471 | * about devices and actions that the general device layer doesn't |