Lines Matching full: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) in devm_kzalloc()
330 static inline void *devm_kmalloc_array(struct device *dev, in devm_kmalloc_array()
340 static inline void *devm_kcalloc(struct device *dev, in devm_kcalloc()
346 devm_krealloc_array(struct device *dev, void *p, size_t new_n, size_t new_size, gfp_t flags) in devm_krealloc_array()
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, in devm_ioremap_resource()
385 void __iomem *devm_ioremap_resource_wc(struct device *dev, in devm_ioremap_resource_wc()
392 void __iomem *devm_of_iomap(struct device *dev, in devm_of_iomap()
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 *), in __devm_add_action_or_reset()
425 * @dev: Device to allocate per-cpu memory for
438 void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
440 void devm_free_percpu(struct device *dev, void __percpu *pdata);
453 * enum device_link_state - Device link states.
471 * Device link flags.
495 * enum dl_dev_state - Device driver presence tracking information.
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).
513 * @DEVICE_REMOVABLE_UNKNOWN: Device location is Unknown.
514 * @DEVICE_FIXED: Device is not removable by the user.
515 * @DEVICE_REMOVABLE: Device is removable by the user.
525 * struct dev_links_info - Device data related to device links.
539 * struct dev_msi_info - Device data related to MSI
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.
553 * @DEVICE_PANEL_TOP: Device connection point is on the top panel.
554 * @DEVICE_PANEL_BOTTOM: Device connection point is on the bottom panel.
555 * @DEVICE_PANEL_LEFT: Device connection point is on the left panel.
556 * @DEVICE_PANEL_RIGHT: Device connection point is on the right panel.
557 * @DEVICE_PANEL_FRONT: Device connection point is on the front panel.
558 * @DEVICE_PANEL_BACK: Device connection point is on the back panel.
559 * @DEVICE_PANEL_UNKNOWN: The panel with device connection point is unknown.
573 * position of the device connection point on the panel surface.
574 * @DEVICE_VERT_POS_UPPER: Device connection point is at upper part of panel.
575 * @DEVICE_VERT_POS_CENTER: Device connection point is at center part of panel.
576 * @DEVICE_VERT_POS_LOWER: Device connection point is at lower part of panel.
586 * position of the device connection point on the panel surface.
587 * @DEVICE_HORI_POS_LEFT: Device connection point is at left part of panel.
588 * @DEVICE_HORI_POS_CENTER: Device connection point is at center part of panel.
589 * @DEVICE_HORI_POS_RIGHT: Device connection point is at right part of panel.
598 * struct device_physical_location - Device data related to physical location
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
710 * @dma_iommu: Device is using default IOMMU implementation for DMA and
713 * At the lowest level, every device in a Linux system is represented by an
714 * instance of struct device. The device structure contains the information
715 * that the device model core needs to model the system. Most subsystems,
717 * result, it is rare for devices to be represented by bare device structures;
719 * a higher-level representation of the device.
721 struct device { struct
723 struct device *parent; argument
727 const char *init_name; /* initial name of the device */ argument
730 const struct bus_type *bus; /* type of bus device is on */ argument
732 device */
733 void *platform_data; /* Platform specific data, device argument
756 u64 *dma_mask; /* dma mask (if dma'able device) */ argument
788 struct device_node *of_node; /* associated device tree node */ argument
789 struct fwnode_handle *fwnode; /* firmware device node */ argument
792 int numa_node; /* NUMA node this device is close to */ argument
795 u32 id; /* device instance */ argument
803 void (*release)(struct device *dev); argument
833 * struct device_link - Device link representation.
834 * @supplier: The device on the supplier end of the link. argument
835 * @s_node: Hook to the supplier device's list of links to consumers.
836 * @consumer: The device on the consumer end of the link.
837 * @c_node: Hook to the consumer device's list of links to suppliers.
838 * @link_dev: device used to expose link details in sysfs
841 * @rpm_active: Whether or not the consumer device is runtime-PM-active.
847 struct device *supplier;
849 struct device *consumer;
851 struct device link_dev;
860 #define kobj_to_dev(__kobj) container_of_const(__kobj, struct device, kobj)
863 * device_iommu_mapped - Returns true when the device DMA is translated
865 * @dev: Device to perform the check on
867 static inline bool device_iommu_mapped(struct device *dev) in device_iommu_mapped()
872 /* Get the wakeup routines, which depend on struct device */
876 * dev_name - Return a device's name.
877 * @dev: Device with name to get.
878 * Return: The kobject name of the device, or its initial name if unavailable.
880 static inline const char *dev_name(const struct device *dev) in dev_name()
890 * dev_bus_name - Return a device's bus/class name, if at all possible
891 * @dev: struct device to get the bus/class name of
893 * Will return the name of the bus/class the device is attached to. If it is
896 static inline const char *dev_bus_name(const struct device *dev) in dev_bus_name()
901 __printf(2, 3) int dev_set_name(struct device *dev, const char *name, ...);
904 static inline int dev_to_node(struct device *dev) in dev_to_node()
908 static inline void set_dev_node(struct device *dev, int node) in set_dev_node()
913 static inline int dev_to_node(struct device *dev) in dev_to_node()
917 static inline void set_dev_node(struct device *dev, int node) in set_dev_node()
922 static inline struct irq_domain *dev_get_msi_domain(const struct device *dev) in dev_get_msi_domain()
931 static inline void dev_set_msi_domain(struct device *dev, struct irq_domain *d) in dev_set_msi_domain()
938 static inline void *dev_get_drvdata(const struct device *dev) in dev_get_drvdata()
943 static inline void dev_set_drvdata(struct device *dev, void *data) in dev_set_drvdata()
948 static inline struct pm_subsys_data *dev_to_psd(struct device *dev) in dev_to_psd()
953 static inline unsigned int dev_get_uevent_suppress(const struct device *dev) in dev_get_uevent_suppress()
958 static inline void dev_set_uevent_suppress(struct device *dev, int val) in dev_set_uevent_suppress()
963 static inline int device_is_registered(struct device *dev) in device_is_registered()
968 static inline void device_enable_async_suspend(struct device *dev) in device_enable_async_suspend()
974 static inline void device_disable_async_suspend(struct device *dev) in device_disable_async_suspend()
980 static inline bool device_async_suspend_enabled(struct device *dev) in device_async_suspend_enabled()
985 static inline bool device_pm_not_required(struct device *dev) in device_pm_not_required()
990 static inline void device_set_pm_not_required(struct device *dev) in device_set_pm_not_required()
995 static inline void dev_pm_syscore_device(struct device *dev, bool val) in dev_pm_syscore_device()
1002 static inline void dev_pm_set_driver_flags(struct device *dev, u32 flags) in dev_pm_set_driver_flags()
1007 static inline bool dev_pm_test_driver_flags(struct device *dev, u32 flags) in dev_pm_test_driver_flags()
1012 static inline void device_lock(struct device *dev) in device_lock()
1017 static inline int device_lock_interruptible(struct device *dev) in device_lock_interruptible()
1022 static inline int device_trylock(struct device *dev) in device_trylock()
1027 static inline void device_unlock(struct device *dev) in device_unlock()
1032 DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T)) in DEFINE_GUARD() argument
1034 static inline void device_lock_assert(struct device *dev) in DEFINE_GUARD()
1039 static inline bool dev_has_sync_state(struct device *dev) in dev_has_sync_state()
1050 static inline void dev_set_removable(struct device *dev, in dev_set_removable()
1056 static inline bool dev_is_removable(struct device *dev) in dev_is_removable()
1061 static inline bool dev_removable_is_valid(struct device *dev) in dev_removable_is_valid()
1069 int __must_check device_register(struct device *dev);
1070 void device_unregister(struct device *dev);
1071 void device_initialize(struct device *dev);
1072 int __must_check device_add(struct device *dev);
1073 void device_del(struct device *dev);
1075 DEFINE_FREE(device_del, struct device *, if (_T) device_del(_T))
1077 int device_for_each_child(struct device *dev, void *data,
1078 int (*fn)(struct device *dev, void *data));
1079 int device_for_each_child_reverse(struct device *dev, void *data,
1080 int (*fn)(struct device *dev, void *data));
1081 int device_for_each_child_reverse_from(struct device *parent,
1082 struct device *from, const void *data,
1083 int (*fn)(struct device *, const void *));
1084 struct device *device_find_child(struct device *dev, void *data,
1085 int (*match)(struct device *dev, void *data));
1086 struct device *device_find_child_by_name(struct device *parent,
1088 struct device *device_find_any_child(struct device *parent);
1090 int device_rename(struct device *dev, const char *new_name);
1091 int device_move(struct device *dev, struct device *new_parent,
1093 int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);
1095 static inline bool device_supports_offline(struct device *dev) in device_supports_offline()
1102 struct device *__d2 __maybe_unused = dev; \
1107 * device_lock_set_class - Specify a temporary lock class while a device
1109 * @dev: device to modify
1119 struct device *__d = dev; \
1130 * device_lock_reset_class - Return a device to the default lockdep novalidate state
1131 * @dev: device to modify
1138 struct device *__d __maybe_unused = dev; \
1146 int device_offline(struct device *dev);
1147 int device_online(struct device *dev);
1149 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
1150 void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
1151 void device_set_node(struct device *dev, struct fwnode_handle *fwnode);
1152 void device_set_of_node_from_dev(struct device *dev, const struct device *dev2);
1154 static inline struct device_node *dev_of_node(struct device *dev) in dev_of_node()
1161 static inline int dev_num_vf(struct device *dev) in dev_num_vf()
1169 * Root device objects for grouping under /sys/devices
1171 struct device *__root_device_register(const char *name, struct module *owner);
1177 void root_device_unregister(struct device *root);
1179 static inline void *dev_get_platdata(const struct device *dev) in dev_get_platdata()
1185 * Manual binding of a device to driver. See drivers/base/bus.c
1189 struct device *dev);
1190 int __must_check device_bind_driver(struct device *dev);
1191 void device_release_driver(struct device *dev);
1192 int __must_check device_attach(struct device *dev);
1194 void device_initial_probe(struct device *dev);
1195 int __must_check device_reprobe(struct device *dev);
1197 bool device_is_bound(struct device *dev);
1202 __printf(5, 6) struct device *
1203 device_create(const struct class *cls, struct device *parent, dev_t devt,
1205 __printf(6, 7) struct device *
1206 device_create_with_groups(const struct class *cls, struct device *parent, dev_t devt,
1211 int __must_check device_add_groups(struct device *dev,
1213 void device_remove_groups(struct device *dev,
1216 static inline int __must_check device_add_group(struct device *dev, in device_add_group()
1224 static inline void device_remove_group(struct device *dev, in device_remove_group()
1232 int __must_check devm_device_add_group(struct device *dev,
1236 * get_device - atomically increment the reference count for the device.
1239 struct device *get_device(struct device *dev);
1240 void put_device(struct device *dev);
1242 DEFINE_FREE(put_device, struct device *, if (_T) put_device(_T))
1244 bool kill_device(struct device *dev);
1256 const char *dev_driver_string(const struct device *dev);
1258 /* Device links interface. */
1259 struct device_link *device_link_add(struct device *consumer,
1260 struct device *supplier, u32 flags);
1262 void device_link_remove(void *consumer, struct device *supplier);