remove DEVFS_FL_AUTO_DEVNUM
Subsystems (2)
PATCH 1/1 remove DEVFS_FL_AUTO_DEVNUM
Remove the DEVFS_FL_AUTO_DEVNUM flag that makes devfs_register() allocate a dev_t for it's caller.
Rationale: while dynamic major/minors are a good idea, devfs is the wrong layer to do it because all code relying on it would break with out devfs.
There were three users (outside the SN1 IRIX compat layer that needs a large rewrite for 2.5/2.6 anyway):
drivers/media/dvb/dvb-core/dvbdev.c:
only used under CONFIG_DVB_DEVFS_ONLY, which isn't exposed in the kernel configurator, removed that code.drivers/media/radio/miropcm20-rds.c:
driver was devfs-only. Add a miscdevice with dynamic minor allocation.
Documentation/filesystems/devfs/README +0 -7
@@ -1466,13 +1466,6 @@ keep using the old major and minor numbers. Devfs will take whatever values are given for major&minor and pass them onto userspace. -Alternatively, you can have devfs choose unique device numbers for -you. When you register a character or block device using -devfs_register you can provide the optional -DEVFS_FL_AUTO_DEVNUM flag, which will then automatically allocate a -unique device number (the allocation is separated for the character -and block devices). - This device number is a 16 bit number, so this leaves plenty of space for large numbers of discs and partitions. This scheme can also be used for character devices, in particular the tty devices, which are
drivers/media/dvb/dvb-core/dvbdev.c +3 -18
@@ -21,8 +21,6 @@* */ -/*#define CONFIG_DVB_DEVFS_ONLY 1*/ -#include <linux/config.h> #include <linux/version.h> #include <linux/module.h>
@@ -56,18 +54,8 @@ }; -#ifdef CONFIG_DVB_DEVFS_ONLY - -#define DVB_MAX_IDS ~0 -#define nums2minor (num,type,id) 0 -#define DVB_DEVFS_FLAGS (DEVFS_FL_DEFAULT|DEVFS_FL_AUTO_DEVNUM) - -#else - -#define DVB_MAX_IDS 4 -#define nums2minor (num,type,id) ((num << 6) | (id << 4) | type) -#define DVB_DEVFS_FLAGS (DEVFS_FL_DEFAULT) - +#define DVB_MAX_IDS 4 +#define nums2minor (num,type,id) ((num << 6) | (id << 4) | type)static struct dvb_device *dvbdev_find_device (int minor)
@@ -122,9 +110,6 @@ .owner = THIS_MODULE, .open = dvb_device_open, }; -#endif /* CONFIG_DVB_DEVFS_ONLY */ - -int dvb_generic_open (struct inode *inode,struct file *file) {
@@ -234,7 +219,7 @@sprintf (name,"%s%d" , dnames[type], id); dvbdev->devfs_handle = devfs_register(adap->devfs_handle, name, - DVB_DEVFS_FLAGS, + DEVFS_FL_DEFAULT, DVB_MAJOR, nums2minor(adap->num, type, id), S_IFCHR | S_IRUSR | S_IWUSR,
===== drivers/media/radio/miropcm20-rds.c 1.6 vs edited =====
drivers/media/radio/miropcm20-rds.c +20 -8
@@ -12,8 +12,9 @@#include <linux/module.h> #include <linux/init.h> #include <linux/slab.h> -#include <asm/uaccess.h> +#include <linux/miscdevice.h> #include <linux/devfs_fs_kernel.h> +#include <asm/uaccess.h> #include "miropcm20-rds-core.h" static char * text_buffer;
@@ -103,28 +104,39 @@ } } -static struct file_operations rds_f_ops = { +static struct file_operations rds_fops = { .owner =THIS_MODULE , .read = rds_f_read, .open = rds_f_open, .release = rds_f_release }; +static struct miscdevice rds_miscdev = { + .minor =MISC_DYNAMIC_MINOR , + .name ="radiotext" + .fops = &rds_fops, +};static int __init miropcm20_rds_init (void ) { -if (!devfs_register (NULL ,"v4l/rds/radiotext" , -DEVFS_FL_DEFAULT |DEVFS_FL_AUTO_DEVNUM , -0 ,0 ,S_IRUGO |S_IFCHR , &rds_f_ops,NULL )) -return -EINVAL ; +int error; -printk ("miropcm20-rds: userinterface driver loaded.\n" ); -return 0 ; + error =misc_register (&rds_miscdev); +if (error) +return error; + + error =devfs_mk_symlink (NULL ,"v4l/rds/radiotext" ,0 , +"../misc/radiotext" ,NULL ,NULL ); +if (error) + misc_deregister(&rds_miscdev) + +return error; } static void __exit miropcm20_rds_cleanup(void) {devfs_remove ("v4l/rds/radiotext" ); + misc_deregister(&rds_miscdev) }module_init (miropcm20_rds_init);
fs/devfs/base.c +0 -14
@@ -773,7 +773,6 @@ {struct block_device_operations *ops;dev_t dev; - unsigned char autogen:1; unsigned char removable:1; };
@@ -938,8 +937,6 @@if (S_ISLNK (de->mode) )kfree (de->u.symlink.linkname);if (S_ISCHR (de->mode) && de->u.cdev.autogen )devfs_dealloc_devnum (de->mode, de->u.cdev.dev); -if (S_ISBLK (de->mode) && de->u.bdev.autogen ) -devfs_dealloc_devnum (de->mode, de->u.bdev.dev);WRITE_ENTRY_MAGIC (de,0 );#ifdef CONFIG_DEVFS_DEBUG spin_lock (&stat_lock);
@@ -1494,17 +1491,6 @@ {PRINTK ("(%s): creating symlinks is not allowed\n" , name);return NULL ; - } -if ( (S_ISCHR (mode) ||S_ISBLK (mode) ) && - (flags &DEVFS_FL_AUTO_DEVNUM ) ) - { - devnum =devfs_alloc_devnum (mode); -if (!devnum) { -PRINTK ("(%s): exhausted %s device numbers\n" , - name,S_ISCHR (mode) ?"char" :"block" ); -return NULL ; - } - dev = devnum; }if ( ( de =_devfs_prepare_leaf (&dir, name, mode) ) ==NULL ) {
include/linux/devfs_fs_kernel.h +0 -2
@@ -13,8 +13,6 @@#define DEVFS_FL_NONE 0x000/* This helps to make code more readable */ -#define DEVFS_FL_AUTO_DEVNUM 0x002/* Automatically generate device number -*/ #define DEVFS_FL_REMOVABLE 0x008/* This is a removable media device */ #define DEVFS_FL_WAIT 0x010/* Wait for devfsd to finish */ #define DEVFS_FL_CURRENT_OWNER 0x020/* Set initial ownership to current */
Quoted 1 line · Christoph Hellwig
There were three users (outside the SN1 IRIX compat layer that needs
^^^ two in fact, the listing of examples below was correct..
Followup to: <[email protected]> By author: Christoph Hellwig <[email protected]> In newsgroup: linux.dev.kernel
Quoted 5 lines
Rationale: while dynamic major/minors are a good idea, devfs is the wrong layer to do it because all code relying on it would break with out devfs.
Your first clause here is a *highly* questionable statement...
-hpa
Signature · 3 lines
<[email protected]> at work, <[email protected]> in private! "Unix gives you enough rope to shoot yourself in the foot." Architectures needed: cris ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
Quoted 10 lines · On March 2, [email protected] wrote:
Followup to: <[email protected]> By author: Christoph Hellwig <[email protected]> In newsgroup: linux.dev.kernelQuoted 5 lines
Rationale: while dynamic major/minors are a good idea, devfs is the wrong layer to do it because all code relying on it would break with out devfs.
Your first clause here is a *highly* questionable statement...
Given the premise "Linus will not allow new static major/minors", I think it is essential :-(
NeilBrown
Quoted 11 lines
-hpa
Signature · 8 lines
<[email protected]> at work, <[email protected]> in private! "Unix gives you enough rope to shoot yourself in the foot." Architectures needed: cris ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Quoted 4 lines · Neil Brown
Given the premise "Linus will not allow new static major/minors", I think it is essential :-(
It's also a totally nonrealistic premise, which is why new allocations are still happening at the request of Alan and Marcelo.
-hpa