xref: /linux/include/linux/miscdevice.h (revision 505d195b0f96fd613a51b13dde37aa5ad301eb32)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_MISCDEVICE_H
3 #define _LINUX_MISCDEVICE_H
4 #include <linux/major.h>
5 #include <linux/list.h>
6 #include <linux/types.h>
7 #include <linux/device.h>
8 
9 /*
10  *	These allocations are managed by device@lanana.org. If you need
11  *	an entry that is not assigned here, it can be moved and
12  *	reassigned or dynamically set if a fixed value is not justified.
13  */
14 
15 #define PSMOUSE_MINOR		1
16 #define MS_BUSMOUSE_MINOR	2	/* unused */
17 #define ATIXL_BUSMOUSE_MINOR	3	/* unused */
18 /*#define AMIGAMOUSE_MINOR	4	FIXME OBSOLETE */
19 #define ATARIMOUSE_MINOR	5	/* unused */
20 #define SUN_MOUSE_MINOR		6	/* unused */
21 #define APOLLO_MOUSE_MINOR	7	/* unused */
22 #define PC110PAD_MINOR		9	/* unused */
23 /*#define ADB_MOUSE_MINOR	10	FIXME OBSOLETE */
24 #define WATCHDOG_MINOR		130	/* Watchdog timer     */
25 #define TEMP_MINOR		131	/* Temperature Sensor */
26 #define APM_MINOR_DEV		134
27 #define RTC_MINOR		135
28 /*#define EFI_RTC_MINOR		136	was EFI Time services */
29 #define VHCI_MINOR		137
30 #define SUN_OPENPROM_MINOR	139
31 #define DMAPI_MINOR		140	/* unused */
32 #define NVRAM_MINOR		144
33 #define SBUS_FLASH_MINOR	152
34 #define SGI_MMTIMER		153
35 #define PMU_MINOR		154
36 #define STORE_QUEUE_MINOR	155	/* unused */
37 #define LCD_MINOR		156
38 #define AC_MINOR		157
39 #define BUTTON_MINOR		158	/* Major 10, Minor 158, /dev/nwbutton */
40 #define NWFLASH_MINOR		160	/* MAJOR is 10 - miscdevice */
41 #define ENVCTRL_MINOR		162
42 #define I2O_MINOR		166
43 #define UCTRL_MINOR		174
44 #define AGPGART_MINOR		175
45 #define TOSH_MINOR_DEV		181
46 #define HWRNG_MINOR		183
47 /*#define MICROCODE_MINOR	184	unused */
48 #define KEYPAD_MINOR		185
49 #define IRNET_MINOR		187
50 #define D7S_MINOR		193
51 #define VFIO_MINOR		196
52 #define PXA3XX_GCU_MINOR	197
53 #define TUN_MINOR		200
54 #define CUSE_MINOR		203
55 #define MPT_MINOR		220
56 #define MPT2SAS_MINOR		221
57 #define MPT3SAS_MINOR		222
58 #define UINPUT_MINOR		223
59 #define MISC_MCELOG_MINOR	227
60 #define HPET_MINOR		228
61 #define FUSE_MINOR		229
62 #define SNAPSHOT_MINOR		231
63 #define KVM_MINOR		232
64 #define BTRFS_MINOR		234
65 #define AUTOFS_MINOR		235
66 #define MAPPER_CTRL_MINOR	236
67 #define LOOP_CTRL_MINOR		237
68 #define VHOST_NET_MINOR		238
69 #define UHID_MINOR		239
70 #define USERIO_MINOR		240
71 #define VHOST_VSOCK_MINOR	241
72 #define EISA_EEPROM_MINOR	241
73 #define RFKILL_MINOR		242
74 
75 /*
76  * Misc char device minor code space division related to below macro:
77  *
78  * <  255  : Fixed minor code
79  * == 255  : Indicator to request dynamic minor code
80  * >  255  : Dynamic minor code requested, 1048320 minor codes totally.
81  */
82 #define MISC_DYNAMIC_MINOR	255
83 
84 struct miscdevice {
85 	int minor;
86 	const char *name;
87 	const struct file_operations *fops;
88 	struct list_head list;
89 	struct device *parent;
90 	struct device *this_device;
91 	const struct attribute_group **groups;
92 	const char *nodename;
93 	umode_t mode;
94 };
95 
96 extern int misc_register(struct miscdevice *misc);
97 extern void misc_deregister(struct miscdevice *misc);
98 
99 /*
100  * Helper macro for drivers that don't do anything special in the initcall.
101  * This helps to eliminate boilerplate code.
102  */
103 #define builtin_misc_device(__misc_device) \
104 	builtin_driver(__misc_device, misc_register)
105 
106 /*
107  * Helper macro for drivers that don't do anything special in module init / exit
108  * call. This helps to eliminate boilerplate code.
109  */
110 #define module_misc_device(__misc_device) \
111 	module_driver(__misc_device, misc_register, misc_deregister)
112 
113 #define MODULE_ALIAS_MISCDEV(minor)				\
114 	MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR)	\
115 	"-" __stringify(minor))
116 #endif
117