Commit 2813027d authored by Richard Gooch's avatar Richard Gooch

misc.c:

  Do not put miscellaneous character devices in /dev/misc if they
  specify their own directory (i.e. contain a '/' character)
util.c:
  Copied and used macro for error messages from fs/devfs/base.c
base.c:
  Removed 2.4.x compatibility code
  Added BKL to <devfs_open> because drivers still need it
parent 702d27c7
......@@ -1912,3 +1912,17 @@ Changes for patch v210
Thanks to Anton Blanchard <anton@samba.org>
- Updated README from master HTML file
===============================================================================
Changes for patch v211
- Do not put miscellaneous character devices in /dev/misc if they
specify their own directory (i.e. contain a '/' character)
- Copied macro for error messages from fs/devfs/base.c to
fs/devfs/util.c and made use of this macro
- Removed 2.4.x compatibility code from fs/devfs/base.c
===============================================================================
Changes for patch v212
- Added BKL to <devfs_open> because drivers still need it
......@@ -170,7 +170,7 @@ static struct file_operations misc_fops = {
int misc_register(struct miscdevice * misc)
{
static devfs_handle_t devfs_handle;
static devfs_handle_t devfs_handle, dir;
struct miscdevice *c;
if (misc->next || misc->prev)
......@@ -201,11 +201,12 @@ int misc_register(struct miscdevice * misc)
misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
if (!devfs_handle)
devfs_handle = devfs_mk_dir (NULL, "misc", NULL);
dir = strchr (misc->name, '/') ? NULL : devfs_handle;
misc->devfs_handle =
devfs_register (devfs_handle, misc->name, DEVFS_FL_NONE,
MISC_MAJOR, misc->minor,
S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
misc->fops, NULL);
devfs_register (dir, misc->name, DEVFS_FL_NONE,
MISC_MAJOR, misc->minor,
S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
misc->fops, NULL);
/*
* Add it to the front, so that later devices can "override"
......
......@@ -620,6 +620,12 @@
unlock_kernel() due to recent VFS locking changes. BKL isn't
required in devfs.
v1.13
20020428 Richard Gooch <rgooch@atnf.csiro.au>
Removed 2.4.x compatibility code.
v1.14
20020510 Richard Gooch <rgooch@atnf.csiro.au>
Added BKL to <devfs_open> because drivers still need it.
v1.15
*/
#include <linux/types.h>
#include <linux/errno.h>
......@@ -652,7 +658,7 @@
#include <asm/bitops.h>
#include <asm/atomic.h>
#define DEVFS_VERSION "1.13 (20020406)"
#define DEVFS_VERSION "1.15 (20020510)"
#define DEVFS_NAME "devfs"
......@@ -1400,16 +1406,8 @@ static void free_dentry (struct devfs_entry *de)
static int is_devfsd_or_child (struct fs_info *fs_info)
{
struct task_struct *p;
if (current == fs_info->devfsd_task) return (TRUE);
if (current->pgrp == fs_info->devfsd_pgrp) return (TRUE);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,1)
for (p = current->p_opptr; p != &init_task; p = p->p_opptr)
{
if (p == fs_info->devfsd_task) return (TRUE);
}
#endif
return (FALSE);
} /* End Function is_devfsd_or_child */
......@@ -1829,16 +1827,6 @@ devfs_handle_t devfs_mk_dir (devfs_handle_t dir, const char *name, void *info)
de->info = info;
if ( ( err = _devfs_append_entry (dir, de, FALSE, &old) ) != 0 )
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,1)
if ( old && S_ISDIR (old->mode) )
{
PRINTK ("(%s): using old entry in dir: %p \"%s\"\n",
name, dir, dir->name);
old->vfs_deletable = FALSE;
devfs_put (dir);
return old;
}
#endif
PRINTK ("(%s): could not append to dir: %p \"%s\", err: %d\n",
name, dir, dir->name, err);
devfs_put (old);
......@@ -2739,15 +2727,22 @@ static int devfs_open (struct inode *inode, struct file *file)
{
file->f_op = &def_blk_fops;
if (df->ops) inode->i_bdev->bd_op = df->ops;
err = def_blk_fops.open (inode, file);
}
else file->f_op = fops_get ( (struct file_operations *) df->ops );
if (file->f_op)
err = file->f_op->open ? (*file->f_op->open) (inode, file) : 0;
else
{
/* Fallback to legacy scheme */
if ( S_ISCHR (inode->i_mode) ) err = chrdev_open (inode, file);
else err = -ENODEV;
file->f_op = fops_get ( (struct file_operations *) df->ops );
if (file->f_op)
{
lock_kernel ();
err = file->f_op->open ? (*file->f_op->open) (inode, file) : 0;
unlock_kernel ();
}
else
{ /* Fallback to legacy scheme */
if ( S_ISCHR (inode->i_mode) ) err = chrdev_open (inode, file);
else err = -ENODEV;
}
}
if (err < 0) return err;
/* Open was successful */
......
......@@ -56,6 +56,8 @@
Made major bitfield type and initialiser 64 bit safe.
20020413 Richard Gooch <rgooch@atnf.csiro.au>
Fixed shift warning on 64 bit machines.
20020428 Richard Gooch <rgooch@atnf.csiro.au>
Copied and used macro for error messages from fs/devfs/base.c
*/
#include <linux/module.h>
#include <linux/init.h>
......@@ -65,6 +67,9 @@
#include <asm/bitops.h>
#define PRINTK(format, args...) \
{printk (KERN_ERR "%s" format, __FUNCTION__ , ## args);}
/* Private functions follow */
......@@ -209,9 +214,7 @@ void devfs_dealloc_major (char type, int major)
spin_lock (&list->lock);
was_set = __test_and_clear_bit (major, list->bits);
spin_unlock (&list->lock);
if (!was_set)
printk (KERN_ERR __FUNCTION__ "(): major %d was already free\n",
major);
if (!was_set) PRINTK ("(): major %d was already free\n", major);
} /* End Function devfs_dealloc_major */
EXPORT_SYMBOL(devfs_dealloc_major);
......@@ -339,12 +342,11 @@ void devfs_dealloc_devnum (char type, kdev_t devnum)
if (was_set) list->none_free = 0;
up (semaphore);
if (!was_set)
printk ( KERN_ERR __FUNCTION__ "(): device %s was already free\n",
kdevname (devnum) );
PRINTK ( "(): device %s was already free\n", kdevname (devnum) );
return;
}
up (semaphore);
printk ( KERN_ERR __FUNCTION__ "(): major for %s not previously allocated\n",
PRINTK ( "(): major for %s not previously allocated\n",
kdevname (devnum) );
} /* End Function devfs_dealloc_devnum */
EXPORT_SYMBOL(devfs_dealloc_devnum);
......@@ -419,8 +421,6 @@ void devfs_dealloc_unique_number (struct unique_numspace *space, int number)
was_set = __test_and_clear_bit (number, space->bits);
if (was_set) ++space->num_free;
up (&space->semaphore);
if (!was_set)
printk (KERN_ERR __FUNCTION__ "(): number %d was already free\n",
number);
if (!was_set) PRINTK ("(): number %d was already free\n", number);
} /* End Function devfs_dealloc_unique_number */
EXPORT_SYMBOL(devfs_dealloc_unique_number);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment