2005-04-17 05:20:36 +07:00
|
|
|
#ifndef _LINUX_MISCDEVICE_H
|
|
|
|
#define _LINUX_MISCDEVICE_H
|
|
|
|
#include <linux/major.h>
|
2011-08-30 02:22:17 +07:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/types.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-06-09 15:39:49 +07: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 18:03:54 +07:00
|
|
|
#define PSMOUSE_MINOR 1
|
2014-02-18 12:27:24 +07:00
|
|
|
#define MS_BUSMOUSE_MINOR 2 /* unused */
|
|
|
|
#define ATIXL_BUSMOUSE_MINOR 3 /* unused */
|
2008-11-26 18:03:54 +07:00
|
|
|
/*#define AMIGAMOUSE_MINOR 4 FIXME OBSOLETE */
|
2014-02-18 12:27:24 +07: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 18:03:54 +07:00
|
|
|
/*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */
|
2005-04-17 05:20:36 +07:00
|
|
|
#define WATCHDOG_MINOR 130 /* Watchdog timer */
|
|
|
|
#define TEMP_MINOR 131 /* Temperature Sensor */
|
2008-11-26 18:03:54 +07:00
|
|
|
#define RTC_MINOR 135
|
2005-04-17 05:20:36 +07:00
|
|
|
#define EFI_RTC_MINOR 136 /* EFI Time services */
|
2014-02-18 12:19:26 +07:00
|
|
|
#define VHCI_MINOR 137
|
2008-11-26 18:03:54 +07:00
|
|
|
#define SUN_OPENPROM_MINOR 139
|
2014-02-18 12:27:24 +07:00
|
|
|
#define DMAPI_MINOR 140 /* unused */
|
2008-11-26 18:03:54 +07:00
|
|
|
#define NVRAM_MINOR 144
|
|
|
|
#define SGI_MMTIMER 153
|
2014-02-18 12:27:24 +07:00
|
|
|
#define STORE_QUEUE_MINOR 155 /* unused */
|
2008-11-26 18:03:54 +07:00
|
|
|
#define I2O_MINOR 166
|
2005-04-17 05:20:36 +07:00
|
|
|
#define MICROCODE_MINOR 184
|
2013-12-20 00:17:11 +07:00
|
|
|
#define VFIO_MINOR 196
|
2008-11-26 18:03:54 +07:00
|
|
|
#define TUN_MINOR 200
|
2013-09-10 01:18:27 +07:00
|
|
|
#define CUSE_MINOR 203
|
2008-11-26 18:03:54 +07:00
|
|
|
#define MWAVE_MINOR 219 /* ACP/Mwave Modem */
|
|
|
|
#define MPT_MINOR 220
|
2009-03-09 14:27:49 +07:00
|
|
|
#define MPT2SAS_MINOR 221
|
2012-11-30 09:28:10 +07:00
|
|
|
#define MPT3SAS_MINOR 222
|
2010-08-19 23:52:28 +07:00
|
|
|
#define UINPUT_MINOR 223
|
2012-06-07 18:56:51 +07:00
|
|
|
#define MISC_MCELOG_MINOR 227
|
2008-11-26 18:03:54 +07: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-20 23:07:20 +07:00
|
|
|
#define BTRFS_MINOR 234
|
|
|
|
#define AUTOFS_MINOR 235
|
2010-08-12 10:14:05 +07: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 03:08:04 +07:00
|
|
|
#define LOOP_CTRL_MINOR 237
|
2012-01-12 02:30:38 +07:00
|
|
|
#define VHOST_NET_MINOR 238
|
2013-09-09 23:33:54 +07:00
|
|
|
#define UHID_MINOR 239
|
2008-11-26 18:03:54 +07:00
|
|
|
#define MISC_DYNAMIC_MINOR 255
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
struct device;
|
|
|
|
|
|
|
|
struct miscdevice {
|
|
|
|
int minor;
|
|
|
|
const char *name;
|
2006-03-28 16:56:41 +07:00
|
|
|
const struct file_operations *fops;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct list_head list;
|
2006-07-28 06:16:04 +07:00
|
|
|
struct device *parent;
|
|
|
|
struct device *this_device;
|
2009-09-19 04:01:12 +07:00
|
|
|
const char *nodename;
|
2011-07-26 15:47:38 +07:00
|
|
|
umode_t mode;
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2014-05-16 15:36:13 +07:00
|
|
|
extern int misc_register(struct miscdevice *misc);
|
2008-03-24 02:28:24 +07:00
|
|
|
extern int misc_deregister(struct miscdevice *misc);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#define MODULE_ALIAS_MISCDEV(minor) \
|
|
|
|
MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR) \
|
|
|
|
"-" __stringify(minor))
|
|
|
|
#endif
|