From 713f798c4eff9dd9a276c4b30826d09793ecad3a Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 10 Mar 2003 19:54:50 -0800 Subject: [PATCH] [PATCH] remaining bits of DEVFS_FL_AUTO_DEVNUM Sorry, the devs_only() patch accidentally included the devfs-portion of the DEVFS_FL_AUTO_DEVNUM patch. This patch contains the remaining parts. --- Documentation/filesystems/devfs/README | 7 ------- drivers/media/radio/miropcm20-rds.c | 28 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Documentation/filesystems/devfs/README b/Documentation/filesystems/devfs/README index af0801af8e713..98688f4afc790 100644 --- a/Documentation/filesystems/devfs/README +++ b/Documentation/filesystems/devfs/README @@ -1466,13 +1466,6 @@ The simplest option (especially when porting drivers to devfs) is to 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 diff --git a/drivers/media/radio/miropcm20-rds.c b/drivers/media/radio/miropcm20-rds.c index 17a32bc17d963..fa2eebe2ecd0e 100644 --- a/drivers/media/radio/miropcm20-rds.c +++ b/drivers/media/radio/miropcm20-rds.c @@ -12,8 +12,9 @@ #include #include #include -#include +#include #include +#include #include "miropcm20-rds-core.h" static char * text_buffer; @@ -103,28 +104,39 @@ static ssize_t rds_f_read(struct file *file, char *buffer, size_t length, loff_t } } -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); -- 2.53.0