[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [linux-2.6.18-xen] gntdev: switch from char-dev to misc-dev
# HG changeset patch # User Jan Beulich <jbeulich@xxxxxxxx> # Date 1327064083 -3600 # Node ID ee73c29182d54b739fc89d0cdceb2d6885422eb2 # Parent 348f3f385b3bfbd5fe9d5e2acc30481573c5d1fa gntdev: switch from char-dev to misc-dev Rather than consuming a major (using just a single minor under it) register a dynamic-minor misc-dev (as has been the case in the pv-ops code from the very beginning). Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- diff -r 348f3f385b3b -r ee73c29182d5 drivers/xen/gntdev/gntdev.c --- a/drivers/xen/gntdev/gntdev.c Thu Jan 19 13:24:23 2012 +0100 +++ b/drivers/xen/gntdev/gntdev.c Fri Jan 20 13:54:43 2012 +0100 @@ -21,7 +21,7 @@ #include <linux/kernel.h> #include <linux/init.h> #include <linux/fs.h> -#include <linux/device.h> +#include <linux/miscdevice.h> #include <linux/mm.h> #include <linux/mman.h> #include <asm/uaccess.h> @@ -30,9 +30,6 @@ #include <asm/hypervisor.h> #include <xen/balloon.h> #include <xen/evtchn.h> -#include <xen/driver_util.h> - -#include <linux/types.h> #include <xen/public/gntdev.h> @@ -156,11 +153,6 @@ .zap_pte = gntdev_clear_pte }; -/* Global variables. */ - -/* The driver major number, for use when unregistering the driver. */ -static int gntdev_major; - #define GNTDEV_NAME "gntdev" /* Memory mapping functions @@ -371,42 +363,27 @@ /* Interface functions. */ +static struct miscdevice gntdev_miscdev = { + .minor = MISC_DYNAMIC_MINOR, + .name = GNTDEV_NAME, + .fops = &gntdev_fops, +}; + /* Initialises the driver. Called when the module is loaded. */ static int __init gntdev_init(void) { - struct class *class; - struct class_device *device; + int err; if (!is_running_on_xen()) { printk(KERN_ERR "You must be running Xen to use gntdev\n"); return -ENODEV; } - gntdev_major = register_chrdev(0, GNTDEV_NAME, &gntdev_fops); - if (gntdev_major < 0) + err = misc_register(&gntdev_miscdev); + if (err) { printk(KERN_ERR "Could not register gntdev device\n"); - return -ENOMEM; - } - - /* Note that if the sysfs code fails, we will still initialise the - * device, and output the major number so that the device can be - * created manually using mknod. - */ - if ((class = get_xen_class()) == NULL) { - printk(KERN_ERR "Error setting up xen_class\n"); - printk(KERN_ERR "gntdev created with major number = %d\n", - gntdev_major); - return 0; - } - - device = class_device_create(class, NULL, MKDEV(gntdev_major, 0), - NULL, GNTDEV_NAME); - if (IS_ERR(device)) { - printk(KERN_ERR "Error creating gntdev device in xen_class\n"); - printk(KERN_ERR "gntdev created with major number = %d\n", - gntdev_major); - return 0; + return err; } return 0; @@ -416,10 +393,7 @@ */ static void __exit gntdev_exit(void) { - struct class *class; - if ((class = get_xen_class()) != NULL) - class_device_destroy(class, MKDEV(gntdev_major, 0)); - unregister_chrdev(gntdev_major, GNTDEV_NAME); + misc_deregister(&gntdev_miscdev); } /* Called when the device is opened. */ _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |