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>
33 #include <asm/device.h>
35 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)(struct device *dev, struct kobj_uevent_env *env);
92 char *(*devnode)(struct device *dev, umode_t *mode,
94 void (*release)(struct device *dev);
99 /* interface for exporting device attributes */
102 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
104 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
113 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
115 ssize_t device_store_ulong(struct device *dev, struct device_attribute *attr,
117 ssize_t device_show_int(struct device *dev, struct device_attribute *attr,
119 ssize_t device_store_int(struct device *dev, struct device_attribute *attr,
121 ssize_t device_show_bool(struct device *dev, struct device_attribute *attr,
123 ssize_t device_store_bool(struct device *dev, struct device_attribute *attr,
154 int device_create_file(struct device *device,
156 void device_remove_file(struct device *dev,
158 bool device_remove_file_self(struct device *dev,
160 int __must_check device_create_bin_file(struct device *dev,
162 void device_remove_bin_file(struct device *dev,
165 /* device resource management */
166 typedef void (*dr_release_t)(struct device *dev, void *res);
167 typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
176 void devres_for_each_res(struct device *dev, dr_release_t release,
178 void (*fn)(struct device *, void *, void *),
181 void devres_add(struct device *dev, void *res);
182 void *devres_find(struct device *dev, dr_release_t release,
184 void *devres_get(struct device *dev, void *new_res,
186 void *devres_remove(struct device *dev, dr_release_t release,
188 int devres_destroy(struct device *dev, dr_release_t release,
190 int devres_release(struct device *dev, dr_release_t release,
194 void * __must_check devres_open_group(struct device *dev, void *id, gfp_t gfp);
195 void devres_close_group(struct device *dev, void *id);
196 void devres_remove_group(struct device *dev, void *id);
197 int devres_release_group(struct device *dev, void *id);
199 /* managed devm_k.alloc/kfree for device drivers */
200 void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp) __malloc;
201 void *devm_krealloc(struct device *dev, void *ptr, size_t size,
203 __printf(3, 0) char *devm_kvasprintf(struct device *dev, gfp_t gfp,
205 __printf(3, 4) char *devm_kasprintf(struct device *dev, gfp_t gfp,
207 static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp) in devm_kzalloc()
211 static inline void *devm_kmalloc_array(struct device *dev, in devm_kmalloc_array()
221 static inline void *devm_kcalloc(struct device *dev, in devm_kcalloc()
226 void devm_kfree(struct device *dev, const void *p);
227 char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc;
228 const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gfp);
229 void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp);
231 unsigned long devm_get_free_pages(struct device *dev,
233 void devm_free_pages(struct device *dev, unsigned long addr);
235 void __iomem *devm_ioremap_resource(struct device *dev,
237 void __iomem *devm_ioremap_resource_wc(struct device *dev,
240 void __iomem *devm_of_iomap(struct device *dev,
245 int devm_add_action(struct device *dev, void (*action)(void *), void *data);
246 void devm_remove_action(struct device *dev, void (*action)(void *), void *data);
247 void devm_release_action(struct device *dev, void (*action)(void *), void *data);
249 static inline int devm_add_action_or_reset(struct device *dev, in devm_add_action_or_reset()
263 * @dev: Device to allocate per-cpu memory for
276 void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
278 void devm_free_percpu(struct device *dev, void __percpu *pdata);
291 * enum device_link_state - Device link states.
309 * Device link flags.
332 * enum dl_dev_state - Device driver presence tracking information.
333 * @DL_DEV_NO_DRIVER: There is no driver attached to the device.
335 * @DL_DEV_DRIVER_BOUND: The driver has been bound to the device.
336 * @DL_DEV_UNBINDING: The driver is unbinding from the device.
346 * enum device_removable - Whether the device is removable. The criteria for a
347 * device to be classified as removable is determined by its subsystem or bus.
349 * device (default).
350 * @DEVICE_REMOVABLE_UNKNOWN: Device location is Unknown.
351 * @DEVICE_FIXED: Device is not removable by the user.
352 * @DEVICE_REMOVABLE: Device is removable by the user.
362 * struct dev_links_info - Device data related to device links.
376 * struct dev_msi_info - Device data related to MSI
377 * @domain: The MSI interrupt domain associated to the device
378 * @data: Pointer to MSI device data
391 * system's housing the device connection point resides on.
392 * @DEVICE_PANEL_TOP: Device connection point is on the top panel.
393 * @DEVICE_PANEL_BOTTOM: Device connection point is on the bottom panel.
394 * @DEVICE_PANEL_LEFT: Device connection point is on the left panel.
395 * @DEVICE_PANEL_RIGHT: Device connection point is on the right panel.
396 * @DEVICE_PANEL_FRONT: Device connection point is on the front panel.
397 * @DEVICE_PANEL_BACK: Device connection point is on the back panel.
398 * @DEVICE_PANEL_UNKNOWN: The panel with device connection point is unknown.
412 * position of the device connection point on the panel surface.
413 * @DEVICE_VERT_POS_UPPER: Device connection point is at upper part of panel.
414 * @DEVICE_VERT_POS_CENTER: Device connection point is at center part of panel.
415 * @DEVICE_VERT_POS_LOWER: Device connection point is at lower part of panel.
425 * position of the device connection point on the panel surface.
426 * @DEVICE_HORI_POS_LEFT: Device connection point is at left part of panel.
427 * @DEVICE_HORI_POS_CENTER: Device connection point is at center part of panel.
428 * @DEVICE_HORI_POS_RIGHT: Device connection point is at right part of panel.
437 * struct device_physical_location - Device data related to physical location
438 * of the device connection point.
439 * @panel: Panel surface of the system's housing that the device connection
441 * @vertical_position: Vertical position of the device connection point within
443 * @horizontal_position: Horizontal position of the device connection point
445 * @dock: Set if the device connection point resides in a docking station or
447 * @lid: Set if this device connection point resides on the lid of laptop
459 * struct device - The basic device structure
460 * @parent: The device's "parent" device, the device to which it is attached.
461 * In most cases, a parent device is some sort of bus or host
462 * controller. If parent is NULL, the device, is a top-level device,
464 * @p: Holds the private data of the driver core portions of the device.
467 * @init_name: Initial name of the device.
468 * @type: The type of device.
469 * This identifies the device type and carries type-specific
472 * @bus: Type of bus device is on.
474 * @platform_data: Platform data specific to the device.
483 * @links: Links to suppliers and consumers of this device.
484 * @power: For device power management.
489 * @em_pd: device's energy model performance domain
490 * @pins: For device pin management.
493 * @numa_node: NUMA node this device is close to.
494 * @dma_ops: DMA mapping operations for this device.
495 * @dma_mask: Dma mask (if dma'ble device).
500 * DMA limit than the device itself supports.
504 * @dma_pools: Dma pools (if dma'ble device).
509 * @of_node: Associated device tree node.
510 * @fwnode: Associated device node supplied by platform firmware.
512 * @id: device instance
513 * @devres_lock: Spinlock to protect the resource of the device.
514 * @devres_head: The resources list of the device.
515 * @knode_class: The node used to add the device to the class list.
516 * @class: The class of the device.
518 * @release: Callback to free the device after all references have
520 * device (i.e. the bus driver that discovered the device).
521 * @iommu_group: IOMMU group the device belongs to.
522 * @iommu: Per device generic IOMMU runtime data
523 * @physical_location: Describes physical location of the device connection
525 * @removable: Whether the device can be removed from the system. This
527 * the device.
529 * @offline_disabled: If set, the device is permanently online.
531 * @of_node_reused: Set if the device-tree node is shared with an ancestor
532 * device.
533 * @state_synced: The hardware state of this device has been synced to match
534 * the software state of this device by calling the driver/bus
536 * @can_match: The device has matched with a driver at least once or it is in
539 * @dma_coherent: this particular device is dma coherent, even if the
547 * At the lowest level, every device in a Linux system is represented by an
548 * instance of struct device. The device structure contains the information
549 * that the device model core needs to model the system. Most subsystems,
551 * result, it is rare for devices to be represented by bare device structures;
553 * a higher-level representation of the device.
555 struct device { struct
557 struct device *parent; argument
561 const char *init_name; /* initial name of the device */ argument
564 struct bus_type *bus; /* type of bus device is on */ argument
566 device */
567 void *platform_data; /* Platform specific data, device argument
590 u64 *dma_mask; /* dma mask (if dma'able device) */ argument
617 struct device_node *of_node; /* associated device tree node */ argument
618 struct fwnode_handle *fwnode; /* firmware device node */ argument
621 int numa_node; /* NUMA node this device is close to */ argument
624 u32 id; /* device instance */ argument
632 void (*release)(struct device *dev); argument
656 * struct device_link - Device link representation.
657 * @supplier: The device on the supplier end of the link. argument
658 * @s_node: Hook to the supplier device's list of links to consumers.
659 * @consumer: The device on the consumer end of the link.
660 * @c_node: Hook to the consumer device's list of links to suppliers.
661 * @link_dev: device used to expose link details in sysfs
664 * @rpm_active: Whether or not the consumer device is runtime-PM-active.
670 struct device *supplier;
672 struct device *consumer;
674 struct device link_dev;
683 static inline struct device *kobj_to_dev(struct kobject *kobj) in kobj_to_dev()
685 return container_of(kobj, struct device, kobj); in kobj_to_dev()
689 * device_iommu_mapped - Returns true when the device DMA is translated
691 * @dev: Device to perform the check on
693 static inline bool device_iommu_mapped(struct device *dev) in device_iommu_mapped()
698 /* Get the wakeup routines, which depend on struct device */
701 static inline const char *dev_name(const struct device *dev) in dev_name()
711 * dev_bus_name - Return a device's bus/class name, if at all possible
712 * @dev: struct device to get the bus/class name of
714 * Will return the name of the bus/class the device is attached to. If it is
717 static inline const char *dev_bus_name(const struct device *dev) in dev_bus_name()
722 __printf(2, 3) int dev_set_name(struct device *dev, const char *name, ...);
725 static inline int dev_to_node(struct device *dev) in dev_to_node()
729 static inline void set_dev_node(struct device *dev, int node) in set_dev_node()
734 static inline int dev_to_node(struct device *dev) in dev_to_node()
738 static inline void set_dev_node(struct device *dev, int node) in set_dev_node()
743 static inline struct irq_domain *dev_get_msi_domain(const struct device *dev) in dev_get_msi_domain()
752 static inline void dev_set_msi_domain(struct device *dev, struct irq_domain *d) in dev_set_msi_domain()
759 static inline void *dev_get_drvdata(const struct device *dev) in dev_get_drvdata()
764 static inline void dev_set_drvdata(struct device *dev, void *data) in dev_set_drvdata()
769 static inline struct pm_subsys_data *dev_to_psd(struct device *dev) in dev_to_psd()
774 static inline unsigned int dev_get_uevent_suppress(const struct device *dev) in dev_get_uevent_suppress()
779 static inline void dev_set_uevent_suppress(struct device *dev, int val) in dev_set_uevent_suppress()
784 static inline int device_is_registered(struct device *dev) in device_is_registered()
789 static inline void device_enable_async_suspend(struct device *dev) in device_enable_async_suspend()
795 static inline void device_disable_async_suspend(struct device *dev) in device_disable_async_suspend()
801 static inline bool device_async_suspend_enabled(struct device *dev) in device_async_suspend_enabled()
806 static inline bool device_pm_not_required(struct device *dev) in device_pm_not_required()
811 static inline void device_set_pm_not_required(struct device *dev) in device_set_pm_not_required()
816 static inline void dev_pm_syscore_device(struct device *dev, bool val) in dev_pm_syscore_device()
823 static inline void dev_pm_set_driver_flags(struct device *dev, u32 flags) in dev_pm_set_driver_flags()
828 static inline bool dev_pm_test_driver_flags(struct device *dev, u32 flags) in dev_pm_test_driver_flags()
833 static inline void device_lock(struct device *dev) in device_lock()
838 static inline int device_lock_interruptible(struct device *dev) in device_lock_interruptible()
843 static inline int device_trylock(struct device *dev) in device_trylock()
848 static inline void device_unlock(struct device *dev) in device_unlock()
853 static inline void device_lock_assert(struct device *dev) in device_lock_assert()
858 static inline struct device_node *dev_of_node(struct device *dev) in dev_of_node()
865 static inline bool dev_has_sync_state(struct device *dev) in dev_has_sync_state()
876 static inline void dev_set_removable(struct device *dev, in dev_set_removable()
882 static inline bool dev_is_removable(struct device *dev) in dev_is_removable()
887 static inline bool dev_removable_is_valid(struct device *dev) in dev_removable_is_valid()
895 int __must_check device_register(struct device *dev);
896 void device_unregister(struct device *dev);
897 void device_initialize(struct device *dev);
898 int __must_check device_add(struct device *dev);
899 void device_del(struct device *dev);
900 int device_for_each_child(struct device *dev, void *data,
901 int (*fn)(struct device *dev, void *data));
902 int device_for_each_child_reverse(struct device *dev, void *data,
903 int (*fn)(struct device *dev, void *data));
904 struct device *device_find_child(struct device *dev, void *data,
905 int (*match)(struct device *dev, void *data));
906 struct device *device_find_child_by_name(struct device *parent,
908 struct device *device_find_any_child(struct device *parent);
910 int device_rename(struct device *dev, const char *new_name);
911 int device_move(struct device *dev, struct device *new_parent,
913 int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);
914 const char *device_get_devnode(struct device *dev, umode_t *mode, kuid_t *uid,
916 int device_is_dependent(struct device *dev, void *target);
918 static inline bool device_supports_offline(struct device *dev) in device_supports_offline()
925 struct device *__d2 __maybe_unused = dev; \
930 * device_lock_set_class - Specify a temporary lock class while a device
932 * @dev: device to modify
942 struct device *__d = dev; \
953 * device_lock_reset_class - Return a device to the default lockdep novalidate state
954 * @dev: device to modify
961 struct device *__d __maybe_unused = dev; \
969 int device_offline(struct device *dev);
970 int device_online(struct device *dev);
971 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
972 void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
973 void device_set_of_node_from_dev(struct device *dev, const struct device *dev2);
974 void device_set_node(struct device *dev, struct fwnode_handle *fwnode);
976 static inline int dev_num_vf(struct device *dev) in dev_num_vf()
984 * Root device objects for grouping under /sys/devices
986 struct device *__root_device_register(const char *name, struct module *owner);
992 void root_device_unregister(struct device *root);
994 static inline void *dev_get_platdata(const struct device *dev) in dev_get_platdata()
1000 * Manual binding of a device to driver. See drivers/base/bus.c
1004 struct device *dev);
1005 int __must_check device_bind_driver(struct device *dev);
1006 void device_release_driver(struct device *dev);
1007 int __must_check device_attach(struct device *dev);
1009 void device_initial_probe(struct device *dev);
1010 int __must_check device_reprobe(struct device *dev);
1012 bool device_is_bound(struct device *dev);
1017 __printf(5, 6) struct device *
1018 device_create(struct class *cls, struct device *parent, dev_t devt,
1020 __printf(6, 7) struct device *
1021 device_create_with_groups(struct class *cls, struct device *parent, dev_t devt,
1026 int __must_check device_add_groups(struct device *dev,
1028 void device_remove_groups(struct device *dev,
1031 static inline int __must_check device_add_group(struct device *dev, in device_add_group()
1039 static inline void device_remove_group(struct device *dev, in device_remove_group()
1047 int __must_check devm_device_add_groups(struct device *dev,
1049 void devm_device_remove_groups(struct device *dev,
1051 int __must_check devm_device_add_group(struct device *dev,
1053 void devm_device_remove_group(struct device *dev,
1058 * about devices and actions that the general device layer doesn't
1061 /* Notify platform of device discovery */
1062 extern int (*platform_notify)(struct device *dev);
1064 extern int (*platform_notify_remove)(struct device *dev);
1068 * get_device - atomically increment the reference count for the device.
1071 struct device *get_device(struct device *dev);
1072 void put_device(struct device *dev);
1073 bool kill_device(struct device *dev);
1085 const char *dev_driver_string(const struct device *dev);
1087 /* Device links interface. */
1088 struct device_link *device_link_add(struct device *consumer,
1089 struct device *supplier, u32 flags);
1091 void device_link_remove(void *consumer, struct device *supplier);
1096 int dev_err_probe(const struct device *dev, int err, const char *fmt, ...);