Lines Matching defs:device

3  * device.h - generic, centralized driver model
30 #include <linux/device/bus.h>
31 #include <linux/device/class.h>
32 #include <linux/device/driver.h>
34 #include <asm/device.h>
36 struct device;
51 * struct subsys_interface - interfaces to device functions
52 * @name: name of the device function
55 * @add_dev: device hookup to device function handler
56 * @remove_dev: device hookup to device function handler
67 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68 void (*remove_dev)(struct device *dev, struct subsys_interface *sif);
80 * The type of device, "struct device" is embedded in. A class
83 * This identifies the device type and carries type-specific
91 int (*uevent)(const struct device *dev, struct kobj_uevent_env *env);
92 char *(*devnode)(const struct device *dev, umode_t *mode,
94 void (*release)(struct device *dev);
100 * struct device_attribute - Interface for exporting device attributes.
107 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
109 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
114 * struct dev_ext_attribute - Exported device attribute with extra context.
115 * @attr: Exported device attribute.
123 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
125 ssize_t device_store_ulong(struct device *dev, struct device_attribute *attr,
127 ssize_t device_show_int(struct device *dev, struct device_attribute *attr,
129 ssize_t device_store_int(struct device *dev, struct device_attribute *attr,
131 ssize_t device_show_bool(struct device *dev, struct device_attribute *attr,
133 ssize_t device_store_bool(struct device *dev, struct device_attribute *attr,
135 ssize_t device_show_string(struct device *dev, struct device_attribute *attr,
139 * DEVICE_ATTR - Define a device attribute.
161 * DEVICE_ATTR_PREALLOC - Define a preallocated device attribute.
174 * DEVICE_ATTR_RW - Define a read-write device attribute.
184 * DEVICE_ATTR_ADMIN_RW - Define an admin-only read-write device attribute.
193 * DEVICE_ATTR_RO - Define a readable device attribute.
202 * DEVICE_ATTR_ADMIN_RO - Define an admin-only readable device attribute.
211 * DEVICE_ATTR_WO - Define an admin-only writable device attribute.
220 * DEVICE_ULONG_ATTR - Define a device attribute backed by an unsigned long.
233 * DEVICE_INT_ATTR - Define a device attribute backed by an int.
245 * DEVICE_BOOL_ATTR - Define a device attribute backed by a bool.
257 * DEVICE_STRING_ATTR_RO - Define a device attribute backed by a r/o string.
273 int device_create_file(struct device *device,
275 void device_remove_file(struct device *dev,
277 bool device_remove_file_self(struct device *dev,
279 int __must_check device_create_bin_file(struct device *dev,
281 void device_remove_bin_file(struct device *dev,
284 /* device resource management */
285 typedef void (*dr_release_t)(struct device *dev, void *res);
286 typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
295 void devres_for_each_res(struct device *dev, dr_release_t release,
297 void (*fn)(struct device *, void *, void *),
300 void devres_add(struct device *dev, void *res);
301 void *devres_find(struct device *dev, dr_release_t release,
303 void *devres_get(struct device *dev, void *new_res,
305 void *devres_remove(struct device *dev, dr_release_t release,
307 int devres_destroy(struct device *dev, dr_release_t release,
309 int devres_release(struct device *dev, dr_release_t release,
313 void * __must_check devres_open_group(struct device *dev, void *id, gfp_t gfp);
314 void devres_close_group(struct device *dev, void *id);
315 void devres_remove_group(struct device *dev, void *id);
316 int devres_release_group(struct device *dev, void *id);
318 /* managed devm_k.alloc/kfree for device drivers */
319 void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp) __alloc_size(2);
320 void *devm_krealloc(struct device *dev, void *ptr, size_t size,
322 __printf(3, 0) char *devm_kvasprintf(struct device *dev, gfp_t gfp,
324 __printf(3, 4) char *devm_kasprintf(struct device *dev, gfp_t gfp,
326 static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
330 static inline void *devm_kmalloc_array(struct device *dev,
340 static inline void *devm_kcalloc(struct device *dev,
346 devm_krealloc_array(struct device *dev, void *p, size_t new_n, size_t new_size, gfp_t flags)
356 void devm_kfree(struct device *dev, const void *p);
357 char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc;
358 const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gfp);
359 void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp)
362 unsigned long devm_get_free_pages(struct device *dev,
364 void devm_free_pages(struct device *dev, unsigned long addr);
367 void __iomem *devm_ioremap_resource(struct device *dev,
369 void __iomem *devm_ioremap_resource_wc(struct device *dev,
372 void __iomem *devm_of_iomap(struct device *dev,
378 void __iomem *devm_ioremap_resource(struct device *dev,
385 void __iomem *devm_ioremap_resource_wc(struct device *dev,
392 void __iomem *devm_of_iomap(struct device *dev,
402 void devm_remove_action(struct device *dev, void (*action)(void *), void *data);
403 void devm_release_action(struct device *dev, void (*action)(void *), void *data);
405 int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
409 static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
438 void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
440 void devm_free_percpu(struct device *dev, void __percpu *pdata);
496 * @DL_DEV_NO_DRIVER: There is no driver attached to the device.
498 * @DL_DEV_DRIVER_BOUND: The driver has been bound to the device.
499 * @DL_DEV_UNBINDING: The driver is unbinding from the device.
509 * enum device_removable - Whether the device is removable. The criteria for a
510 * device to be classified as removable is determined by its subsystem or bus.
512 * device (default).
525 * struct dev_links_info - Device data related to device links.
540 * @domain: The MSI interrupt domain associated to the device
541 * @data: Pointer to MSI device data
552 * system's housing the device connection point resides on.
559 * @DEVICE_PANEL_UNKNOWN: The panel with device connection point is unknown.
573 * position of the device connection point on the panel surface.
586 * position of the device connection point on the panel surface.
599 * of the device connection point.
600 * @panel: Panel surface of the system's housing that the device connection
602 * @vertical_position: Vertical position of the device connection point within
604 * @horizontal_position: Horizontal position of the device connection point
606 * @dock: Set if the device connection point resides in a docking station or
608 * @lid: Set if this device connection point resides on the lid of laptop
620 * struct device - The basic device structure
621 * @parent: The device's "parent" device, the device to which it is attached.
622 * In most cases, a parent device is some sort of bus or host
623 * controller. If parent is NULL, the device, is a top-level device,
625 * @p: Holds the private data of the driver core portions of the device.
628 * @init_name: Initial name of the device.
629 * @type: The type of device.
630 * This identifies the device type and carries type-specific
633 * @bus: Type of bus device is on.
635 * @platform_data: Platform data specific to the device.
644 * @links: Links to suppliers and consumers of this device.
645 * @power: For device power management.
650 * @em_pd: device's energy model performance domain
651 * @pins: For device pin management.
654 * @numa_node: NUMA node this device is close to.
655 * @dma_ops: DMA mapping operations for this device.
656 * @dma_mask: Dma mask (if dma'ble device).
661 * DMA limit than the device itself supports.
665 * @dma_pools: Dma pools (if dma'ble device).
671 * @dma_uses_io_tlb: %true if device has used the software IO TLB.
673 * @of_node: Associated device tree node.
674 * @fwnode: Associated device node supplied by platform firmware.
676 * @id: device instance
677 * @devres_lock: Spinlock to protect the resource of the device.
678 * @devres_head: The resources list of the device.
679 * @class: The class of the device.
681 * @release: Callback to free the device after all references have
683 * device (i.e. the bus driver that discovered the device).
684 * @iommu_group: IOMMU group the device belongs to.
685 * @iommu: Per device generic IOMMU runtime data
686 * @physical_location: Describes physical location of the device connection
688 * @removable: Whether the device can be removed from the system. This
690 * the device.
692 * @offline_disabled: If set, the device is permanently online.
694 * @of_node_reused: Set if the device-tree node is shared with an ancestor
695 * device.
696 * @state_synced: The hardware state of this device has been synced to match
697 * the software state of this device by calling the driver/bus
699 * @can_match: The device has matched with a driver at least once or it is in
702 * @dma_coherent: this particular device is dma coherent, even if the
711 * At the lowest level, every device in a Linux system is represented by an
712 * instance of struct device. The device structure contains the information
713 * that the device model core needs to model the system. Most subsystems,
715 * result, it is rare for devices to be represented by bare device structures;
717 * a higher-level representation of the device.
719 struct device {
721 struct device *parent;
725 const char *init_name; /* initial name of the device */
728 const struct bus_type *bus; /* type of bus device is on */
730 device */
731 void *platform_data; /* Platform specific data, device
754 u64 *dma_mask; /* dma mask (if dma'able device) */
786 struct device_node *of_node; /* associated device tree node */
787 struct fwnode_handle *fwnode; /* firmware device node */
790 int numa_node; /* NUMA node this device is close to */
793 u32 id; /* device instance */
801 void (*release)(struct device *dev);
829 * @supplier: The device on the supplier end of the link.
830 * @s_node: Hook to the supplier device's list of links to consumers.
831 * @consumer: The device on the consumer end of the link.
832 * @c_node: Hook to the consumer device's list of links to suppliers.
833 * @link_dev: device used to expose link details in sysfs
836 * @rpm_active: Whether or not the consumer device is runtime-PM-active.
842 struct device *supplier;
844 struct device *consumer;
846 struct device link_dev;
855 #define kobj_to_dev(__kobj) container_of_const(__kobj, struct device, kobj)
858 * device_iommu_mapped - Returns true when the device DMA is translated
862 static inline bool device_iommu_mapped(struct device *dev)
867 /* Get the wakeup routines, which depend on struct device */
871 * dev_name - Return a device's name.
873 * Return: The kobject name of the device, or its initial name if unavailable.
875 static inline const char *dev_name(const struct device *dev)
885 * dev_bus_name - Return a device's bus/class name, if at all possible
886 * @dev: struct device to get the bus/class name of
888 * Will return the name of the bus/class the device is attached to. If it is
891 static inline const char *dev_bus_name(const struct device *dev)
896 __printf(2, 3) int dev_set_name(struct device *dev, const char *name, ...);
899 static inline int dev_to_node(struct device *dev)
903 static inline void set_dev_node(struct device *dev, int node)
908 static inline int dev_to_node(struct device *dev)
912 static inline void set_dev_node(struct device *dev, int node)
917 static inline struct irq_domain *dev_get_msi_domain(const struct device *dev)
926 static inline void dev_set_msi_domain(struct device *dev, struct irq_domain *d)
933 static inline void *dev_get_drvdata(const struct device *dev)
938 static inline void dev_set_drvdata(struct device *dev, void *data)
943 static inline struct pm_subsys_data *dev_to_psd(struct device *dev)
948 static inline unsigned int dev_get_uevent_suppress(const struct device *dev)
953 static inline void dev_set_uevent_suppress(struct device *dev, int val)
958 static inline int device_is_registered(struct device *dev)
963 static inline void device_enable_async_suspend(struct device *dev)
969 static inline void device_disable_async_suspend(struct device *dev)
975 static inline bool device_async_suspend_enabled(struct device *dev)
980 static inline bool device_pm_not_required(struct device *dev)
985 static inline void device_set_pm_not_required(struct device *dev)
990 static inline void dev_pm_syscore_device(struct device *dev, bool val)
997 static inline void dev_pm_set_driver_flags(struct device *dev, u32 flags)
1002 static inline bool dev_pm_test_driver_flags(struct device *dev, u32 flags)
1007 static inline void device_lock(struct device *dev)
1012 static inline int device_lock_interruptible(struct device *dev)
1017 static inline int device_trylock(struct device *dev)
1022 static inline void device_unlock(struct device *dev)
1027 DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T))
1029 static inline void device_lock_assert(struct device *dev)
1034 static inline struct device_node *dev_of_node(struct device *dev)
1041 static inline bool dev_has_sync_state(struct device *dev)
1052 static inline void dev_set_removable(struct device *dev,
1058 static inline bool dev_is_removable(struct device *dev)
1063 static inline bool dev_removable_is_valid(struct device *dev)
1071 int __must_check device_register(struct device *dev);
1072 void device_unregister(struct device *dev);
1073 void device_initialize(struct device *dev);
1074 int __must_check device_add(struct device *dev);
1075 void device_del(struct device *dev);
1077 DEFINE_FREE(device_del, struct device *, if (_T) device_del(_T))
1079 int device_for_each_child(struct device *dev, void *data,
1080 int (*fn)(struct device *dev, void *data));
1081 int device_for_each_child_reverse(struct device *dev, void *data,
1082 int (*fn)(struct device *dev, void *data));
1083 struct device *device_find_child(struct device *dev, void *data,
1084 int (*match)(struct device *dev, void *data));
1085 struct device *device_find_child_by_name(struct device *parent,
1087 struct device *device_find_any_child(struct device *parent);
1089 int device_rename(struct device *dev, const char *new_name);
1090 int device_move(struct device *dev, struct device *new_parent,
1092 int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);
1094 static inline bool device_supports_offline(struct device *dev)
1101 struct device *__d2 __maybe_unused = dev; \
1106 * device_lock_set_class - Specify a temporary lock class while a device
1108 * @dev: device to modify
1118 struct device *__d = dev; \
1129 * device_lock_reset_class - Return a device to the default lockdep novalidate state
1130 * @dev: device to modify
1137 struct device *__d __maybe_unused = dev; \
1145 int device_offline(struct device *dev);
1146 int device_online(struct device *dev);
1147 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
1148 void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
1149 void device_set_of_node_from_dev(struct device *dev, const struct device *dev2);
1150 void device_set_node(struct device *dev, struct fwnode_handle *fwnode);
1152 static inline int dev_num_vf(struct device *dev)
1160 * Root device objects for grouping under /sys/devices
1162 struct device *__root_device_register(const char *name, struct module *owner);
1168 void root_device_unregister(struct device *root);
1170 static inline void *dev_get_platdata(const struct device *dev)
1176 * Manual binding of a device to driver. See drivers/base/bus.c
1180 struct device *dev);
1181 int __must_check device_bind_driver(struct device *dev);
1182 void device_release_driver(struct device *dev);
1183 int __must_check device_attach(struct device *dev);
1185 void device_initial_probe(struct device *dev);
1186 int __must_check device_reprobe(struct device *dev);
1188 bool device_is_bound(struct device *dev);
1193 __printf(5, 6) struct device *
1194 device_create(const struct class *cls, struct device *parent, dev_t devt,
1196 __printf(6, 7) struct device *
1197 device_create_with_groups(const struct class *cls, struct device *parent, dev_t devt,
1202 int __must_check device_add_groups(struct device *dev,
1204 void device_remove_groups(struct device *dev,
1207 static inline int __must_check device_add_group(struct device *dev,
1215 static inline void device_remove_group(struct device *dev,
1223 int __must_check devm_device_add_groups(struct device *dev,
1225 int __must_check devm_device_add_group(struct device *dev,
1229 * get_device - atomically increment the reference count for the device.
1232 struct device *get_device(struct device *dev);
1233 void put_device(struct device *dev);
1235 DEFINE_FREE(put_device, struct device *, if (_T) put_device(_T))
1237 bool kill_device(struct device *dev);
1249 const char *dev_driver_string(const struct device *dev);
1252 struct device_link *device_link_add(struct device *consumer,
1253 struct device *supplier, u32 flags);
1255 void device_link_remove(void *consumer, struct device *supplier);