File Index
Files and directories
Sign in
FILE

device.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/device.h C
   1// SPDX-License-Identifier: GPL-2.0
   2/*
   3 * device.h - generic, centralized driver model
   4 *
   5 * Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
   6 * Copyright (c) 2004-2009 Greg Kroah-Hartman <gregkh@suse.de>
   7 * Copyright (c) 2008-2009 Novell Inc.
   8 *
   9 * See Documentation/driver-api/driver-model/ for more information.
  10 */
  11
  12#ifndef _DEVICE_H_
  13#define _DEVICE_H_
  14
  15#include <linux/dev_printk.h>
  16#include <linux/energy_model.h>
  17#include <linux/ioport.h>
  18#include <linux/kobject.h>
  19#include <linux/klist.h>
  20#include <linux/list.h>
  21#include <linux/lockdep.h>
  22#include <linux/compiler.h>
  23#include <linux/types.h>
  24#include <linux/mutex.h>
  25#include <linux/pm.h>
  26#include <linux/atomic.h>
  27#include <linux/uidgid.h>
  28#include <linux/gfp.h>
  29#include <linux/device/bus.h>
  30#include <linux/device/class.h>
  31#include <linux/device/devres.h>
  32#include <linux/device/driver.h>
  33#include <linux/cleanup.h>
  34#include <asm/device.h>
  35
  36struct device;
  37struct device_private;
  38struct device_driver;
  39struct driver_private;
  40struct module;
  41struct class;
  42struct subsys_private;
  43struct device_node;
  44struct fwnode_handle;
  45struct iommu_group;
  46struct dev_pin_info;
  47struct dev_iommu;
  48struct msi_device_data;
  49
  50/**
  51 * struct subsys_interface - interfaces to device functions
  52 * @name:       name of the device function
  53 * @subsys:     subsystem of the devices to attach to
  54 * @node:       the list of functions registered at the subsystem
  55 * @add_dev:    device hookup to device function handler
  56 * @remove_dev: device hookup to device function handler
  57 *
  58 * Simple interfaces attached to a subsystem. Multiple interfaces can
  59 * attach to a subsystem and its devices. Unlike drivers, they do not
  60 * exclusively claim or control devices. Interfaces usually represent
  61 * a specific functionality of a subsystem/class of devices.
  62 */
  63struct subsys_interface {
  64	const char *name;
  65	const struct bus_type *subsys;
  66	struct list_head node;
  67	int (*add_dev)(struct device *dev, struct subsys_interface *sif);
  68	void (*remove_dev)(struct device *dev, struct subsys_interface *sif);
  69};
  70
  71int subsys_interface_register(struct subsys_interface *sif);
  72void subsys_interface_unregister(struct subsys_interface *sif);
  73
  74int subsys_system_register(const struct bus_type *subsys,
  75			   const struct attribute_group **groups);
  76int subsys_virtual_register(const struct bus_type *subsys,
  77			    const struct attribute_group **groups);
  78
  79/*
  80 * The type of device, "struct device" is embedded in. A class
  81 * or bus can contain devices of different types
  82 * like "partitions" and "disks", "mouse" and "event".
  83 * This identifies the device type and carries type-specific
  84 * information, equivalent to the kobj_type of a kobject.
  85 * If "name" is specified, the uevent will contain it in
  86 * the DEVTYPE variable.
  87 */
  88struct device_type {
  89	const char *name;
  90	const struct attribute_group **groups;
  91	int (*uevent)(const struct device *dev, struct kobj_uevent_env *env);
  92	char *(*devnode)(const struct device *dev, umode_t *mode,
  93			 kuid_t *uid, kgid_t *gid);
  94	void (*release)(struct device *dev);
  95
  96	const struct dev_pm_ops *pm;
  97};
  98
  99/**
 100 * struct device_attribute - Interface for exporting device attributes.
 101 * @attr: sysfs attribute definition.
 102 * @show: Show handler.
 103 * @store: Store handler.
 104 */
 105struct device_attribute {
 106	struct attribute	attr;
 107	ssize_t (*show)(struct device *dev, struct device_attribute *attr,
 108			char *buf);
 109	ssize_t (*store)(struct device *dev, struct device_attribute *attr,
 110			 const char *buf, size_t count);
 111};
 112
 113/**
 114 * struct dev_ext_attribute - Exported device attribute with extra context.
 115 * @attr: Exported device attribute.
 116 * @var: Pointer to context.
 117 */
 118struct dev_ext_attribute {
 119	struct device_attribute attr;
 120	void *var;
 121};
 122
 123ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
 124			  char *buf);
 125ssize_t device_store_ulong(struct device *dev, struct device_attribute *attr,
 126			   const char *buf, size_t count);
 127ssize_t device_show_int(struct device *dev, struct device_attribute *attr,
 128			char *buf);
 129ssize_t device_store_int(struct device *dev, struct device_attribute *attr,
 130			 const char *buf, size_t count);
 131ssize_t device_show_bool(struct device *dev, struct device_attribute *attr,
 132			char *buf);
 133ssize_t device_store_bool(struct device *dev, struct device_attribute *attr,
 134			 const char *buf, size_t count);
 135ssize_t device_show_string(struct device *dev, struct device_attribute *attr,
 136			   char *buf);
 137
 138/**
 139 * DEVICE_ATTR - Define a device attribute.
 140 * @_name: Attribute name.
 141 * @_mode: File mode.
 142 * @_show: Show handler. Optional, but mandatory if attribute is readable.
 143 * @_store: Store handler. Optional, but mandatory if attribute is writable.
 144 *
 145 * Convenience macro for defining a struct device_attribute.
 146 *
 147 * For example, ``DEVICE_ATTR(foo, 0644, foo_show, foo_store);`` expands to:
 148 *
 149 * .. code-block:: c
 150 *
 151 *	struct device_attribute dev_attr_foo = {
 152 *		.attr	= { .name = "foo", .mode = 0644 },
 153 *		.show	= foo_show,
 154 *		.store	= foo_store,
 155 *	};
 156 */
 157#define DEVICE_ATTR(_name, _mode, _show, _store) \
 158	struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
 159
 160/**
 161 * DEVICE_ATTR_PREALLOC - Define a preallocated device attribute.
 162 * @_name: Attribute name.
 163 * @_mode: File mode.
 164 * @_show: Show handler. Optional, but mandatory if attribute is readable.
 165 * @_store: Store handler. Optional, but mandatory if attribute is writable.
 166 *
 167 * Like DEVICE_ATTR(), but ``SYSFS_PREALLOC`` is set on @_mode.
 168 */
 169#define DEVICE_ATTR_PREALLOC(_name, _mode, _show, _store) \
 170	struct device_attribute dev_attr_##_name = \
 171		__ATTR_PREALLOC(_name, _mode, _show, _store)
 172
 173/**
 174 * DEVICE_ATTR_RW - Define a read-write device attribute.
 175 * @_name: Attribute name.
 176 *
 177 * Like DEVICE_ATTR(), but @_mode is 0644, @_show is <_name>_show,
 178 * and @_store is <_name>_store.
 179 */
 180#define DEVICE_ATTR_RW(_name) \
 181	struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
 182
 183/**
 184 * DEVICE_ATTR_ADMIN_RW - Define an admin-only read-write device attribute.
 185 * @_name: Attribute name.
 186 *
 187 * Like DEVICE_ATTR_RW(), but @_mode is 0600.
 188 */
 189#define DEVICE_ATTR_ADMIN_RW(_name) \
 190	struct device_attribute dev_attr_##_name = __ATTR_RW_MODE(_name, 0600)
 191
 192/**
 193 * DEVICE_ATTR_RO - Define a readable device attribute.
 194 * @_name: Attribute name.
 195 *
 196 * Like DEVICE_ATTR(), but @_mode is 0444 and @_show is <_name>_show.
 197 */
 198#define DEVICE_ATTR_RO(_name) \
 199	struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
 200
 201/**
 202 * DEVICE_ATTR_ADMIN_RO - Define an admin-only readable device attribute.
 203 * @_name: Attribute name.
 204 *
 205 * Like DEVICE_ATTR_RO(), but @_mode is 0400.
 206 */
 207#define DEVICE_ATTR_ADMIN_RO(_name) \
 208	struct device_attribute dev_attr_##_name = __ATTR_RO_MODE(_name, 0400)
 209
 210/**
 211 * DEVICE_ATTR_WO - Define an admin-only writable device attribute.
 212 * @_name: Attribute name.
 213 *
 214 * Like DEVICE_ATTR(), but @_mode is 0200 and @_store is <_name>_store.
 215 */
 216#define DEVICE_ATTR_WO(_name) \
 217	struct device_attribute dev_attr_##_name = __ATTR_WO(_name)
 218
 219/**
 220 * DEVICE_ULONG_ATTR - Define a device attribute backed by an unsigned long.
 221 * @_name: Attribute name.
 222 * @_mode: File mode.
 223 * @_var: Identifier of unsigned long.
 224 *
 225 * Like DEVICE_ATTR(), but @_show and @_store are automatically provided
 226 * such that reads and writes to the attribute from userspace affect @_var.
 227 */
 228#define DEVICE_ULONG_ATTR(_name, _mode, _var) \
 229	struct dev_ext_attribute dev_attr_##_name = \
 230		{ __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) }
 231
 232/**
 233 * DEVICE_INT_ATTR - Define a device attribute backed by an int.
 234 * @_name: Attribute name.
 235 * @_mode: File mode.
 236 * @_var: Identifier of int.
 237 *
 238 * Like DEVICE_ULONG_ATTR(), but @_var is an int.
 239 */
 240#define DEVICE_INT_ATTR(_name, _mode, _var) \
 241	struct dev_ext_attribute dev_attr_##_name = \
 242		{ __ATTR(_name, _mode, device_show_int, device_store_int), &(_var) }
 243
 244/**
 245 * DEVICE_BOOL_ATTR - Define a device attribute backed by a bool.
 246 * @_name: Attribute name.
 247 * @_mode: File mode.
 248 * @_var: Identifier of bool.
 249 *
 250 * Like DEVICE_ULONG_ATTR(), but @_var is a bool.
 251 */
 252#define DEVICE_BOOL_ATTR(_name, _mode, _var) \
 253	struct dev_ext_attribute dev_attr_##_name = \
 254		{ __ATTR(_name, _mode, device_show_bool, device_store_bool), &(_var) }
 255
 256/**
 257 * DEVICE_STRING_ATTR_RO - Define a device attribute backed by a r/o string.
 258 * @_name: Attribute name.
 259 * @_mode: File mode.
 260 * @_var: Identifier of string.
 261 *
 262 * Like DEVICE_ULONG_ATTR(), but @_var is a string. Because the length of the
 263 * string allocation is unknown, the attribute must be read-only.
 264 */
 265#define DEVICE_STRING_ATTR_RO(_name, _mode, _var) \
 266	struct dev_ext_attribute dev_attr_##_name = \
 267		{ __ATTR(_name, (_mode) & ~0222, device_show_string, NULL), (_var) }
 268
 269#define DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \
 270	struct device_attribute dev_attr_##_name =		\
 271		__ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store)
 272
 273int device_create_file(struct device *device,
 274		       const struct device_attribute *entry);
 275void device_remove_file(struct device *dev,
 276			const struct device_attribute *attr);
 277bool device_remove_file_self(struct device *dev,
 278			     const struct device_attribute *attr);
 279int __must_check device_create_bin_file(struct device *dev,
 280					const struct bin_attribute *attr);
 281void device_remove_bin_file(struct device *dev,
 282			    const struct bin_attribute *attr);
 283
 284struct device_dma_parameters {
 285	/*
 286	 * a low level driver may set these to teach IOMMU code about
 287	 * sg limitations.
 288	 */
 289	unsigned int max_segment_size;
 290	unsigned int min_align_mask;
 291	unsigned long segment_boundary_mask;
 292};
 293
 294/**
 295 * enum device_link_state - Device link states.
 296 * @DL_STATE_NONE: The presence of the drivers is not being tracked.
 297 * @DL_STATE_DORMANT: None of the supplier/consumer drivers is present.
 298 * @DL_STATE_AVAILABLE: The supplier driver is present, but the consumer is not.
 299 * @DL_STATE_CONSUMER_PROBE: The consumer is probing (supplier driver present).
 300 * @DL_STATE_ACTIVE: Both the supplier and consumer drivers are present.
 301 * @DL_STATE_SUPPLIER_UNBIND: The supplier driver is unbinding.
 302 */
 303enum device_link_state {
 304	DL_STATE_NONE = -1,
 305	DL_STATE_DORMANT = 0,
 306	DL_STATE_AVAILABLE,
 307	DL_STATE_CONSUMER_PROBE,
 308	DL_STATE_ACTIVE,
 309	DL_STATE_SUPPLIER_UNBIND,
 310};
 311
 312/*
 313 * Device link flags.
 314 *
 315 * STATELESS: The core will not remove this link automatically.
 316 * AUTOREMOVE_CONSUMER: Remove the link automatically on consumer driver unbind.
 317 * PM_RUNTIME: If set, the runtime PM framework will use this link.
 318 * RPM_ACTIVE: Run pm_runtime_get_sync() on the supplier during link creation.
 319 * AUTOREMOVE_SUPPLIER: Remove the link automatically on supplier driver unbind.
 320 * AUTOPROBE_CONSUMER: Probe consumer driver automatically after supplier binds.
 321 * MANAGED: The core tracks presence of supplier/consumer drivers (internal).
 322 * SYNC_STATE_ONLY: Link only affects sync_state() behavior.
 323 * INFERRED: Inferred from data (eg: firmware) and not from driver actions.
 324 */
 325#define DL_FLAG_STATELESS		BIT(0)
 326#define DL_FLAG_AUTOREMOVE_CONSUMER	BIT(1)
 327#define DL_FLAG_PM_RUNTIME		BIT(2)
 328#define DL_FLAG_RPM_ACTIVE		BIT(3)
 329#define DL_FLAG_AUTOREMOVE_SUPPLIER	BIT(4)
 330#define DL_FLAG_AUTOPROBE_CONSUMER	BIT(5)
 331#define DL_FLAG_MANAGED			BIT(6)
 332#define DL_FLAG_SYNC_STATE_ONLY		BIT(7)
 333#define DL_FLAG_INFERRED		BIT(8)
 334#define DL_FLAG_CYCLE			BIT(9)
 335
 336/**
 337 * enum dl_dev_state - Device driver presence tracking information.
 338 * @DL_DEV_NO_DRIVER: There is no driver attached to the device.
 339 * @DL_DEV_PROBING: A driver is probing.
 340 * @DL_DEV_DRIVER_BOUND: The driver has been bound to the device.
 341 * @DL_DEV_UNBINDING: The driver is unbinding from the device.
 342 */
 343enum dl_dev_state {
 344	DL_DEV_NO_DRIVER = 0,
 345	DL_DEV_PROBING,
 346	DL_DEV_DRIVER_BOUND,
 347	DL_DEV_UNBINDING,
 348};
 349
 350/**
 351 * enum device_removable - Whether the device is removable. The criteria for a
 352 * device to be classified as removable is determined by its subsystem or bus.
 353 * @DEVICE_REMOVABLE_NOT_SUPPORTED: This attribute is not supported for this
 354 *				    device (default).
 355 * @DEVICE_REMOVABLE_UNKNOWN:  Device location is Unknown.
 356 * @DEVICE_FIXED: Device is not removable by the user.
 357 * @DEVICE_REMOVABLE: Device is removable by the user.
 358 */
 359enum device_removable {
 360	DEVICE_REMOVABLE_NOT_SUPPORTED = 0, /* must be 0 */
 361	DEVICE_REMOVABLE_UNKNOWN,
 362	DEVICE_FIXED,
 363	DEVICE_REMOVABLE,
 364};
 365
 366/**
 367 * struct dev_links_info - Device data related to device links.
 368 * @suppliers: List of links to supplier devices.
 369 * @consumers: List of links to consumer devices.
 370 * @defer_sync: Hook to global list of devices that have deferred sync_state.
 371 * @status: Driver status information.
 372 */
 373struct dev_links_info {
 374	struct list_head suppliers;
 375	struct list_head consumers;
 376	struct list_head defer_sync;
 377	enum dl_dev_state status;
 378};
 379
 380/**
 381 * struct dev_msi_info - Device data related to MSI
 382 * @domain:	The MSI interrupt domain associated to the device
 383 * @data:	Pointer to MSI device data
 384 */
 385struct dev_msi_info {
 386#ifdef CONFIG_GENERIC_MSI_IRQ
 387	struct irq_domain	*domain;
 388	struct msi_device_data	*data;
 389#endif
 390};
 391
 392/**
 393 * enum device_physical_location_panel - Describes which panel surface of the
 394 * system's housing the device connection point resides on.
 395 * @DEVICE_PANEL_TOP: Device connection point is on the top panel.
 396 * @DEVICE_PANEL_BOTTOM: Device connection point is on the bottom panel.
 397 * @DEVICE_PANEL_LEFT: Device connection point is on the left panel.
 398 * @DEVICE_PANEL_RIGHT: Device connection point is on the right panel.
 399 * @DEVICE_PANEL_FRONT: Device connection point is on the front panel.
 400 * @DEVICE_PANEL_BACK: Device connection point is on the back panel.
 401 * @DEVICE_PANEL_UNKNOWN: The panel with device connection point is unknown.
 402 */
 403enum device_physical_location_panel {
 404	DEVICE_PANEL_TOP,
 405	DEVICE_PANEL_BOTTOM,
 406	DEVICE_PANEL_LEFT,
 407	DEVICE_PANEL_RIGHT,
 408	DEVICE_PANEL_FRONT,
 409	DEVICE_PANEL_BACK,
 410	DEVICE_PANEL_UNKNOWN,
 411};
 412
 413/**
 414 * enum device_physical_location_vertical_position - Describes vertical
 415 * position of the device connection point on the panel surface.
 416 * @DEVICE_VERT_POS_UPPER: Device connection point is at upper part of panel.
 417 * @DEVICE_VERT_POS_CENTER: Device connection point is at center part of panel.
 418 * @DEVICE_VERT_POS_LOWER: Device connection point is at lower part of panel.
 419 */
 420enum device_physical_location_vertical_position {
 421	DEVICE_VERT_POS_UPPER,
 422	DEVICE_VERT_POS_CENTER,
 423	DEVICE_VERT_POS_LOWER,
 424};
 425
 426/**
 427 * enum device_physical_location_horizontal_position - Describes horizontal
 428 * position of the device connection point on the panel surface.
 429 * @DEVICE_HORI_POS_LEFT: Device connection point is at left part of panel.
 430 * @DEVICE_HORI_POS_CENTER: Device connection point is at center part of panel.
 431 * @DEVICE_HORI_POS_RIGHT: Device connection point is at right part of panel.
 432 */
 433enum device_physical_location_horizontal_position {
 434	DEVICE_HORI_POS_LEFT,
 435	DEVICE_HORI_POS_CENTER,
 436	DEVICE_HORI_POS_RIGHT,
 437};
 438
 439/**
 440 * struct device_physical_location - Device data related to physical location
 441 * of the device connection point.
 442 * @panel: Panel surface of the system's housing that the device connection
 443 *         point resides on.
 444 * @vertical_position: Vertical position of the device connection point within
 445 *                     the panel.
 446 * @horizontal_position: Horizontal position of the device connection point
 447 *                       within the panel.
 448 * @dock: Set if the device connection point resides in a docking station or
 449 *        port replicator.
 450 * @lid: Set if this device connection point resides on the lid of laptop
 451 *       system.
 452 */
 453struct device_physical_location {
 454	enum device_physical_location_panel panel;
 455	enum device_physical_location_vertical_position vertical_position;
 456	enum device_physical_location_horizontal_position horizontal_position;
 457	bool dock;
 458	bool lid;
 459};
 460
 461/**
 462 * struct device - The basic device structure
 463 * @parent:	The device's "parent" device, the device to which it is attached.
 464 * 		In most cases, a parent device is some sort of bus or host
 465 * 		controller. If parent is NULL, the device, is a top-level device,
 466 * 		which is not usually what you want.
 467 * @p:		Holds the private data of the driver core portions of the device.
 468 * 		See the comment of the struct device_private for detail.
 469 * @kobj:	A top-level, abstract class from which other classes are derived.
 470 * @init_name:	Initial name of the device.
 471 * @type:	The type of device.
 472 * 		This identifies the device type and carries type-specific
 473 * 		information.
 474 * @mutex:	Mutex to synchronize calls to its driver.
 475 * @bus:	Type of bus device is on.
 476 * @driver:	Which driver has allocated this
 477 * @platform_data: Platform data specific to the device.
 478 * 		Example: For devices on custom boards, as typical of embedded
 479 * 		and SOC based hardware, Linux often uses platform_data to point
 480 * 		to board-specific structures describing devices and how they
 481 * 		are wired.  That can include what ports are available, chip
 482 * 		variants, which GPIO pins act in what additional roles, and so
 483 * 		on.  This shrinks the "Board Support Packages" (BSPs) and
 484 * 		minimizes board-specific #ifdefs in drivers.
 485 * @driver_data: Private pointer for driver specific info.
 486 * @driver_override: Driver name to force a match.  Do not touch directly; use
 487 *		     device_set_driver_override() instead.
 488 * @links:	Links to suppliers and consumers of this device.
 489 * @power:	For device power management.
 490 *		See Documentation/driver-api/pm/devices.rst for details.
 491 * @pm_domain:	Provide callbacks that are executed during system suspend,
 492 * 		hibernation, system resume and during runtime PM transitions
 493 * 		along with subsystem-level and driver-level callbacks.
 494 * @em_pd:	device's energy model performance domain
 495 * @pins:	For device pin management.
 496 *		See Documentation/driver-api/pin-control.rst for details.
 497 * @msi:	MSI related data
 498 * @numa_node:	NUMA node this device is close to.
 499 * @dma_ops:    DMA mapping operations for this device.
 500 * @dma_mask:	Dma mask (if dma'ble device).
 501 * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all
 502 * 		hardware supports 64-bit addresses for consistent allocations
 503 * 		such descriptors.
 504 * @bus_dma_limit: Limit of an upstream bridge or bus which imposes a smaller
 505 *		DMA limit than the device itself supports.
 506 * @dma_range_map: map for DMA memory ranges relative to that of RAM
 507 * @dma_parms:	A low level driver may set these to teach IOMMU code about
 508 * 		segment limitations.
 509 * @dma_pools:	Dma pools (if dma'ble device).
 510 * @dma_mem:	Internal for coherent mem override.
 511 * @cma_area:	Contiguous memory area for dma allocations
 512 * @dma_io_tlb_mem: Software IO TLB allocator.  Not for driver use.
 513 * @dma_io_tlb_pools:	List of transient swiotlb memory pools.
 514 * @dma_io_tlb_lock:	Protects changes to the list of active pools.
 515 * @dma_uses_io_tlb: %true if device has used the software IO TLB.
 516 * @archdata:	For arch-specific additions.
 517 * @of_node:	Associated device tree node.
 518 * @fwnode:	Associated device node supplied by platform firmware.
 519 * @devt:	For creating the sysfs "dev".
 520 * @id:		device instance
 521 * @devres_lock: Spinlock to protect the resource of the device.
 522 * @devres_head: The resources list of the device.
 523 * @class:	The class of the device.
 524 * @groups:	Optional attribute groups.
 525 * @release:	Callback to free the device after all references have
 526 * 		gone away. This should be set by the allocator of the
 527 * 		device (i.e. the bus driver that discovered the device).
 528 * @iommu_group: IOMMU group the device belongs to.
 529 * @iommu:	Per device generic IOMMU runtime data
 530 * @physical_location: Describes physical location of the device connection
 531 *		point in the system housing.
 532 * @removable:  Whether the device can be removed from the system. This
 533 *              should be set by the subsystem / bus driver that discovered
 534 *              the device.
 535 *
 536 * @offline_disabled: If set, the device is permanently online.
 537 * @offline:	Set after successful invocation of bus type's .offline().
 538 * @of_node_reused: Set if the device-tree node is shared with an ancestor
 539 *              device.
 540 * @state_synced: The hardware state of this device has been synced to match
 541 *		  the software state of this device by calling the driver/bus
 542 *		  sync_state() callback.
 543 * @can_match:	The device has matched with a driver at least once or it is in
 544 *		a bus (like AMBA) which can't check for matching drivers until
 545 *		other devices probe successfully.
 546 * @dma_coherent: this particular device is dma coherent, even if the
 547 *		architecture supports non-coherent devices.
 548 * @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the
 549 *		streaming DMA operations (->map_* / ->unmap_* / ->sync_*),
 550 *		and optionall (if the coherent mask is large enough) also
 551 *		for dma allocations.  This flag is managed by the dma ops
 552 *		instance from ->dma_supported.
 553 * @dma_skip_sync: DMA sync operations can be skipped for coherent buffers.
 554 * @dma_iommu: Device is using default IOMMU implementation for DMA and
 555 *		doesn't rely on dma_ops structure.
 556 *
 557 * At the lowest level, every device in a Linux system is represented by an
 558 * instance of struct device. The device structure contains the information
 559 * that the device model core needs to model the system. Most subsystems,
 560 * however, track additional information about the devices they host. As a
 561 * result, it is rare for devices to be represented by bare device structures;
 562 * instead, that structure, like kobject structures, is usually embedded within
 563 * a higher-level representation of the device.
 564 */
 565struct device {
 566	struct kobject kobj;
 567	struct device		*parent;
 568
 569	struct device_private	*p;
 570
 571	const char		*init_name; /* initial name of the device */
 572	const struct device_type *type;
 573
 574	const struct bus_type	*bus;	/* type of bus device is on */
 575	struct device_driver *driver;	/* which driver has allocated this
 576					   device */
 577	void		*platform_data;	/* Platform specific data, device
 578					   core doesn't touch it */
 579	void		*driver_data;	/* Driver data, set and get with
 580					   dev_set_drvdata/dev_get_drvdata */
 581	struct {
 582		const char	*name;
 583		spinlock_t	lock;
 584	} driver_override;
 585	struct mutex		mutex;	/* mutex to synchronize calls to
 586					 * its driver.
 587					 */
 588
 589	struct dev_links_info	links;
 590	struct dev_pm_info	power;
 591	struct dev_pm_domain	*pm_domain;
 592
 593#ifdef CONFIG_ENERGY_MODEL
 594	struct em_perf_domain	*em_pd;
 595#endif
 596
 597#ifdef CONFIG_PINCTRL
 598	struct dev_pin_info	*pins;
 599#endif
 600	struct dev_msi_info	msi;
 601#ifdef CONFIG_ARCH_HAS_DMA_OPS
 602	const struct dma_map_ops *dma_ops;
 603#endif
 604	u64		*dma_mask;	/* dma mask (if dma'able device) */
 605	u64		coherent_dma_mask;/* Like dma_mask, but for
 606					     alloc_coherent mappings as
 607					     not all hardware supports
 608					     64 bit addresses for consistent
 609					     allocations such descriptors. */
 610	u64		bus_dma_limit;	/* upstream dma constraint */
 611	const struct bus_dma_region *dma_range_map;
 612
 613	struct device_dma_parameters *dma_parms;
 614
 615	struct list_head	dma_pools;	/* dma pools (if dma'ble) */
 616
 617#ifdef CONFIG_DMA_DECLARE_COHERENT
 618	struct dma_coherent_mem	*dma_mem; /* internal for coherent mem
 619					     override */
 620#endif
 621#ifdef CONFIG_DMA_CMA
 622	struct cma *cma_area;		/* contiguous memory area for dma
 623					   allocations */
 624#endif
 625#ifdef CONFIG_SWIOTLB
 626	struct io_tlb_mem *dma_io_tlb_mem;
 627#endif
 628#ifdef CONFIG_SWIOTLB_DYNAMIC
 629	struct list_head dma_io_tlb_pools;
 630	spinlock_t dma_io_tlb_lock;
 631	bool dma_uses_io_tlb;
 632#endif
 633	/* arch specific additions */
 634	struct dev_archdata	archdata;
 635
 636	struct device_node	*of_node; /* associated device tree node */
 637	struct fwnode_handle	*fwnode; /* firmware device node */
 638
 639#ifdef CONFIG_NUMA
 640	int		numa_node;	/* NUMA node this device is close to */
 641#endif
 642	dev_t			devt;	/* dev_t, creates the sysfs "dev" */
 643	u32			id;	/* device instance */
 644
 645	spinlock_t		devres_lock;
 646	struct list_head	devres_head;
 647
 648	const struct class	*class;
 649	const struct attribute_group **groups;	/* optional groups */
 650
 651	void	(*release)(struct device *dev);
 652	struct iommu_group	*iommu_group;
 653	struct dev_iommu	*iommu;
 654
 655	struct device_physical_location *physical_location;
 656
 657	enum device_removable	removable;
 658
 659	bool			offline_disabled:1;
 660	bool			offline:1;
 661	bool			of_node_reused:1;
 662	bool			state_synced:1;
 663	bool			can_match:1;
 664#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
 665    defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
 666    defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
 667	bool			dma_coherent:1;
 668#endif
 669#ifdef CONFIG_DMA_OPS_BYPASS
 670	bool			dma_ops_bypass : 1;
 671#endif
 672#ifdef CONFIG_DMA_NEED_SYNC
 673	bool			dma_skip_sync:1;
 674#endif
 675#ifdef CONFIG_IOMMU_DMA
 676	bool			dma_iommu:1;
 677#endif
 678};
 679
 680/**
 681 * struct device_link - Device link representation.
 682 * @supplier: The device on the supplier end of the link.
 683 * @s_node: Hook to the supplier device's list of links to consumers.
 684 * @consumer: The device on the consumer end of the link.
 685 * @c_node: Hook to the consumer device's list of links to suppliers.
 686 * @link_dev: device used to expose link details in sysfs
 687 * @status: The state of the link (with respect to the presence of drivers).
 688 * @flags: Link flags.
 689 * @rpm_active: Whether or not the consumer device is runtime-PM-active.
 690 * @kref: Count repeated addition of the same link.
 691 * @rm_work: Work structure used for removing the link.
 692 * @supplier_preactivated: Supplier has been made active before consumer probe.
 693 */
 694struct device_link {
 695	struct device *supplier;
 696	struct list_head s_node;
 697	struct device *consumer;
 698	struct list_head c_node;
 699	struct device link_dev;
 700	enum device_link_state status;
 701	u32 flags;
 702	refcount_t rpm_active;
 703	struct kref kref;
 704	struct work_struct rm_work;
 705	bool supplier_preactivated; /* Owned by consumer probe. */
 706};
 707
 708#define kobj_to_dev(__kobj)	container_of_const(__kobj, struct device, kobj)
 709
 710int __device_set_driver_override(struct device *dev, const char *s, size_t len);
 711
 712/**
 713 * device_set_driver_override() - Helper to set or clear driver override.
 714 * @dev: Device to change
 715 * @s: NUL-terminated string, new driver name to force a match, pass empty
 716 *     string to clear it ("" or "\n", where the latter is only for sysfs
 717 *     interface).
 718 *
 719 * Helper to set or clear driver override of a device.
 720 *
 721 * Returns: 0 on success or a negative error code on failure.
 722 */
 723static inline int device_set_driver_override(struct device *dev, const char *s)
 724{
 725	return __device_set_driver_override(dev, s, s ? strlen(s) : 0);
 726}
 727
 728/**
 729 * device_has_driver_override() - Check if a driver override has been set.
 730 * @dev: device to check
 731 *
 732 * Returns true if a driver override has been set for this device.
 733 */
 734static inline bool device_has_driver_override(struct device *dev)
 735{
 736	guard(spinlock)(&dev->driver_override.lock);
 737	return !!dev->driver_override.name;
 738}
 739
 740/**
 741 * device_match_driver_override() - Match a driver against the device's driver_override.
 742 * @dev: device to check
 743 * @drv: driver to match against
 744 *
 745 * Returns > 0 if a driver override is set and matches the given driver, 0 if a
 746 * driver override is set but does not match, or < 0 if a driver override is not
 747 * set at all.
 748 */
 749static inline int device_match_driver_override(struct device *dev,
 750					       const struct device_driver *drv)
 751{
 752	guard(spinlock)(&dev->driver_override.lock);
 753	if (dev->driver_override.name)
 754		return !strcmp(dev->driver_override.name, drv->name);
 755	return -1;
 756}
 757
 758/**
 759 * device_iommu_mapped - Returns true when the device DMA is translated
 760 *			 by an IOMMU
 761 * @dev: Device to perform the check on
 762 */
 763static inline bool device_iommu_mapped(struct device *dev)
 764{
 765	return (dev->iommu_group != NULL);
 766}
 767
 768/* Get the wakeup routines, which depend on struct device */
 769#include <linux/pm_wakeup.h>
 770
 771/**
 772 * dev_name - Return a device's name.
 773 * @dev: Device with name to get.
 774 * Return: The kobject name of the device, or its initial name if unavailable.
 775 */
 776static inline const char *dev_name(const struct device *dev)
 777{
 778	/* Use the init name until the kobject becomes available */
 779	if (dev->init_name)
 780		return dev->init_name;
 781
 782	return kobject_name(&dev->kobj);
 783}
 784
 785/**
 786 * dev_bus_name - Return a device's bus/class name, if at all possible
 787 * @dev: struct device to get the bus/class name of
 788 *
 789 * Will return the name of the bus/class the device is attached to.  If it is
 790 * not attached to a bus/class, an empty string will be returned.
 791 */
 792static inline const char *dev_bus_name(const struct device *dev)
 793{
 794	return dev->bus ? dev->bus->name : (dev->class ? dev->class->name : "");
 795}
 796
 797__printf(2, 3) int dev_set_name(struct device *dev, const char *name, ...);
 798
 799#ifdef CONFIG_NUMA
 800static inline int dev_to_node(struct device *dev)
 801{
 802	return dev->numa_node;
 803}
 804static inline void set_dev_node(struct device *dev, int node)
 805{
 806	dev->numa_node = node;
 807}
 808#else
 809static inline int dev_to_node(struct device *dev)
 810{
 811	return NUMA_NO_NODE;
 812}
 813static inline void set_dev_node(struct device *dev, int node)
 814{
 815}
 816#endif
 817
 818static inline struct irq_domain *dev_get_msi_domain(const struct device *dev)
 819{
 820#ifdef CONFIG_GENERIC_MSI_IRQ
 821	return dev->msi.domain;
 822#else
 823	return NULL;
 824#endif
 825}
 826
 827static inline void dev_set_msi_domain(struct device *dev, struct irq_domain *d)
 828{
 829#ifdef CONFIG_GENERIC_MSI_IRQ
 830	dev->msi.domain = d;
 831#endif
 832}
 833
 834static inline void *dev_get_drvdata(const struct device *dev)
 835{
 836	return dev->driver_data;
 837}
 838
 839static inline void dev_set_drvdata(struct device *dev, void *data)
 840{
 841	dev->driver_data = data;
 842}
 843
 844static inline struct pm_subsys_data *dev_to_psd(struct device *dev)
 845{
 846	return dev ? dev->power.subsys_data : NULL;
 847}
 848
 849static inline unsigned int dev_get_uevent_suppress(const struct device *dev)
 850{
 851	return dev->kobj.uevent_suppress;
 852}
 853
 854static inline void dev_set_uevent_suppress(struct device *dev, int val)
 855{
 856	dev->kobj.uevent_suppress = val;
 857}
 858
 859static inline int device_is_registered(struct device *dev)
 860{
 861	return dev->kobj.state_in_sysfs;
 862}
 863
 864static inline void device_enable_async_suspend(struct device *dev)
 865{
 866	if (!dev->power.is_prepared)
 867		dev->power.async_suspend = true;
 868}
 869
 870static inline void device_disable_async_suspend(struct device *dev)
 871{
 872	if (!dev->power.is_prepared)
 873		dev->power.async_suspend = false;
 874}
 875
 876static inline bool device_async_suspend_enabled(struct device *dev)
 877{
 878	return !!dev->power.async_suspend;
 879}
 880
 881static inline bool device_pm_not_required(struct device *dev)
 882{
 883	return dev->power.no_pm;
 884}
 885
 886static inline void device_set_pm_not_required(struct device *dev)
 887{
 888	dev->power.no_pm = true;
 889#ifdef CONFIG_PM
 890	dev->power.no_callbacks = true;
 891#endif
 892}
 893
 894static inline void dev_pm_syscore_device(struct device *dev, bool val)
 895{
 896#ifdef CONFIG_PM_SLEEP
 897	dev->power.syscore = val;
 898#endif
 899}
 900
 901static inline void dev_pm_set_driver_flags(struct device *dev, u32 flags)
 902{
 903	dev->power.driver_flags = flags;
 904}
 905
 906static inline bool dev_pm_test_driver_flags(struct device *dev, u32 flags)
 907{
 908	return !!(dev->power.driver_flags & flags);
 909}
 910
 911static inline bool dev_pm_smart_suspend(struct device *dev)
 912{
 913#ifdef CONFIG_PM_SLEEP
 914	return dev->power.smart_suspend;
 915#else
 916	return false;
 917#endif
 918}
 919
 920/*
 921 * dev_pm_set_strict_midlayer - Update the device's power.strict_midlayer flag
 922 * @dev: Target device.
 923 * @val: New flag value.
 924 *
 925 * When set, power.strict_midlayer means that the middle layer power management
 926 * code (typically, a bus type or a PM domain) does not expect its runtime PM
 927 * suspend callback to be invoked at all during system-wide PM transitions and
 928 * it does not expect its runtime PM resume callback to be invoked at any point
 929 * when runtime PM is disabled for the device during system-wide PM transitions.
 930 */
 931static inline void dev_pm_set_strict_midlayer(struct device *dev, bool val)
 932{
 933#ifdef CONFIG_PM_SLEEP
 934	dev->power.strict_midlayer = val;
 935#endif
 936}
 937
 938static inline bool dev_pm_strict_midlayer_is_set(struct device *dev)
 939{
 940#ifdef CONFIG_PM_SLEEP
 941	return dev->power.strict_midlayer;
 942#else
 943	return false;
 944#endif
 945}
 946
 947static inline void device_lock(struct device *dev)
 948{
 949	mutex_lock(&dev->mutex);
 950}
 951
 952static inline int device_lock_interruptible(struct device *dev)
 953{
 954	return mutex_lock_interruptible(&dev->mutex);
 955}
 956
 957static inline int device_trylock(struct device *dev)
 958{
 959	return mutex_trylock(&dev->mutex);
 960}
 961
 962static inline void device_unlock(struct device *dev)
 963{
 964	mutex_unlock(&dev->mutex);
 965}
 966
 967DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T))
 968
 969static inline void device_lock_assert(struct device *dev)
 970{
 971	lockdep_assert_held(&dev->mutex);
 972}
 973
 974static inline bool dev_has_sync_state(struct device *dev)
 975{
 976	if (!dev)
 977		return false;
 978	if (dev->driver && dev->driver->sync_state)
 979		return true;
 980	if (dev->bus && dev->bus->sync_state)
 981		return true;
 982	return false;
 983}
 984
 985static inline int dev_set_drv_sync_state(struct device *dev,
 986					 void (*fn)(struct device *dev))
 987{
 988	if (!dev || !dev->driver)
 989		return 0;
 990	if (dev->driver->sync_state && dev->driver->sync_state != fn)
 991		return -EBUSY;
 992	if (!dev->driver->sync_state)
 993		dev->driver->sync_state = fn;
 994	return 0;
 995}
 996
 997static inline void dev_set_removable(struct device *dev,
 998				     enum device_removable removable)
 999{
1000	dev->removable = removable;
1001}
1002
1003static inline bool dev_is_removable(struct device *dev)
1004{
1005	return dev->removable == DEVICE_REMOVABLE;
1006}
1007
1008static inline bool dev_removable_is_valid(struct device *dev)
1009{
1010	return dev->removable != DEVICE_REMOVABLE_NOT_SUPPORTED;
1011}
1012
1013/*
1014 * High level routines for use by the bus drivers
1015 */
1016int __must_check device_register(struct device *dev);
1017void device_unregister(struct device *dev);
1018void device_initialize(struct device *dev);
1019int __must_check device_add(struct device *dev);
1020void device_del(struct device *dev);
1021
1022DEFINE_FREE(device_del, struct device *, if (_T) device_del(_T))
1023
1024int device_for_each_child(struct device *parent, void *data,
1025			  device_iter_t fn);
1026int device_for_each_child_reverse(struct device *parent, void *data,
1027				  device_iter_t fn);
1028int device_for_each_child_reverse_from(struct device *parent,
1029				       struct device *from, void *data,
1030				       device_iter_t fn);
1031struct device *device_find_child(struct device *parent, const void *data,
1032				 device_match_t match);
1033/**
1034 * device_find_child_by_name - device iterator for locating a child device.
1035 * @parent: parent struct device
1036 * @name: name of the child device
1037 *
1038 * This is similar to the device_find_child() function above, but it
1039 * returns a reference to a device that has the name @name.
1040 *
1041 * NOTE: you will need to drop the reference with put_device() after use.
1042 */
1043static inline struct device *device_find_child_by_name(struct device *parent,
1044						       const char *name)
1045{
1046	return device_find_child(parent, name, device_match_name);
1047}
1048
1049/**
1050 * device_find_any_child - device iterator for locating a child device, if any.
1051 * @parent: parent struct device
1052 *
1053 * This is similar to the device_find_child() function above, but it
1054 * returns a reference to a child device, if any.
1055 *
1056 * NOTE: you will need to drop the reference with put_device() after use.
1057 */
1058static inline struct device *device_find_any_child(struct device *parent)
1059{
1060	return device_find_child(parent, NULL, device_match_any);
1061}
1062
1063int device_rename(struct device *dev, const char *new_name);
1064int device_move(struct device *dev, struct device *new_parent,
1065		enum dpm_order dpm_order);
1066int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);
1067
1068static inline bool device_supports_offline(struct device *dev)
1069{
1070	return dev->bus && dev->bus->offline && dev->bus->online;
1071}
1072
1073#define __device_lock_set_class(dev, name, key)                        \
1074do {                                                                   \
1075	struct device *__d2 __maybe_unused = dev;                      \
1076	lock_set_class(&__d2->mutex.dep_map, name, key, 0, _THIS_IP_); \
1077} while (0)
1078
1079/**
1080 * device_lock_set_class - Specify a temporary lock class while a device
1081 *			   is attached to a driver
1082 * @dev: device to modify
1083 * @key: lock class key data
1084 *
1085 * This must be called with the device_lock() already held, for example
1086 * from driver ->probe(). Take care to only override the default
1087 * lockdep_no_validate class.
1088 */
1089#ifdef CONFIG_LOCKDEP
1090#define device_lock_set_class(dev, key)                                    \
1091do {                                                                       \
1092	struct device *__d = dev;                                          \
1093	dev_WARN_ONCE(__d, !lockdep_match_class(&__d->mutex,               \
1094						&__lockdep_no_validate__), \
1095		 "overriding existing custom lock class\n");               \
1096	__device_lock_set_class(__d, #key, key);                           \
1097} while (0)
1098#else
1099#define device_lock_set_class(dev, key) __device_lock_set_class(dev, #key, key)
1100#endif
1101
1102/**
1103 * device_lock_reset_class - Return a device to the default lockdep novalidate state
1104 * @dev: device to modify
1105 *
1106 * This must be called with the device_lock() already held, for example
1107 * from driver ->remove().
1108 */
1109#define device_lock_reset_class(dev) \
1110do { \
1111	struct device *__d __maybe_unused = dev;                       \
1112	lock_set_novalidate_class(&__d->mutex.dep_map, "&dev->mutex",  \
1113				  _THIS_IP_);                          \
1114} while (0)
1115
1116void lock_device_hotplug(void);
1117void unlock_device_hotplug(void);
1118int lock_device_hotplug_sysfs(void);
1119int device_offline(struct device *dev);
1120int device_online(struct device *dev);
1121
1122void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
1123void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
1124void device_set_node(struct device *dev, struct fwnode_handle *fwnode);
1125int device_add_of_node(struct device *dev, struct device_node *of_node);
1126void device_remove_of_node(struct device *dev);
1127void device_set_of_node_from_dev(struct device *dev, const struct device *dev2);
1128struct device *get_dev_from_fwnode(struct fwnode_handle *fwnode);
1129
1130static inline struct device_node *dev_of_node(struct device *dev)
1131{
1132	if (!IS_ENABLED(CONFIG_OF) || !dev)
1133		return NULL;
1134	return dev->of_node;
1135}
1136
1137static inline int dev_num_vf(struct device *dev)
1138{
1139	if (dev->bus && dev->bus->num_vf)
1140		return dev->bus->num_vf(dev);
1141	return 0;
1142}
1143
1144/*
1145 * Root device objects for grouping under /sys/devices
1146 */
1147struct device *__root_device_register(const char *name, struct module *owner);
1148
1149/* This is a macro to avoid include problems with THIS_MODULE */
1150#define root_device_register(name) \
1151	__root_device_register(name, THIS_MODULE)
1152
1153void root_device_unregister(struct device *root);
1154
1155static inline void *dev_get_platdata(const struct device *dev)
1156{
1157	return dev->platform_data;
1158}
1159
1160/*
1161 * Manual binding of a device to driver. See drivers/base/bus.c
1162 * for information on use.
1163 */
1164int __must_check device_driver_attach(const struct device_driver *drv,
1165				      struct device *dev);
1166int __must_check device_bind_driver(struct device *dev);
1167void device_release_driver(struct device *dev);
1168int  __must_check device_attach(struct device *dev);
1169int __must_check driver_attach(const struct device_driver *drv);
1170void device_initial_probe(struct device *dev);
1171int __must_check device_reprobe(struct device *dev);
1172
1173bool device_is_bound(struct device *dev);
1174
1175/*
1176 * Easy functions for dynamically creating devices on the fly
1177 */
1178__printf(5, 6) struct device *
1179device_create(const struct class *cls, struct device *parent, dev_t devt,
1180	      void *drvdata, const char *fmt, ...);
1181__printf(6, 7) struct device *
1182device_create_with_groups(const struct class *cls, struct device *parent, dev_t devt,
1183			  void *drvdata, const struct attribute_group **groups,
1184			  const char *fmt, ...);
1185void device_destroy(const struct class *cls, dev_t devt);
1186
1187int __must_check device_add_groups(struct device *dev,
1188				   const struct attribute_group **groups);
1189void device_remove_groups(struct device *dev,
1190			  const struct attribute_group **groups);
1191
1192static inline int __must_check device_add_group(struct device *dev,
1193					const struct attribute_group *grp)
1194{
1195	const struct attribute_group *groups[] = { grp, NULL };
1196
1197	return device_add_groups(dev, groups);
1198}
1199
1200static inline void device_remove_group(struct device *dev,
1201				       const struct attribute_group *grp)
1202{
1203	const struct attribute_group *groups[] = { grp, NULL };
1204
1205	device_remove_groups(dev, groups);
1206}
1207
1208int __must_check devm_device_add_group(struct device *dev,
1209				       const struct attribute_group *grp);
1210
1211/*
1212 * get_device - atomically increment the reference count for the device.
1213 *
1214 */
1215struct device *get_device(struct device *dev);
1216void put_device(struct device *dev);
1217
1218DEFINE_FREE(put_device, struct device *, if (_T) put_device(_T))
1219
1220bool kill_device(struct device *dev);
1221
1222#ifdef CONFIG_DEVTMPFS
1223int devtmpfs_mount(void);
1224#else
1225static inline int devtmpfs_mount(void) { return 0; }
1226#endif
1227
1228/* drivers/base/power/shutdown.c */
1229void device_shutdown(void);
1230
1231/* debugging and troubleshooting/diagnostic helpers. */
1232const char *dev_driver_string(const struct device *dev);
1233
1234/* Device links interface. */
1235struct device_link *device_link_add(struct device *consumer,
1236				    struct device *supplier, u32 flags);
1237void device_link_del(struct device_link *link);
1238void device_link_remove(void *consumer, struct device *supplier);
1239void device_links_supplier_sync_state_pause(void);
1240void device_links_supplier_sync_state_resume(void);
1241void device_link_wait_removal(void);
1242
1243static inline bool device_link_test(const struct device_link *link, u32 flags)
1244{
1245	return !!(link->flags & flags);
1246}
1247
1248/* Create alias, so I can be autoloaded. */
1249#define MODULE_ALIAS_CHARDEV(major,minor) \
1250	MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
1251#define MODULE_ALIAS_CHARDEV_MAJOR(major) \
1252	MODULE_ALIAS("char-major-" __stringify(major) "-*")
1253
1254#endif /* _DEVICE_H_ */
~/ Read-only file preview.