Changeset 679 for GPL/trunk/include/linux/device.h
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-linux-3.2.102 (added) merged: 611-614 /GPL/branches/uniaud32-next (added) merged: 615-678
- Property svn:mergeinfo changed
-
GPL/trunk/include/linux/device.h
r463 r679 1 /* $Id: pm.h,v 1.1.1.1 2003/07/02 13:57:00 eleph Exp $ */2 3 1 #ifndef _LINUX_DEVICE_H 4 2 #define _LINUX_DEVICE_H 3 4 #include <linux/types.h> 5 #include <linux/kobject.h> 5 6 #include <linux/pm.h> 7 #include <linux/sysfs.h> 8 #include <linux/lockdep.h> 9 #include <linux/overflow.h> 10 11 struct device; 12 struct device_private; 13 struct device_driver; 14 struct driver_private; 15 struct class; 16 struct subsys_private; 17 struct bus_type; 18 struct device_node; 19 20 struct bus_attribute { 21 struct attribute attr; 22 ssize_t (*show)(struct bus_type *bus, char *buf); 23 ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count); 24 }; 25 26 /* 27 * The type of device, "struct device" is embedded in. A class 28 * or bus can contain devices of different types 29 * like "partitions" and "disks", "mouse" and "event". 30 * This identifies the device type and carries type-specific 31 * information, equivalent to the kobj_type of a kobject. 32 * If "name" is specified, the uevent will contain it in 33 * the DEVTYPE variable. 34 */ 35 struct device_type { 36 const char *name; 37 const struct attribute_group **groups; 38 int (*uevent)(struct device *dev, struct kobj_uevent_env *env); 39 /* char *(*devnode)(struct device *dev, umode_t *mode, 40 kuid_t *uid, kgid_t *gid);*/ 41 void (*release)(struct device *dev); 42 43 const struct dev_pm_ops *pm; 44 }; 45 46 typedef struct device { 47 struct pci_dev *pci; /* for PCI and PCI-SG types */ 48 struct device * parent; 49 struct device_private *p; 50 struct bus_type * bus; /* type of bus device is on */ 51 struct kobject kobj; 52 const char *init_name; /* initial name of the device */ 53 const struct device_type *type; 6 54 #if 0 7 struct device { 8 void *private_data; 9 void *platform_data; 10 11 struct device_driver *driver; 12 struct pm_dev *pm_dev; 13 char bus_id[20]; 14 }; 55 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 15 56 #endif 57 dev_t devt; /* dev_t, creates the sysfs "dev" */ 58 void (*release)(struct device * dev); 59 unsigned int flags; /* GFP_XXX for continous and ISA types */ 60 struct semaphore mutex; /* mutex to synchronize calls to 61 * its driver. 62 */ 63 #ifdef CONFIG_SBUS 64 struct sbus_dev *sbus; /* for SBUS type */ 65 #endif 66 void *private_data; 67 void *platform_data; 68 struct dev_pm_info power; 69 struct list_head dma_pools; /* dma pools (if dma'ble) */ 70 struct device_driver *driver; 71 struct pm_dev *pm_dev; 72 char bus_id[20]; 73 struct class *class; 74 spinlock_t devres_lock; 75 struct list_head devres_head; 76 const struct attribute_group **groups; /* optional groups */ 77 struct dma_map_ops *dma_ops; 78 u64 *dma_mask; /* dma mask (if dma'able device) */ 79 u64 coherent_dma_mask; /* Like dma_mask, but for 80 alloc_coherent mappings as 81 not all hardware supports 82 64 bit addresses for consistent 83 allocations such descriptors. */ 84 struct device_node *of_node; /* associated device tree node */ 85 } device; 86 87 static inline struct device *kobj_to_dev(struct kobject *kobj) 88 { 89 return container_of(kobj, struct device, kobj); 90 } 91 92 static inline const char *dev_name(const struct device *dev) 93 { 94 /* Use the init name until the kobject becomes available */ 95 if (dev->init_name) 96 return dev->init_name; 97 98 return kobject_name(&dev->kobj); 99 } 16 100 17 101 struct bus_type { 18 int not_used; 19 }; 20 21 struct device_driver { 22 const char *name; 23 struct bus_type *bus; 24 struct module *owner; 102 const char *name; 103 const char *dev_name; 104 int (*match)(struct device *dev, struct device_driver *drv); 105 int (*uevent)(struct device *dev, struct kobj_uevent_env *env); 25 106 int (*probe)(struct device *dev); 26 107 int (*remove)(struct device *dev); 27 void (*shutdown)(struct device *dev); 108 struct subsys_private *p; 109 struct lock_class_key lock_key; 110 }; 111 112 struct device_driver { 113 const char *name; 114 struct bus_type *bus; 115 116 struct module *owner; 117 const char *mod_name; /* used for built-in modules */ 118 119 bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ 120 121 const struct of_device_id *of_match_table; 122 123 int (*probe) (struct device *dev); 124 int (*remove) (struct device *dev); 125 void (*shutdown) (struct device *dev); 126 int (*suspend) (struct device *dev, u32 state); 127 int (*resume) (struct device *dev); 128 const struct attribute_group **groups; 129 130 const struct dev_pm_ops *pm; 131 132 struct driver_private *p; 133 }; 134 135 struct device_attribute { 136 struct attribute attr; 137 ssize_t (*show)(struct device *dev, struct device_attribute *attr, 138 char *buf); 139 ssize_t (*store)(struct device *dev, struct device_attribute *attr, 140 const char *buf, size_t count); 141 }; 142 143 extern int __must_check driver_register(struct device_driver *drv); 144 extern void driver_unregister(struct device_driver *drv); 145 extern struct device_driver *driver_find(const char *name, 146 struct bus_type *bus); 147 148 #define dev_set_drvdata(dev,ptr) ((dev)->private_data = (ptr)) 149 #define dev_get_drvdata(dev) (dev)->private_data 150 151 #define MODULE_ALIAS_CHARDEV_MAJOR(x) 152 153 #define dev_dbg_ratelimited dev_dbg 154 #define dev_emerg dev_dbg 155 #define dev_crit dev_dbg 156 #define dev_alert dev_dbg 157 #define dev_err dev_dbg 158 #define dev_warn dev_dbg 159 #define dev_notice dev_dbg 160 #define dev_info dev_dbg 161 162 #define dev_err_ratelimited dev_err 163 164 #define DEVICE_ATTR_RO(_name) \ 165 struct device_attribute dev_attr_##_name = __ATTR_RO(_name) 166 167 int dev_dbg(const struct device *dev, const char *fmt, ...); 168 169 170 171 /* 172 * get_device - atomically increment the reference count for the device. 173 * 174 */ 175 extern struct device *get_device(struct device *dev); 176 extern void put_device(struct device *dev); 177 178 static inline int device_add(struct device *dev) { return 0; } 179 static inline void device_del(struct device *dev) { } 180 extern void device_initialize(struct device *dev); 181 extern int dev_set_name(struct device *dev, const char *name, ...); 182 183 184 static inline int device_is_registered(struct device *dev) 185 { 186 return dev->kobj.state_in_sysfs; 187 } 188 189 static inline void device_enable_async_suspend(struct device *dev) 190 { 191 if (!dev->power.is_prepared) 192 dev->power.async_suspend = 1; 193 } 194 195 extern int __must_check bus_register(struct bus_type *bus); 196 197 static inline void bus_unregister(struct bus_type *bus) {} 198 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, 199 int (*fn)(struct device *dev, void *data)); 200 201 static inline void device_lock(struct device *dev) 202 { 203 mutex_lock(&dev->mutex); 204 } 205 206 static inline void device_unlock(struct device *dev) 207 { 208 mutex_unlock(&dev->mutex); 209 } 210 211 extern int device_attach(struct device *dev); 212 //static inline int device_attach(struct device *dev) {return 0;} 213 extern void devres_add(struct device *dev, void *res); 214 extern int driver_attach(struct device_driver *drv); 215 216 /* device resource management */ 217 typedef void (*dr_release_t)(struct device *dev, void *res); 218 typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data); 219 220 extern void *devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, 221 int nid); 222 #define NUMA_NO_NODE (-1) 223 static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp) 224 { 225 return devres_alloc_node(release, size, gfp, NUMA_NO_NODE); 226 } 227 228 /** 229 * struct class - device classes 230 * @name: Name of the class. 231 * @owner: The module owner. 232 * @class_attrs: Default attributes of this class. 233 * @dev_attrs: Default attributes of the devices belong to the class. 234 * @dev_bin_attrs: Default binary attributes of the devices belong to the class. 235 * @dev_kobj: The kobject that represents this class and links it into the hierarchy. 236 * @dev_uevent: Called when a device is added, removed from this class, or a 237 * few other things that generate uevents to add the environment 238 * variables. 239 * @devnode: Callback to provide the devtmpfs. 240 * @class_release: Called to release this class. 241 * @dev_release: Called to release the device. 242 * @suspend: Used to put the device to sleep mode, usually to a low power 243 * state. 244 * @resume: Used to bring the device from the sleep mode. 245 * @ns_type: Callbacks so sysfs can detemine namespaces. 246 * @namespace: Namespace of the device belongs to this class. 247 * @pm: The default device power management operations of this class. 248 * @p: The private data of the driver core, no one other than the 249 * driver core can touch this. 250 * 251 * A class is a higher-level view of a device that abstracts out low-level 252 * implementation details. Drivers may see a SCSI disk or an ATA disk, but, 253 * at the class level, they are all simply disks. Classes allow user space 254 * to work with devices based on what they do, rather than how they are 255 * connected or how they work. 256 */ 257 struct class { 258 const char *name; 259 struct module *owner; 260 261 struct class_attribute *class_attrs; 262 struct device_attribute *dev_attrs; 263 struct bin_attribute *dev_bin_attrs; 264 struct kobject *dev_kobj; 265 266 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); 267 char *(*devnode)(struct device *dev, mode_t *mode); 268 269 void (*class_release)(struct class *class); 270 void (*dev_release)(struct device *dev); 271 28 272 int (*suspend)(struct device *dev, pm_message_t state); 29 273 int (*resume)(struct device *dev); 30 struct list_head list; 31 struct list_head device_list; 32 }; 33 34 struct device_attribute { 35 int not_used2; 36 }; 37 38 int snd_compat_driver_register(struct device_driver *driver); 39 void snd_compat_driver_unregister(struct device_driver *driver); 40 41 #define driver_register snd_compat_driver_register 42 #define driver_unregister snd_compat_driver_unregister 43 #define dev_set_drvdata(dev,ptr) ((dev)->private_data = (ptr)) 44 #define dev_get_drvdata(dev) (dev)->private_data 45 46 #define MODULE_ALIAS_CHARDEV_MAJOR(x) 274 275 const struct kobj_ns_type_operations *ns_type; 276 const void *(*namespace)(struct device *dev); 277 278 const struct dev_pm_ops *pm; 279 280 struct subsys_private *p; 281 }; 282 283 extern int __must_check device_bind_driver(struct device *dev); 284 int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, 285 void *data, int (*fn)(struct device_driver *, void *)); 286 extern void devres_free(void *res); 287 extern void *devres_find(struct device *dev, dr_release_t release, 288 dr_match_t match, void *match_data); 289 290 /* debugging and troubleshooting/diagnostic helpers. */ 291 extern const char *dev_driver_string(const struct device *dev); 47 292 48 293 #endif /* _LINUX_DEVICE_H */
Note:
See TracChangeset
for help on using the changeset viewer.