Lines Matching full:device
3 * device.h - generic, centralized driver model
29 #include <linux/device/bus.h>
30 #include <linux/device/class.h>
31 #include <linux/device/devres.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,
285 int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
289 * @dev: Device that owns the action
297 void devm_remove_action(struct device *dev, void (*action)(void *), void *data) in devm_remove_action()
302 void devm_release_action(struct device *dev, void (*action)(void *), void *data);
304 int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
308 static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *), in __devm_add_action_or_reset()
324 * @dev: Device to allocate per-cpu memory for
337 void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
339 void devm_free_percpu(struct device *dev, void __percpu *pdata);
352 * enum device_link_state - Device link states.
370 * Device link flags.
394 * enum dl_dev_state - Device driver presence tracking information.
395 * @DL_DEV_NO_DRIVER: There is no driver attached to the device.
397 * @DL_DEV_DRIVER_BOUND: The driver has been bound to the device.
398 * @DL_DEV_UNBINDING: The driver is unbinding from the device.
408 * enum device_removable - Whether the device is removable. The criteria for a
409 * device to be classified as removable is determined by its subsystem or bus.
411 * device (default).
412 * @DEVICE_REMOVABLE_UNKNOWN: Device location is Unknown.
413 * @DEVICE_FIXED: Device is not removable by the user.
414 * @DEVICE_REMOVABLE: Device is removable by the user.
424 * struct dev_links_info - Device data related to device links.
438 * struct dev_msi_info - Device data related to MSI
439 * @domain: The MSI interrupt domain associated to the device
440 * @data: Pointer to MSI device data
451 * system's housing the device connection point resides on.
452 * @DEVICE_PANEL_TOP: Device connection point is on the top panel.
453 * @DEVICE_PANEL_BOTTOM: Device connection point is on the bottom panel.
454 * @DEVICE_PANEL_LEFT: Device connection point is on the left panel.
455 * @DEVICE_PANEL_RIGHT: Device connection point is on the right panel.
456 * @DEVICE_PANEL_FRONT: Device connection point is on the front panel.
457 * @DEVICE_PANEL_BACK: Device connection point is on the back panel.
458 * @DEVICE_PANEL_UNKNOWN: The panel with device connection point is unknown.
472 * position of the device connection point on the panel surface.
473 * @DEVICE_VERT_POS_UPPER: Device connection point is at upper part of panel.
474 * @DEVICE_VERT_POS_CENTER: Device connection point is at center part of panel.
475 * @DEVICE_VERT_POS_LOWER: Device connection point is at lower part of panel.
485 * position of the device connection point on the panel surface.
486 * @DEVICE_HORI_POS_LEFT: Device connection point is at left part of panel.
487 * @DEVICE_HORI_POS_CENTER: Device connection point is at center part of panel.
488 * @DEVICE_HORI_POS_RIGHT: Device connection point is at right part of panel.
497 * struct device_physical_location - Device data related to physical location
498 * of the device connection point.
499 * @panel: Panel surface of the system's housing that the device connection
501 * @vertical_position: Vertical position of the device connection point within
503 * @horizontal_position: Horizontal position of the device connection point
505 * @dock: Set if the device connection point resides in a docking station or
507 * @lid: Set if this device connection point resides on the lid of laptop
519 * struct device - The basic device structure
520 * @parent: The device's "parent" device, the device to which it is attached.
521 * In most cases, a parent device is some sort of bus or host
522 * controller. If parent is NULL, the device, is a top-level device,
524 * @p: Holds the private data of the driver core portions of the device.
527 * @init_name: Initial name of the device.
528 * @type: The type of device.
529 * This identifies the device type and carries type-specific
532 * @bus: Type of bus device is on.
534 * @platform_data: Platform data specific to the device.
543 * @links: Links to suppliers and consumers of this device.
544 * @power: For device power management.
549 * @em_pd: device's energy model performance domain
550 * @pins: For device pin management.
553 * @numa_node: NUMA node this device is close to.
554 * @dma_ops: DMA mapping operations for this device.
555 * @dma_mask: Dma mask (if dma'ble device).
560 * DMA limit than the device itself supports.
564 * @dma_pools: Dma pools (if dma'ble device).
570 * @dma_uses_io_tlb: %true if device has used the software IO TLB.
572 * @of_node: Associated device tree node.
573 * @fwnode: Associated device node supplied by platform firmware.
575 * @id: device instance
576 * @devres_lock: Spinlock to protect the resource of the device.
577 * @devres_head: The resources list of the device.
578 * @class: The class of the device.
580 * @release: Callback to free the device after all references have
582 * device (i.e. the bus driver that discovered the device).
583 * @iommu_group: IOMMU group the device belongs to.
584 * @iommu: Per device generic IOMMU runtime data
585 * @physical_location: Describes physical location of the device connection
587 * @removable: Whether the device can be removed from the system. This
589 * the device.
591 * @offline_disabled: If set, the device is permanently online.
593 * @of_node_reused: Set if the device-tree node is shared with an ancestor
594 * device.
595 * @state_synced: The hardware state of this device has been synced to match
596 * the software state of this device by calling the driver/bus
598 * @can_match: The device has matched with a driver at least once or it is in
601 * @dma_coherent: this particular device is dma coherent, even if the
609 * @dma_iommu: Device is using default IOMMU implementation for DMA and
612 * At the lowest level, every device in a Linux system is represented by an
613 * instance of struct device. The device structure contains the information
614 * that the device model core needs to model the system. Most subsystems,
616 * result, it is rare for devices to be represented by bare device structures;
618 * a higher-level representation of the device.
620 struct device { struct
622 struct device *parent; argument
626 const char *init_name; /* initial name of the device */ argument
629 const struct bus_type *bus; /* type of bus device is on */ argument
631 device */
632 void *platform_data; /* Platform specific data, device argument
655 u64 *dma_mask; /* dma mask (if dma'able device) */ argument
687 struct device_node *of_node; /* associated device tree node */ argument
688 struct fwnode_handle *fwnode; /* firmware device node */ argument
691 int numa_node; /* NUMA node this device is close to */ argument
694 u32 id; /* device instance */ argument
702 void (*release)(struct device *dev); argument
732 * struct device_link - Device link representation.
733 * @supplier: The device on the supplier end of the link. argument
734 * @s_node: Hook to the supplier device's list of links to consumers.
735 * @consumer: The device on the consumer end of the link.
736 * @c_node: Hook to the consumer device's list of links to suppliers.
737 * @link_dev: device used to expose link details in sysfs
740 * @rpm_active: Whether or not the consumer device is runtime-PM-active.
746 struct device *supplier;
748 struct device *consumer;
750 struct device link_dev;
759 #define kobj_to_dev(__kobj) container_of_const(__kobj, struct device, kobj)
762 * device_iommu_mapped - Returns true when the device DMA is translated
764 * @dev: Device to perform the check on
766 static inline bool device_iommu_mapped(struct device *dev) in device_iommu_mapped()
771 /* Get the wakeup routines, which depend on struct device */
775 * dev_name - Return a device's name.
776 * @dev: Device with name to get.
777 * Return: The kobject name of the device, or its initial name if unavailable.
779 static inline const char *dev_name(const struct device *dev) in dev_name()
789 * dev_bus_name - Return a device's bus/class name, if at all possible
790 * @dev: struct device to get the bus/class name of
792 * Will return the name of the bus/class the device is attached to. If it is
795 static inline const char *dev_bus_name(const struct device *dev) in dev_bus_name()
800 __printf(2, 3) int dev_set_name(struct device *dev, const char *name, ...);
803 static inline int dev_to_node(struct device *dev) in dev_to_node()
807 static inline void set_dev_node(struct device *dev, int node) in set_dev_node()
812 static inline int dev_to_node(struct device *dev) in dev_to_node()
816 static inline void set_dev_node(struct device *dev, int node) in set_dev_node()
821 static inline struct irq_domain *dev_get_msi_domain(const struct device *dev) in dev_get_msi_domain()
830 static inline void dev_set_msi_domain(struct device *dev, struct irq_domain *d) in dev_set_msi_domain()
837 static inline void *dev_get_drvdata(const struct device *dev) in dev_get_drvdata()
842 static inline void dev_set_drvdata(struct device *dev, void *data) in dev_set_drvdata()
847 static inline struct pm_subsys_data *dev_to_psd(struct device *dev) in dev_to_psd()
852 static inline unsigned int dev_get_uevent_suppress(const struct device *dev) in dev_get_uevent_suppress()
857 static inline void dev_set_uevent_suppress(struct device *dev, int val) in dev_set_uevent_suppress()
862 static inline int device_is_registered(struct device *dev) in device_is_registered()
867 static inline void device_enable_async_suspend(struct device *dev) in device_enable_async_suspend()
873 static inline void device_disable_async_suspend(struct device *dev) in device_disable_async_suspend()
879 static inline bool device_async_suspend_enabled(struct device *dev) in device_async_suspend_enabled()
884 static inline bool device_pm_not_required(struct device *dev) in device_pm_not_required()
889 static inline void device_set_pm_not_required(struct device *dev) in device_set_pm_not_required()
894 static inline void dev_pm_syscore_device(struct device *dev, bool val) in dev_pm_syscore_device()
901 static inline void dev_pm_set_driver_flags(struct device *dev, u32 flags) in dev_pm_set_driver_flags()
906 static inline bool dev_pm_test_driver_flags(struct device *dev, u32 flags) in dev_pm_test_driver_flags()
911 static inline bool dev_pm_smart_suspend(struct device *dev) in dev_pm_smart_suspend()
920 static inline void device_lock(struct device *dev) in device_lock()
925 static inline int device_lock_interruptible(struct device *dev) in device_lock_interruptible()
930 static inline int device_trylock(struct device *dev) in device_trylock()
935 static inline void device_unlock(struct device *dev) in device_unlock()
940 DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T)) in DEFINE_GUARD() argument
942 static inline void device_lock_assert(struct device *dev) in DEFINE_GUARD()
947 static inline bool dev_has_sync_state(struct device *dev) in dev_has_sync_state()
958 static inline void dev_set_removable(struct device *dev, in dev_set_removable()
964 static inline bool dev_is_removable(struct device *dev) in dev_is_removable()
969 static inline bool dev_removable_is_valid(struct device *dev) in dev_removable_is_valid()
977 int __must_check device_register(struct device *dev);
978 void device_unregister(struct device *dev);
979 void device_initialize(struct device *dev);
980 int __must_check device_add(struct device *dev);
981 void device_del(struct device *dev);
983 DEFINE_FREE(device_del, struct device *, if (_T) device_del(_T))
985 int device_for_each_child(struct device *parent, void *data,
987 int device_for_each_child_reverse(struct device *parent, void *data,
989 int device_for_each_child_reverse_from(struct device *parent,
990 struct device *from, void *data,
992 struct device *device_find_child(struct device *parent, const void *data,
995 * device_find_child_by_name - device iterator for locating a child device.
996 * @parent: parent struct device
997 * @name: name of the child device
1000 * returns a reference to a device that has the name @name.
1004 static inline struct device *device_find_child_by_name(struct device *parent, in device_find_child_by_name()
1011 * device_find_any_child - device iterator for locating a child device, if any.
1012 * @parent: parent struct device
1015 * returns a reference to a child device, if any.
1019 static inline struct device *device_find_any_child(struct device *parent) in device_find_any_child()
1024 int device_rename(struct device *dev, const char *new_name);
1025 int device_move(struct device *dev, struct device *new_parent,
1027 int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);
1029 static inline bool device_supports_offline(struct device *dev) in device_supports_offline()
1036 struct device *__d2 __maybe_unused = dev; \
1041 * device_lock_set_class - Specify a temporary lock class while a device
1043 * @dev: device to modify
1053 struct device *__d = dev; \
1064 * device_lock_reset_class - Return a device to the default lockdep novalidate state
1065 * @dev: device to modify
1072 struct device *__d __maybe_unused = dev; \
1080 int device_offline(struct device *dev);
1081 int device_online(struct device *dev);
1083 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
1084 void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
1085 void device_set_node(struct device *dev, struct fwnode_handle *fwnode);
1086 int device_add_of_node(struct device *dev, struct device_node *of_node);
1087 void device_remove_of_node(struct device *dev);
1088 void device_set_of_node_from_dev(struct device *dev, const struct device *dev2);
1090 static inline struct device_node *dev_of_node(struct device *dev) in dev_of_node()
1097 static inline int dev_num_vf(struct device *dev) in dev_num_vf()
1105 * Root device objects for grouping under /sys/devices
1107 struct device *__root_device_register(const char *name, struct module *owner);
1113 void root_device_unregister(struct device *root);
1115 static inline void *dev_get_platdata(const struct device *dev) in dev_get_platdata()
1121 * Manual binding of a device to driver. See drivers/base/bus.c
1125 struct device *dev);
1126 int __must_check device_bind_driver(struct device *dev);
1127 void device_release_driver(struct device *dev);
1128 int __must_check device_attach(struct device *dev);
1130 void device_initial_probe(struct device *dev);
1131 int __must_check device_reprobe(struct device *dev);
1133 bool device_is_bound(struct device *dev);
1138 __printf(5, 6) struct device *
1139 device_create(const struct class *cls, struct device *parent, dev_t devt,
1141 __printf(6, 7) struct device *
1142 device_create_with_groups(const struct class *cls, struct device *parent, dev_t devt,
1147 int __must_check device_add_groups(struct device *dev,
1149 void device_remove_groups(struct device *dev,
1152 static inline int __must_check device_add_group(struct device *dev, in device_add_group()
1160 static inline void device_remove_group(struct device *dev, in device_remove_group()
1168 int __must_check devm_device_add_group(struct device *dev,
1172 * get_device - atomically increment the reference count for the device.
1175 struct device *get_device(struct device *dev);
1176 void put_device(struct device *dev);
1178 DEFINE_FREE(put_device, struct device *, if (_T) put_device(_T))
1180 bool kill_device(struct device *dev);
1192 const char *dev_driver_string(const struct device *dev);
1194 /* Device links interface. */
1195 struct device_link *device_link_add(struct device *consumer,
1196 struct device *supplier, u32 flags);
1198 void device_link_remove(void *consumer, struct device *supplier);