svn commit: r214038 - projects/ofed/head/sys/ofed/include/linux
Jeff Roberson
jeff at FreeBSD.org
Mon Oct 18 22:22:38 UTC 2010
Author: jeff
Date: Mon Oct 18 22:22:38 2010
New Revision: 214038
URL: http://svn.freebsd.org/changeset/base/214038
Log:
- Add the cdev for misc devices.
Sponsored by: Isilon Systems, iX Systems, and Panasas.
Modified:
projects/ofed/head/sys/ofed/include/linux/miscdevice.h
Modified: projects/ofed/head/sys/ofed/include/linux/miscdevice.h
==============================================================================
--- projects/ofed/head/sys/ofed/include/linux/miscdevice.h Mon Oct 18 22:21:57 2010 (r214037)
+++ projects/ofed/head/sys/ofed/include/linux/miscdevice.h Mon Oct 18 22:22:38 2010 (r214038)
@@ -32,24 +32,31 @@
#define MISC_DYNAMIC_MINOR -1
#include <linux/device.h>
+#include <linux/cdev.h>
struct miscdevice {
const char *name;
struct device *this_device;
const struct file_operations *fops;
+ struct cdev *cdev;
int minor;
};
extern struct class miscclass;
-/*
- * XXX Missing cdev.
- */
static inline int
misc_register(struct miscdevice *misc)
{
misc->this_device = device_create(&miscclass, &linux_rootdev, 0, misc,
misc->name);
+ misc->cdev = cdev_alloc();
+ if (misc->cdev == NULL)
+ return -ENOMEM;
+ misc->cdev->owner = THIS_MODULE;
+ misc->cdev->ops = misc->fops;
+ kobject_set_name(&misc->cdev->kobj, misc->name);
+ if (cdev_add(misc->cdev, misc->this_device->devt, 1))
+ return -EINVAL;
return (0);
}
@@ -57,8 +64,9 @@ static inline int
misc_deregister(struct miscdevice *misc)
{
device_destroy(&miscclass, misc->this_device->devt);
+ cdev_del(misc->cdev);
+
return (0);
}
-
#endif /* _LINUX_MISCDEVICE_H_ */
More information about the svn-src-projects
mailing list