diff --git a/config/spl-build.m4 b/config/spl-build.m4 index f9287e2de..1acacb5b6 100644 --- a/config/spl-build.m4 +++ b/config/spl-build.m4 @@ -34,9 +34,6 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ SPL_AC_VMALLOC_INFO SPL_AC_PDE_DATA SPL_AC_FLS64 - SPL_AC_DEVICE_CREATE - SPL_AC_5ARGS_DEVICE_CREATE - SPL_AC_CLASS_DEVICE_CREATE SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE SPL_AC_TIMESPEC_SUB @@ -1075,64 +1072,6 @@ AC_DEFUN([SPL_AC_FLS64], ]) ]) -dnl # -dnl # 2.6.18 API change, check whether device_create() is available. -dnl # Device_create() was introduced in 2.6.18 and depricated -dnl # class_device_create() which was fully removed in 2.6.26. -dnl # -AC_DEFUN([SPL_AC_DEVICE_CREATE], - [AC_MSG_CHECKING([whether device_create() is available]) - SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_DEVICE_CREATE, 1, - [device_create() is available]) - ], [ - AC_MSG_RESULT(no) - ]) -]) - -dnl # -dnl # 2.6.27 API change, -dnl # device_create() uses 5 args, new 'drvdata' argument. -dnl # -AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [ - AC_MSG_CHECKING([whether device_create() wants 5 args]) - tmp_flags="$EXTRA_KCFLAGS" - EXTRA_KCFLAGS="-Werror" - SPL_LINUX_TRY_COMPILE([ - #include - ],[ - device_create(NULL, NULL, 0, NULL, "%d", 1); - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1, - [device_create wants 5 args]) - ],[ - AC_MSG_RESULT(no) - ]) - EXTRA_KCFLAGS="$tmp_flags" -]) - -dnl # -dnl # 2.6.13 API change, check whether class_device_create() is available. -dnl # Class_device_create() was introduced in 2.6.13 and depricated -dnl # class_simple_device_add() which was fully removed in 2.6.13. -dnl # -AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], - [AC_MSG_CHECKING([whether class_device_create() is available]) - SPL_LINUX_TRY_COMPILE_SYMBOL([ - #include - ], [ - class_device_create(NULL, NULL, 0, NULL, NULL); - ], [class_device_create], [drivers/base/class.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1, - [class_device_create() is available]) - ], [ - AC_MSG_RESULT(no) - ]) -]) - dnl # dnl # 2.6.26 API change, set_normalized_timespec() is exported. dnl # diff --git a/include/Makefile.am b/include/Makefile.am index 463bea1d1..a7508fb34 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -6,7 +6,6 @@ KERNEL_H = \ $(top_srcdir)/include/splat-ctl.h \ $(top_srcdir)/include/spl-ctl.h \ $(top_srcdir)/include/spl-debug.h \ - $(top_srcdir)/include/spl-device.h \ $(top_srcdir)/include/spl-trace.h \ $(top_srcdir)/include/strings.h \ $(top_srcdir)/include/unistd.h diff --git a/include/spl-device.h b/include/spl-device.h deleted file mode 100644 index b237cf1b0..000000000 --- a/include/spl-device.h +++ /dev/null @@ -1,90 +0,0 @@ -/*****************************************************************************\ - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . -\*****************************************************************************/ - -#ifndef _SPL_DEVICE_H -#define _SPL_DEVICE_H - -#include - -/* - * Preferred API from 2.6.18 to 2.6.26+ - */ -#ifdef HAVE_DEVICE_CREATE - -typedef struct class spl_class; -typedef struct device spl_device; - -#define spl_class_create(mod, name) class_create(mod, name) -#define spl_class_destroy(cls) class_destroy(cls) - -# ifdef HAVE_5ARGS_DEVICE_CREATE -# define spl_device_create(cls, parent, devt, drvdata, fmt, args...) \ - device_create(cls, parent, devt, drvdata, fmt, ## args) -# else -# define spl_device_create(cls, parent, devt, drvdata, fmt, args...) \ - device_create(cls, parent, devt, fmt, ## args) -# endif - -#define spl_device_destroy(cls, cls_dev, devt) \ - device_destroy(cls, devt) - -/* - * Preferred API from 2.6.13 to 2.6.17 - * Depricated in 2.6.18 - * Removed in 2.6.26 - */ -#else -#ifdef HAVE_CLASS_DEVICE_CREATE - -typedef struct class spl_class; -typedef struct class_device spl_device; - -#define spl_class_create(mod, name) class_create(mod, name) -#define spl_class_destroy(cls) class_destroy(cls) -#define spl_device_create(cls, parent, devt, device, fmt, args...) \ - class_device_create(cls, parent, devt, device, fmt, ## args) -#define spl_device_destroy(cls, cls_dev, devt) \ - class_device_unregister(cls_dev) - -/* - * Prefered API from 2.6.0 to 2.6.12 - * Depricated in 2.6.13 - * Removed in 2.6.13 - */ -#else /* Legacy API */ - -typedef struct class_simple spl_class; -typedef struct class_device spl_class_device; - -#define spl_class_create(mod, name) class_simple_create(mod, name) -#define spl_class_destroy(cls) class_simple_destroy(cls) -#define spl_device_create(cls, parent, devt, device, fmt, args...) \ - class_simple_device_add(cls, devt, device, fmt, ## args) -#define spl_device_destroy(cls, cls_dev, devt) \ - class_simple_device_remove(devt) - -#endif /* HAVE_CLASS_DEVICE_CREATE */ -#endif /* HAVE_DEVICE_CREATE */ - -#endif /* _SPL_DEVICE_H */ diff --git a/include/splat-ctl.h b/include/splat-ctl.h index ccf3644bd..15fd01b54 100644 --- a/include/splat-ctl.h +++ b/include/splat-ctl.h @@ -32,8 +32,6 @@ * ensure 32-bit/64-bit interoperability over ioctl()'s only types with * fixed sizes can be used. */ -#define SPLAT_MAJOR 225 /* XXX - Arbitrary */ -#define SPLAT_MINORS 1 #define SPLAT_NAME "splatctl" #define SPLAT_DEV "/dev/splatctl" diff --git a/include/sys/sunddi.h b/include/sys/sunddi.h index 545803afd..c49b0c26c 100644 --- a/include/sys/sunddi.h +++ b/include/sys/sunddi.h @@ -31,7 +31,6 @@ #include #include #include -#include typedef int ddi_devid_t; diff --git a/module/splat/splat-ctl.c b/module/splat/splat-ctl.c index 4048e0817..46bc6d1a6 100644 --- a/module/splat/splat-ctl.c +++ b/module/splat/splat-ctl.c @@ -49,25 +49,20 @@ #include #include #include +#include #include #include #include #include "splat-internal.h" -static spl_class *splat_class; -static spl_device *splat_device; static struct list_head splat_module_list; static spinlock_t splat_module_lock; static int splat_open(struct inode *inode, struct file *file) { - unsigned int minor = iminor(inode); splat_info_t *info; - if (minor >= SPLAT_MINORS) - return -ENXIO; - info = (splat_info_t *)kmalloc(sizeof(*info), GFP_KERNEL); if (info == NULL) return -ENOMEM; @@ -92,12 +87,8 @@ splat_open(struct inode *inode, struct file *file) static int splat_release(struct inode *inode, struct file *file) { - unsigned int minor = iminor(inode); splat_info_t *info = (splat_info_t *)file->private_data; - if (minor >= SPLAT_MINORS) - return -ENXIO; - ASSERT(info); ASSERT(info->info_buffer); @@ -458,16 +449,12 @@ splat_ioctl_cmd(struct file *file, unsigned int cmd, unsigned long arg) static long splat_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - unsigned int minor = iminor(file->f_dentry->d_inode); int rc = 0; /* Ignore tty ioctls */ if ((cmd & 0xffffff00) == ((int)'T') << 8) return -ENOTTY; - if (minor >= SPLAT_MINORS) - return -ENXIO; - switch (cmd) { case SPLAT_CFG: rc = splat_ioctl_cfg(file, cmd, arg); @@ -500,13 +487,9 @@ splat_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) static ssize_t splat_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { - unsigned int minor = iminor(file->f_dentry->d_inode); splat_info_t *info = (splat_info_t *)file->private_data; int rc = 0; - if (minor >= SPLAT_MINORS) - return -ENXIO; - ASSERT(info); ASSERT(info->info_buffer); @@ -537,13 +520,9 @@ out: static ssize_t splat_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { - unsigned int minor = iminor(file->f_dentry->d_inode); splat_info_t *info = (splat_info_t *)file->private_data; int rc = 0; - if (minor >= SPLAT_MINORS) - return -ENXIO; - ASSERT(info); ASSERT(info->info_buffer); @@ -571,13 +550,9 @@ out: static loff_t splat_seek(struct file *file, loff_t offset, int origin) { - unsigned int minor = iminor(file->f_dentry->d_inode); splat_info_t *info = (splat_info_t *)file->private_data; int rc = -EINVAL; - if (minor >= SPLAT_MINORS) - return -ENXIO; - ASSERT(info); ASSERT(info->info_buffer); @@ -605,7 +580,6 @@ static loff_t splat_seek(struct file *file, loff_t offset, int origin) return rc; } -static struct cdev splat_cdev; static struct file_operations splat_fops = { .owner = THIS_MODULE, .open = splat_open, @@ -619,11 +593,16 @@ static struct file_operations splat_fops = { .llseek = splat_seek, }; +static struct miscdevice splat_misc = { + .minor = MISC_DYNAMIC_MINOR, + .name = SPLAT_NAME, + .fops = &splat_fops, +}; + static int splat_init(void) { - dev_t dev; - int rc; + int error; spin_lock_init(&splat_module_lock); INIT_LIST_HEAD(&splat_module_list); @@ -645,52 +624,25 @@ splat_init(void) SPLAT_SUBSYSTEM_INIT(zlib); SPLAT_SUBSYSTEM_INIT(linux); - dev = MKDEV(SPLAT_MAJOR, 0); - if ((rc = register_chrdev_region(dev, SPLAT_MINORS, SPLAT_NAME))) - goto error; - - /* Support for registering a character driver */ - cdev_init(&splat_cdev, &splat_fops); - splat_cdev.owner = THIS_MODULE; - kobject_set_name(&splat_cdev.kobj, SPLAT_NAME); - if ((rc = cdev_add(&splat_cdev, dev, SPLAT_MINORS))) { - printk(KERN_ERR "SPLAT: Error adding cdev, %d\n", rc); - kobject_put(&splat_cdev.kobj); - unregister_chrdev_region(dev, SPLAT_MINORS); - goto error; + error = misc_register(&splat_misc); + if (error) { + printk(KERN_INFO "SPLAT: misc_register() failed %d\n", error); + } else { + printk(KERN_INFO "SPLAT: Loaded module v%s-%s%s\n", + SPL_META_VERSION, SPL_META_RELEASE, SPL_DEBUG_STR); } - /* Support for udev make driver info available in sysfs */ - splat_class = spl_class_create(THIS_MODULE, "splat"); - if (IS_ERR(splat_class)) { - rc = PTR_ERR(splat_class); - printk(KERN_ERR "SPLAT: Error creating splat class, %d\n", rc); - cdev_del(&splat_cdev); - unregister_chrdev_region(dev, SPLAT_MINORS); - goto error; - } - - splat_device = spl_device_create(splat_class, NULL, - MKDEV(SPLAT_MAJOR, 0), - NULL, SPLAT_NAME); - - printk(KERN_INFO "SPLAT: Loaded module v%s-%s%s\n", - SPL_META_VERSION, SPL_META_RELEASE, SPL_DEBUG_STR); - return 0; -error: - printk(KERN_ERR "SPLAT: Error registering splat device, %d\n", rc); - return rc; + return (error); } static int splat_fini(void) { - dev_t dev = MKDEV(SPLAT_MAJOR, 0); + int error; - spl_device_destroy(splat_class, splat_device, dev); - spl_class_destroy(splat_class); - cdev_del(&splat_cdev); - unregister_chrdev_region(dev, SPLAT_MINORS); + error = misc_deregister(&splat_misc); + if (error) + printk(KERN_INFO "SPLAT: misc_deregister() failed %d\n", error); SPLAT_SUBSYSTEM_FINI(linux); SPLAT_SUBSYSTEM_FINI(zlib); @@ -711,9 +663,9 @@ splat_fini(void) ASSERT(list_empty(&splat_module_list)); printk(KERN_INFO "SPLAT: Unloaded module v%s-%s%s\n", - SPL_META_VERSION, SPL_META_RELEASE, SPL_DEBUG_STR); + SPL_META_VERSION, SPL_META_RELEASE, SPL_DEBUG_STR); - return 0; + return (0); } spl_module_init(splat_init); diff --git a/module/splat/splat-internal.h b/module/splat/splat-internal.h index 2ff19541b..ea0a88f0c 100644 --- a/module/splat/splat-internal.h +++ b/module/splat/splat-internal.h @@ -25,7 +25,6 @@ #ifndef _SPLAT_INTERNAL_H #define _SPLAT_INTERNAL_H -#include "spl-device.h" #include "spl-debug.h" #include "splat-ctl.h" #include