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