Subversion Repositories Kolibri OS

Rev

Rev 6102 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * device.h - generic, centralized driver model
  3.  *
  4.  * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
  5.  * Copyright (c) 2004-2009 Greg Kroah-Hartman <gregkh@suse.de>
  6.  * Copyright (c) 2008-2009 Novell Inc.
  7.  *
  8.  * This file is released under the GPLv2
  9.  *
  10.  * See Documentation/driver-model/ for more information.
  11.  */
  12.  
  13. #ifndef _DEVICE_H_
  14. #define _DEVICE_H_
  15.  
  16. #include <linux/list.h>
  17. #include <linux/compiler.h>
  18. #include <linux/types.h>
  19. #include <linux/mutex.h>
  20. struct device;
  21. enum probe_type {
  22.         PROBE_DEFAULT_STRATEGY,
  23.         PROBE_PREFER_ASYNCHRONOUS,
  24.         PROBE_FORCE_SYNCHRONOUS,
  25. };
  26.  
  27. struct device_driver {
  28.         const char              *name;
  29.         const char              *mod_name;      /* used for built-in modules */
  30.  
  31.         bool suppress_bind_attrs;       /* disables bind/unbind via sysfs */
  32.         enum probe_type probe_type;
  33. };
  34.  
  35. struct device {
  36.         struct device           *parent;
  37.  
  38.         const char              *init_name; /* initial name of the device */
  39.         struct device_driver *driver;   /* which driver has allocated this
  40.                                            device */
  41.         void            *platform_data; /* Platform specific data, device
  42.                                            core doesn't touch it */
  43.         void            *driver_data;   /* Driver data, set and get with
  44.                                            dev_set/get_drvdata */
  45. #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
  46.         struct irq_domain       *msi_domain;
  47. #endif
  48. #ifdef CONFIG_PINCTRL
  49.         struct dev_pin_info     *pins;
  50. #endif
  51. #ifdef CONFIG_GENERIC_MSI_IRQ
  52.         struct list_head        msi_list;
  53. #endif
  54.  
  55. #ifdef CONFIG_NUMA
  56.         int             numa_node;      /* NUMA node this device is close to */
  57. #endif
  58. #ifdef CONFIG_DMA_CMA
  59.         struct cma *cma_area;           /* contiguous memory area for dma
  60.                                            allocations */
  61. #endif
  62. };
  63.  
  64. extern __printf(2, 3)
  65. int dev_set_name(struct device *dev, const char *name, ...);
  66.  
  67. #ifdef CONFIG_NUMA
  68. static inline int dev_to_node(struct device *dev)
  69. {
  70.         return dev->numa_node;
  71. }
  72. static inline void set_dev_node(struct device *dev, int node)
  73. {
  74.         dev->numa_node = node;
  75. }
  76. #else
  77. static inline int dev_to_node(struct device *dev)
  78. {
  79.         return -1;
  80. }
  81. static inline void set_dev_node(struct device *dev, int node)
  82. {
  83. }
  84. #endif
  85.  
  86.  
  87. static inline void *dev_get_drvdata(const struct device *dev)
  88. {
  89.         return dev->driver_data;
  90. }
  91.  
  92. static inline void dev_set_drvdata(struct device *dev, void *data)
  93. {
  94.         dev->driver_data = data;
  95. }
  96.  
  97.  
  98.  
  99. #endif /* _DEVICE_H_ */
  100.