aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/device.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h59
1 files changed, 55 insertions, 4 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 9d4f6a963936..f44247fe8135 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 */
87struct notifier_block;
88
89extern int bus_register_notifier(struct bus_type *bus,
90 struct notifier_block *nb);
91extern 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
80struct bus_attribute { 106struct 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
401static inline int dev_to_node(struct device *dev)
402{
403 return dev->numa_node;
404}
405static inline void set_dev_node(struct device *dev, int node)
406{
407 dev->numa_node = node;
408}
409#else
410static inline int dev_to_node(struct device *dev)
411{
412 return -1;
413}
414static inline void set_dev_node(struct device *dev, int node)
415{
416}
417#endif
418
371static inline void * 419static inline void *
372dev_get_drvdata (struct device *dev) 420dev_get_drvdata (struct device *dev)
373{ 421{
@@ -385,6 +433,8 @@ static inline int device_is_registered(struct device *dev)
385 return dev->is_registered; 433 return dev->is_registered;
386} 434}
387 435
436void driver_init(void);
437
388/* 438/*
389 * High level routines for use by the bus drivers 439 * High level routines for use by the bus drivers
390 */ 440 */
@@ -395,7 +445,10 @@ extern int __must_check device_add(struct device * dev);
395extern void device_del(struct device * dev); 445extern void device_del(struct device * dev);
396extern int device_for_each_child(struct device *, void *, 446extern int device_for_each_child(struct device *, void *,
397 int (*fn)(struct device *, void *)); 447 int (*fn)(struct device *, void *));
448extern struct device *device_find_child(struct device *, void *data,
449 int (*match)(struct device *, void *));
398extern int device_rename(struct device *dev, char *new_name); 450extern int device_rename(struct device *dev, char *new_name);
451extern int device_move(struct device *dev, struct device *new_parent);
399 452
400/* 453/*
401 * Manual binding of a device to driver. See drivers/base/bus.c 454 * Manual binding of a device to driver. See drivers/base/bus.c
@@ -415,8 +468,6 @@ extern struct device *device_create(struct class *cls, struct device *parent,
415 __attribute__((format(printf,4,5))); 468 __attribute__((format(printf,4,5)));
416extern void device_destroy(struct class *cls, dev_t devt); 469extern void device_destroy(struct class *cls, dev_t devt);
417 470
418extern int virtual_device_parent(struct device *dev);
419
420/* 471/*
421 * Platform "fixup" functions - allow the platform to have their say 472 * Platform "fixup" functions - allow the platform to have their say
422 * about devices and actions that the general device layer doesn't 473 * about devices and actions that the general device layer doesn't