2005-04-17 06:20:36 +08:00
|
|
|
#ifndef _LINUX_MISCDEVICE_H
|
|
|
|
#define _LINUX_MISCDEVICE_H
|
|
|
|
#include <linux/major.h>
|
2011-08-30 03:22:17 +08:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/types.h>
|
2016-08-26 01:00:49 +08:00
|
|
|
#include <linux/device.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-06-09 16:39:49 +08:00
|
|
|
/*
|
|
|
|
* These allocations are managed by device@lanana.org. If you use an
|
|
|
|
* entry that is not in assigned your entry may well be moved and
|
|
|
|
* reassigned, or set dynamic if a fixed value is not justified.
|
|
|
|
*/
|
|
|
|
|
2008-11-26 19:03:54 +08:00
|
|
|
#define PSMOUSE_MINOR 1
|
2014-02-18 13:27:24 +08:00
|
|
|
#define MS_BUSMOUSE_MINOR 2 /* unused */
|
|
|
|
#define ATIXL_BUSMOUSE_MINOR 3 /* unused */
|
2008-11-26 19:03:54 +08:00
|
|
|
/*#define AMIGAMOUSE_MINOR 4 FIXME OBSOLETE */
|
2014-02-18 13:27:24 +08:00
|
|
|
#define ATARIMOUSE_MINOR 5 /* unused */
|
|
|
|
#define SUN_MOUSE_MINOR 6 /* unused */
|
|
|
|
#define APOLLO_MOUSE_MINOR 7 /* unused */
|
|
|
|
#define PC110PAD_MINOR 9 /* unused */
|
2008-11-26 19:03:54 +08:00
|
|
|
/*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */
|
2005-04-17 06:20:36 +08:00
|
|
|
#define WATCHDOG_MINOR 130 /* Watchdog timer */
|
|
|
|
#define TEMP_MINOR 131 /* Temperature Sensor */
|
2016-12-16 03:36:33 +08:00
|
|
|
#define APM_MINOR_DEV 134
|
2008-11-26 19:03:54 +08:00
|
|
|
#define RTC_MINOR 135
|
2005-04-17 06:20:36 +08:00
|
|
|
#define EFI_RTC_MINOR 136 /* EFI Time services */
|
2014-02-18 13:19:26 +08:00
|
|
|
#define VHCI_MINOR 137
|
2008-11-26 19:03:54 +08:00
|
|
|
#define SUN_OPENPROM_MINOR 139
|
2014-02-18 13:27:24 +08:00
|
|
|
#define DMAPI_MINOR 140 /* unused */
|
2008-11-26 19:03:54 +08:00
|
|
|
#define NVRAM_MINOR 144
|
|
|
|
#define SGI_MMTIMER 153
|
2014-02-18 13:27:24 +08:00
|
|
|
#define STORE_QUEUE_MINOR 155 /* unused */
|
2008-11-26 19:03:54 +08:00
|
|
|
#define I2O_MINOR 166
|
2016-12-13 22:51:13 +08:00
|
|
|
#define HWRNG_MINOR 183
|
2005-04-17 06:20:36 +08:00
|
|
|
#define MICROCODE_MINOR 184
|
2016-12-15 18:42:48 +08:00
|
|
|
#define IRNET_MINOR 187
|
2013-12-20 01:17:11 +08:00
|
|
|
#define VFIO_MINOR 196
|
2008-11-26 19:03:54 +08:00
|
|
|
#define TUN_MINOR 200
|
2013-09-10 02:18:27 +08:00
|
|
|
#define CUSE_MINOR 203
|
2008-11-26 19:03:54 +08:00
|
|
|
#define MWAVE_MINOR 219 /* ACP/Mwave Modem */
|
|
|
|
#define MPT_MINOR 220
|
2009-03-09 15:27:49 +08:00
|
|
|
#define MPT2SAS_MINOR 221
|
2012-11-30 10:28:10 +08:00
|
|
|
#define MPT3SAS_MINOR 222
|
2010-08-20 00:52:28 +08:00
|
|
|
#define UINPUT_MINOR 223
|
2012-06-07 19:56:51 +08:00
|
|
|
#define MISC_MCELOG_MINOR 227
|
2008-11-26 19:03:54 +08:00
|
|
|
#define HPET_MINOR 228
|
|
|
|
#define FUSE_MINOR 229
|
|
|
|
#define KVM_MINOR 232
|
driver core: add devname module aliases to allow module on-demand auto-loading
This adds:
alias: devname:<name>
to some common kernel modules, which will allow the on-demand loading
of the kernel module when the device node is accessed.
Ideally all these modules would be compiled-in, but distros seems too
much in love with their modularization that we need to cover the common
cases with this new facility. It will allow us to remove a bunch of pretty
useless init scripts and modprobes from init scripts.
The static device node aliases will be carried in the module itself. The
program depmod will extract this information to a file in the module directory:
$ cat /lib/modules/2.6.34-00650-g537b60d-dirty/modules.devname
# Device nodes to trigger on-demand module loading.
microcode cpu/microcode c10:184
fuse fuse c10:229
ppp_generic ppp c108:0
tun net/tun c10:200
dm_mod mapper/control c10:235
Udev will pick up the depmod created file on startup and create all the
static device nodes which the kernel modules specify, so that these modules
get automatically loaded when the device node is accessed:
$ /sbin/udevd --debug
...
static_dev_create_from_modules: mknod '/dev/cpu/microcode' c10:184
static_dev_create_from_modules: mknod '/dev/fuse' c10:229
static_dev_create_from_modules: mknod '/dev/ppp' c108:0
static_dev_create_from_modules: mknod '/dev/net/tun' c10:200
static_dev_create_from_modules: mknod '/dev/mapper/control' c10:235
udev_rules_apply_static_dev_perms: chmod '/dev/net/tun' 0666
udev_rules_apply_static_dev_perms: chmod '/dev/fuse' 0666
A few device nodes are switched to statically allocated numbers, to allow
the static nodes to work. This might also useful for systems which still run
a plain static /dev, which is completely unsafe to use with any dynamic minor
numbers.
Note:
The devname aliases must be limited to the *common* and *single*instance*
device nodes, like the misc devices, and never be used for conceptually limited
systems like the loop devices, which should rather get fixed properly and get a
control node for losetup to talk to, instead of creating a random number of
device nodes in advance, regardless if they are ever used.
This facility is to hide the mess distros are creating with too modualized
kernels, and just to hide that these modules are not compiled-in, and not to
paper-over broken concepts. Thanks! :)
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: David S. Miller <davem@davemloft.net>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Alasdair G Kergon <agk@redhat.com>
Cc: Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
Cc: Ian Kent <raven@themaw.net>
Signed-Off-By: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-05-21 00:07:20 +08:00
|
|
|
#define BTRFS_MINOR 234
|
|
|
|
#define AUTOFS_MINOR 235
|
2010-08-12 11:14:05 +08:00
|
|
|
#define MAPPER_CTRL_MINOR 236
|
loop: add management interface for on-demand device allocation
Loop devices today have a fixed pre-allocated number of usually 8.
The number can only be changed at module init time. To find a free
device to use, /dev/loop%i needs to be scanned, and all devices need
to be opened until a free one is possibly found.
This adds a new /dev/loop-control device node, that allows to
dynamically find or allocate a free device, and to add and remove loop
devices from the running system:
LOOP_CTL_ADD adds a specific device. Arg is the number
of the device. It returns the device i or a negative
error code.
LOOP_CTL_REMOVE removes a specific device, Arg is the
number the device. It returns the device i or a negative
error code.
LOOP_CTL_GET_FREE finds the next unbound device or allocates
a new one. No arg is given. It returns the device i or a
negative error code.
The loop kernel module gets automatically loaded when
/dev/loop-control is accessed the first time. The alias
specified in the module, instructs udev to create this
'dead' device node, even when the module is not loaded.
Example:
cfd = open("/dev/loop-control", O_RDWR);
# add a new specific loop device
err = ioctl(cfd, LOOP_CTL_ADD, devnr);
# remove a specific loop device
err = ioctl(cfd, LOOP_CTL_REMOVE, devnr);
# find or allocate a free loop device to use
devnr = ioctl(cfd, LOOP_CTL_GET_FREE);
sprintf(loopname, "/dev/loop%i", devnr);
ffd = open("backing-file", O_RDWR);
lfd = open(loopname, O_RDWR);
err = ioctl(lfd, LOOP_SET_FD, ffd);
Cc: Tejun Heo <tj@kernel.org>
Cc: Karel Zak <kzak@redhat.com>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
2011-08-01 04:08:04 +08:00
|
|
|
#define LOOP_CTRL_MINOR 237
|
2012-01-12 03:30:38 +08:00
|
|
|
#define VHOST_NET_MINOR 238
|
2013-09-10 00:33:54 +08:00
|
|
|
#define UHID_MINOR 239
|
2015-10-25 04:10:29 +08:00
|
|
|
#define USERIO_MINOR 240
|
2008-11-26 19:03:54 +08:00
|
|
|
#define MISC_DYNAMIC_MINOR 255
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct device;
|
2015-02-02 22:44:54 +08:00
|
|
|
struct attribute_group;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct miscdevice {
|
|
|
|
int minor;
|
|
|
|
const char *name;
|
2006-03-28 17:56:41 +08:00
|
|
|
const struct file_operations *fops;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct list_head list;
|
2006-07-28 07:16:04 +08:00
|
|
|
struct device *parent;
|
|
|
|
struct device *this_device;
|
2015-02-02 22:44:54 +08:00
|
|
|
const struct attribute_group **groups;
|
2009-09-19 05:01:12 +08:00
|
|
|
const char *nodename;
|
2011-07-26 16:47:38 +08:00
|
|
|
umode_t mode;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2014-05-16 16:36:13 +08:00
|
|
|
extern int misc_register(struct miscdevice *misc);
|
2015-07-31 06:59:57 +08:00
|
|
|
extern void misc_deregister(struct miscdevice *misc);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-10-23 06:36:05 +08:00
|
|
|
/*
|
|
|
|
* Helper macro for drivers that don't do anything special in the initcall.
|
|
|
|
* This helps in eleminating of boilerplate code.
|
|
|
|
*/
|
|
|
|
#define builtin_misc_device(__misc_device) \
|
|
|
|
builtin_driver(__misc_device, misc_register)
|
|
|
|
|
2016-08-26 01:00:49 +08:00
|
|
|
/*
|
|
|
|
* Helper macro for drivers that don't do anything special in module init / exit
|
|
|
|
* call. This helps in eleminating of boilerplate code.
|
|
|
|
*/
|
|
|
|
#define module_misc_device(__misc_device) \
|
|
|
|
module_driver(__misc_device, misc_register, misc_deregister)
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#define MODULE_ALIAS_MISCDEV(minor) \
|
|
|
|
MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR) \
|
|
|
|
"-" __stringify(minor))
|
|
|
|
#endif
|