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;
52 * struct subsys_interface - interfaces to device functions
53 * @name: name of the device function
56 * @add_dev: device hookup to device function handler
57 * @remove_dev: device hookup to device function handler
68 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
69 void (*remove_dev)(struct device *dev, struct subsys_interface *sif);
81 * The type of device, "struct device" is embedded in. A class
84 * This identifies the device type and carries type-specific
92 int (*uevent)(const struct device *dev, struct kobj_uevent_env *env);
93 char *(*devnode)(const struct device *dev, umode_t *mode,
95 void (*release)(struct device *dev);
101 * struct device_attribute - Interface for exporting device attributes.
108 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
110 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
115 * struct dev_ext_attribute - Exported device attribute with extra context.
116 * @attr: Exported device attribute.
124 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
126 ssize_t device_store_ulong(struct device *dev, struct device_attribute *attr,
128 ssize_t device_show_int(struct device *dev, struct device_attribute *attr,
130 ssize_t device_store_int(struct device *dev, struct device_attribute *attr,
132 ssize_t device_show_bool(struct device *dev, struct device_attribute *attr,
134 ssize_t device_store_bool(struct device *dev, struct device_attribute *attr,
138 * DEVICE_ATTR - Define a device attribute.
160 * DEVICE_ATTR_PREALLOC - Define a preallocated device attribute.
173 * DEVICE_ATTR_RW - Define a read-write device attribute.
183 * DEVICE_ATTR_ADMIN_RW - Define an admin-only read-write device attribute.
192 * DEVICE_ATTR_RO - Define a readable device attribute.
201 * DEVICE_ATTR_ADMIN_RO - Define an admin-only readable device attribute.
210 * DEVICE_ATTR_WO - Define an admin-only writable device attribute.
219 * DEVICE_ULONG_ATTR - Define a device attribute backed by an unsigned long.
232 * DEVICE_INT_ATTR - Define a device attribute backed by an int.
244 * DEVICE_BOOL_ATTR - Define a device attribute backed by a bool.
259 int device_create_file(struct device *device,
261 void device_remove_file(struct device *dev,
263 bool device_remove_file_self(struct device *dev,
265 int __must_check device_create_bin_file(struct device *dev,
267 void device_remove_bin_file(struct device *dev,
270 /* device resource management */
271 typedef void (*dr_release_t)(struct device *dev, void *res);
272 typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
281 void devres_for_each_res(struct device *dev, dr_release_t release,
283 void (*fn)(struct device *, void *, void *),
286 void devres_add(struct device *dev, void *res);
287 void *devres_find(struct device *dev, dr_release_t release,
289 void *devres_get(struct device *dev, void *new_res,
291 void *devres_remove(struct device *dev, dr_release_t release,
293 int devres_destroy(struct device *dev, dr_release_t release,
295 int devres_release(struct device *dev, dr_release_t release,
299 void * __must_check devres_open_group(struct device *dev, void *id, gfp_t gfp);
300 void devres_close_group(struct device *dev, void *id);
301 void devres_remove_group(struct device *dev, void *id);
302 int devres_release_group(struct device *dev, void *id);
304 /* managed devm_k.alloc/kfree for device drivers */
305 void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp) __alloc_size(2);
306 void *devm_krealloc(struct device *dev, void *ptr, size_t size,
308 __printf(3, 0) char *devm_kvasprintf(struct device *dev, gfp_t gfp,
310 __printf(3, 4) char *devm_kasprintf(struct device *dev, gfp_t gfp,
312 static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp) in devm_kzalloc()
316 static inline void *devm_kmalloc_array(struct device *dev, in devm_kmalloc_array()
326 static inline void *devm_kcalloc(struct device *dev, in devm_kcalloc()
332 devm_krealloc_array(struct device *dev, void *p, size_t new_n, size_t new_size, gfp_t flags) in devm_krealloc_array()
342 void devm_kfree(struct device *dev, const void *p);
343 char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc;
344 const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gfp);
345 void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp)
348 unsigned long devm_get_free_pages(struct device *dev,
350 void devm_free_pages(struct device *dev, unsigned long addr);
353 void __iomem *devm_ioremap_resource(struct device *dev,
355 void __iomem *devm_ioremap_resource_wc(struct device *dev,
358 void __iomem *devm_of_iomap(struct device *dev,
364 void __iomem *devm_ioremap_resource(struct device *dev, in devm_ioremap_resource()
371 void __iomem *devm_ioremap_resource_wc(struct device *dev, in devm_ioremap_resource_wc()
378 void __iomem *devm_of_iomap(struct device *dev, in devm_of_iomap()
388 void devm_remove_action(struct device *dev, void (*action)(void *), void *data);
389 void devm_release_action(struct device *dev, void (*action)(void *), void *data);
391 int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
395 static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *), in __devm_add_action_or_reset()
411 * @dev: Device to allocate per-cpu memory for
424 void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
426 void devm_free_percpu(struct device *dev, void __percpu *pdata);
439 * enum device_link_state - Device link states.
457 * Device link flags.
481 * enum dl_dev_state - Device driver presence tracking information.
482 * @DL_DEV_NO_DRIVER: There is no driver attached to the device.
484 * @DL_DEV_DRIVER_BOUND: The driver has been bound to the device.
485 * @DL_DEV_UNBINDING: The driver is unbinding from the device.
495 * enum device_removable - Whether the device is removable. The criteria for a
496 * device to be classified as removable is determined by its subsystem or bus.
498 * device (default).
499 * @DEVICE_REMOVABLE_UNKNOWN: Device location is Unknown.
500 * @DEVICE_FIXED: Device is not removable by the user.
501 * @DEVICE_REMOVABLE: Device is removable by the user.
511 * struct dev_links_info - Device data related to device links.
525 * struct dev_msi_info - Device data related to MSI
526 * @domain: The MSI interrupt domain associated to the device
527 * @data: Pointer to MSI device data
538 * system's housing the device connection point resides on.
539 * @DEVICE_PANEL_TOP: Device connection point is on the top panel.
540 * @DEVICE_PANEL_BOTTOM: Device connection point is on the bottom panel.
541 * @DEVICE_PANEL_LEFT: Device connection point is on the left panel.
542 * @DEVICE_PANEL_RIGHT: Device connection point is on the right panel.
543 * @DEVICE_PANEL_FRONT: Device connection point is on the front panel.
544 * @DEVICE_PANEL_BACK: Device connection point is on the back panel.
545 * @DEVICE_PANEL_UNKNOWN: The panel with device connection point is unknown.
559 * position of the device connection point on the panel surface.
560 * @DEVICE_VERT_POS_UPPER: Device connection point is at upper part of panel.
561 * @DEVICE_VERT_POS_CENTER: Device connection point is at center part of panel.
562 * @DEVICE_VERT_POS_LOWER: Device connection point is at lower part of panel.
572 * position of the device connection point on the panel surface.
573 * @DEVICE_HORI_POS_LEFT: Device connection point is at left part of panel.
574 * @DEVICE_HORI_POS_CENTER: Device connection point is at center part of panel.
575 * @DEVICE_HORI_POS_RIGHT: Device connection point is at right part of panel.
584 * struct device_physical_location - Device data related to physical location
585 * of the device connection point.
586 * @panel: Panel surface of the system's housing that the device connection
588 * @vertical_position: Vertical position of the device connection point within
590 * @horizontal_position: Horizontal position of the device connection point
592 * @dock: Set if the device connection point resides in a docking station or
594 * @lid: Set if this device connection point resides on the lid of laptop
606 * struct device - The basic device structure
607 * @parent: The device's "parent" device, the device to which it is attached.
608 * In most cases, a parent device is some sort of bus or host
609 * controller. If parent is NULL, the device, is a top-level device,
611 * @p: Holds the private data of the driver core portions of the device.
614 * @init_name: Initial name of the device.
615 * @type: The type of device.
616 * This identifies the device type and carries type-specific
619 * @bus: Type of bus device is on.
621 * @platform_data: Platform data specific to the device.
630 * @links: Links to suppliers and consumers of this device.
631 * @power: For device power management.
636 * @em_pd: device's energy model performance domain
637 * @pins: For device pin management.
640 * @numa_node: NUMA node this device is close to.
641 * @dma_ops: DMA mapping operations for this device.
642 * @dma_mask: Dma mask (if dma'ble device).
647 * DMA limit than the device itself supports.
651 * @dma_pools: Dma pools (if dma'ble device).
657 * @dma_uses_io_tlb: %true if device has used the software IO TLB.
659 * @of_node: Associated device tree node.
660 * @fwnode: Associated device node supplied by platform firmware.
662 * @id: device instance
663 * @devres_lock: Spinlock to protect the resource of the device.
664 * @devres_head: The resources list of the device.
665 * @knode_class: The node used to add the device to the class list.
666 * @class: The class of the device.
668 * @release: Callback to free the device after all references have
670 * device (i.e. the bus driver that discovered the device).
671 * @iommu_group: IOMMU group the device belongs to.
672 * @iommu: Per device generic IOMMU runtime data
673 * @physical_location: Describes physical location of the device connection
675 * @removable: Whether the device can be removed from the system. This
677 * the device.
679 * @offline_disabled: If set, the device is permanently online.
681 * @of_node_reused: Set if the device-tree node is shared with an ancestor
682 * device.
683 * @state_synced: The hardware state of this device has been synced to match
684 * the software state of this device by calling the driver/bus
686 * @can_match: The device has matched with a driver at least once or it is in
689 * @dma_coherent: this particular device is dma coherent, even if the
697 * At the lowest level, every device in a Linux system is represented by an
698 * instance of struct device. The device structure contains the information
699 * that the device model core needs to model the system. Most subsystems,
701 * result, it is rare for devices to be represented by bare device structures;
703 * a higher-level representation of the device.
705 struct device { struct
707 struct device *parent; argument
711 const char *init_name; /* initial name of the device */ argument
714 const struct bus_type *bus; /* type of bus device is on */ argument
716 device */
717 void *platform_data; /* Platform specific data, device argument
740 u64 *dma_mask; /* dma mask (if dma'able device) */ argument
772 struct device_node *of_node; /* associated device tree node */ argument
773 struct fwnode_handle *fwnode; /* firmware device node */ argument
776 int numa_node; /* NUMA node this device is close to */ argument
779 u32 id; /* device instance */ argument
787 void (*release)(struct device *dev); argument
811 * struct device_link - Device link representation.
812 * @supplier: The device on the supplier end of the link. argument
813 * @s_node: Hook to the supplier device's list of links to consumers.
814 * @consumer: The device on the consumer end of the link.
815 * @c_node: Hook to the consumer device's list of links to suppliers.
816 * @link_dev: device used to expose link details in sysfs
819 * @rpm_active: Whether or not the consumer device is runtime-PM-active.
825 struct device *supplier;
827 struct device *consumer;
829 struct device link_dev;
838 #define kobj_to_dev(__kobj) container_of_const(__kobj, struct device, kobj)
841 * device_iommu_mapped - Returns true when the device DMA is translated
843 * @dev: Device to perform the check on
845 static inline bool device_iommu_mapped(struct device *dev) in device_iommu_mapped()
850 /* Get the wakeup routines, which depend on struct device */
854 * dev_name - Return a device's name.
855 * @dev: Device with name to get.
856 * Return: The kobject name of the device, or its initial name if unavailable.
858 static inline const char *dev_name(const struct device *dev) in dev_name()
868 * dev_bus_name - Return a device's bus/class name, if at all possible
869 * @dev: struct device to get the bus/class name of
871 * Will return the name of the bus/class the device is attached to. If it is
874 static inline const char *dev_bus_name(const struct device *dev) in dev_bus_name()
879 __printf(2, 3) int dev_set_name(struct device *dev, const char *name, ...);
882 static inline int dev_to_node(struct device *dev) in dev_to_node()
886 static inline void set_dev_node(struct device *dev, int node) in set_dev_node()
891 static inline int dev_to_node(struct device *dev) in dev_to_node()
895 static inline void set_dev_node(struct device *dev, int node) in set_dev_node()
900 static inline struct irq_domain *dev_get_msi_domain(const struct device *dev) in dev_get_msi_domain()
909 static inline void dev_set_msi_domain(struct device *dev, struct irq_domain *d) in dev_set_msi_domain()
916 static inline void *dev_get_drvdata(const struct device *dev) in dev_get_drvdata()
921 static inline void dev_set_drvdata(struct device *dev, void *data) in dev_set_drvdata()
926 static inline struct pm_subsys_data *dev_to_psd(struct device *dev) in dev_to_psd()
931 static inline unsigned int dev_get_uevent_suppress(const struct device *dev) in dev_get_uevent_suppress()
936 static inline void dev_set_uevent_suppress(struct device *dev, int val) in dev_set_uevent_suppress()
941 static inline int device_is_registered(struct device *dev) in device_is_registered()
946 static inline void device_enable_async_suspend(struct device *dev) in device_enable_async_suspend()
952 static inline void device_disable_async_suspend(struct device *dev) in device_disable_async_suspend()
958 static inline bool device_async_suspend_enabled(struct device *dev) in device_async_suspend_enabled()
963 static inline bool device_pm_not_required(struct device *dev) in device_pm_not_required()
968 static inline void device_set_pm_not_required(struct device *dev) in device_set_pm_not_required()
973 static inline void dev_pm_syscore_device(struct device *dev, bool val) in dev_pm_syscore_device()
980 static inline void dev_pm_set_driver_flags(struct device *dev, u32 flags) in dev_pm_set_driver_flags()
985 static inline bool dev_pm_test_driver_flags(struct device *dev, u32 flags) in dev_pm_test_driver_flags()
990 static inline void device_lock(struct device *dev) in device_lock()
995 static inline int device_lock_interruptible(struct device *dev) in device_lock_interruptible()
1000 static inline int device_trylock(struct device *dev) in device_trylock()
1005 static inline void device_unlock(struct device *dev) in device_unlock()
1010 static inline void device_lock_assert(struct device *dev) in device_lock_assert()
1015 static inline struct device_node *dev_of_node(struct device *dev) in dev_of_node()
1022 static inline bool dev_has_sync_state(struct device *dev) in dev_has_sync_state()
1033 static inline void dev_set_removable(struct device *dev, in dev_set_removable()
1039 static inline bool dev_is_removable(struct device *dev) in dev_is_removable()
1044 static inline bool dev_removable_is_valid(struct device *dev) in dev_removable_is_valid()
1052 int __must_check device_register(struct device *dev);
1053 void device_unregister(struct device *dev);
1054 void device_initialize(struct device *dev);
1055 int __must_check device_add(struct device *dev);
1056 void device_del(struct device *dev);
1058 DEFINE_FREE(device_del, struct device *, if (_T) device_del(_T))
1060 int device_for_each_child(struct device *dev, void *data,
1061 int (*fn)(struct device *dev, void *data));
1062 int device_for_each_child_reverse(struct device *dev, void *data,
1063 int (*fn)(struct device *dev, void *data));
1064 struct device *device_find_child(struct device *dev, void *data,
1065 int (*match)(struct device *dev, void *data));
1066 struct device *device_find_child_by_name(struct device *parent,
1068 struct device *device_find_any_child(struct device *parent);
1070 int device_rename(struct device *dev, const char *new_name);
1071 int device_move(struct device *dev, struct device *new_parent,
1073 int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);
1074 int device_is_dependent(struct device *dev, void *target);
1076 static inline bool device_supports_offline(struct device *dev) in device_supports_offline()
1083 struct device *__d2 __maybe_unused = dev; \
1088 * device_lock_set_class - Specify a temporary lock class while a device
1090 * @dev: device to modify
1100 struct device *__d = dev; \
1111 * device_lock_reset_class - Return a device to the default lockdep novalidate state
1112 * @dev: device to modify
1119 struct device *__d __maybe_unused = dev; \
1127 int device_offline(struct device *dev);
1128 int device_online(struct device *dev);
1129 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
1130 void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
1131 void device_set_of_node_from_dev(struct device *dev, const struct device *dev2);
1132 void device_set_node(struct device *dev, struct fwnode_handle *fwnode);
1134 static inline int dev_num_vf(struct device *dev) in dev_num_vf()
1142 * Root device objects for grouping under /sys/devices
1144 struct device *__root_device_register(const char *name, struct module *owner);
1150 void root_device_unregister(struct device *root);
1152 static inline void *dev_get_platdata(const struct device *dev) in dev_get_platdata()
1158 * Manual binding of a device to driver. See drivers/base/bus.c
1162 struct device *dev);
1163 int __must_check device_bind_driver(struct device *dev);
1164 void device_release_driver(struct device *dev);
1165 int __must_check device_attach(struct device *dev);
1167 void device_initial_probe(struct device *dev);
1168 int __must_check device_reprobe(struct device *dev);
1170 bool device_is_bound(struct device *dev);
1175 __printf(5, 6) struct device *
1176 device_create(const struct class *cls, struct device *parent, dev_t devt,
1178 __printf(6, 7) struct device *
1179 device_create_with_groups(const struct class *cls, struct device *parent, dev_t devt,
1184 int __must_check device_add_groups(struct device *dev,
1186 void device_remove_groups(struct device *dev,
1189 static inline int __must_check device_add_group(struct device *dev, in device_add_group()
1197 static inline void device_remove_group(struct device *dev, in device_remove_group()
1205 int __must_check devm_device_add_groups(struct device *dev,
1207 int __must_check devm_device_add_group(struct device *dev,
1212 * about devices and actions that the general device layer doesn't
1215 /* Notify platform of device discovery */
1216 extern int (*platform_notify)(struct device *dev);
1218 extern int (*platform_notify_remove)(struct device *dev);
1222 * get_device - atomically increment the reference count for the device.
1225 struct device *get_device(struct device *dev);
1226 void put_device(struct device *dev);
1228 DEFINE_FREE(put_device, struct device *, if (_T) put_device(_T))
1230 bool kill_device(struct device *dev);
1242 const char *dev_driver_string(const struct device *dev);
1244 /* Device links interface. */
1245 struct device_link *device_link_add(struct device *consumer,
1246 struct device *supplier, u32 flags);
1248 void device_link_remove(void *consumer, struct device *supplier);