Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/char/raw.c |
| 3 | * |
| 4 | * Front-end raw character devices. These can be bound to any block |
| 5 | * devices to provide genuine Unix raw character device semantics. |
| 6 | * |
| 7 | * We reserve minor number 0 for a control interface. ioctl()s on this |
| 8 | * device are used to bind the other minor numbers to block devices. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/major.h> |
| 14 | #include <linux/blkdev.h> |
| 15 | #include <linux/module.h> |
| 16 | #include <linux/raw.h> |
| 17 | #include <linux/capability.h> |
| 18 | #include <linux/uio.h> |
| 19 | #include <linux/cdev.h> |
| 20 | #include <linux/device.h> |
Arjan van de Ven | 8ed965d | 2006-03-23 03:00:21 -0800 | [diff] [blame] | 21 | #include <linux/mutex.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 22 | #include <linux/gfp.h> |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 23 | #include <linux/compat.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | #include <asm/uaccess.h> |
| 26 | |
| 27 | struct raw_device_data { |
| 28 | struct block_device *binding; |
| 29 | int inuse; |
| 30 | }; |
| 31 | |
gregkh@suse.de | ca8eca6 | 2005-03-23 09:53:09 -0800 | [diff] [blame] | 32 | static struct class *raw_class; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | static struct raw_device_data raw_devices[MAX_RAW_MINORS]; |
Arjan van de Ven | 8ed965d | 2006-03-23 03:00:21 -0800 | [diff] [blame] | 34 | static DEFINE_MUTEX(raw_mutex); |
Arjan van de Ven | 62322d2 | 2006-07-03 00:24:21 -0700 | [diff] [blame] | 35 | static const struct file_operations raw_ctl_fops; /* forward declaration */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * Open/close code for raw IO. |
| 39 | * |
| 40 | * We just rewrite the i_mapping for the /dev/raw/rawN file descriptor to |
| 41 | * point at the blockdev's address_space and set the file handle to use |
| 42 | * O_DIRECT. |
| 43 | * |
| 44 | * Set the device's soft blocksize to the minimum possible. This gives the |
| 45 | * finest possible alignment and has no adverse impact on performance. |
| 46 | */ |
| 47 | static int raw_open(struct inode *inode, struct file *filp) |
| 48 | { |
| 49 | const int minor = iminor(inode); |
| 50 | struct block_device *bdev; |
| 51 | int err; |
| 52 | |
| 53 | if (minor == 0) { /* It is the control device */ |
| 54 | filp->f_op = &raw_ctl_fops; |
| 55 | return 0; |
| 56 | } |
| 57 | |
Arjan van de Ven | 8ed965d | 2006-03-23 03:00:21 -0800 | [diff] [blame] | 58 | mutex_lock(&raw_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | /* |
| 61 | * All we need to do on open is check that the device is bound. |
| 62 | */ |
| 63 | bdev = raw_devices[minor].binding; |
| 64 | err = -ENODEV; |
| 65 | if (!bdev) |
| 66 | goto out; |
| 67 | igrab(bdev->bd_inode); |
Tejun Heo | e525fd8 | 2010-11-13 11:55:17 +0100 | [diff] [blame] | 68 | err = blkdev_get(bdev, filp->f_mode | FMODE_EXCL, raw_open); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | if (err) |
| 70 | goto out; |
Martin K. Petersen | e1defc4 | 2009-05-22 17:17:49 -0400 | [diff] [blame] | 71 | err = set_blocksize(bdev, bdev_logical_block_size(bdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | if (err) |
Tejun Heo | e525fd8 | 2010-11-13 11:55:17 +0100 | [diff] [blame] | 73 | goto out1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | filp->f_flags |= O_DIRECT; |
| 75 | filp->f_mapping = bdev->bd_inode->i_mapping; |
| 76 | if (++raw_devices[minor].inuse == 1) |
Josef Sipek | a7113a9 | 2006-12-08 02:36:55 -0800 | [diff] [blame] | 77 | filp->f_path.dentry->d_inode->i_mapping = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | bdev->bd_inode->i_mapping; |
| 79 | filp->private_data = bdev; |
Arjan van de Ven | 8ed965d | 2006-03-23 03:00:21 -0800 | [diff] [blame] | 80 | mutex_unlock(&raw_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | return 0; |
| 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | out1: |
Tejun Heo | e525fd8 | 2010-11-13 11:55:17 +0100 | [diff] [blame] | 84 | blkdev_put(bdev, filp->f_mode | FMODE_EXCL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | out: |
Arjan van de Ven | 8ed965d | 2006-03-23 03:00:21 -0800 | [diff] [blame] | 86 | mutex_unlock(&raw_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | return err; |
| 88 | } |
| 89 | |
| 90 | /* |
| 91 | * When the final fd which refers to this character-special node is closed, we |
| 92 | * make its ->mapping point back at its own i_data. |
| 93 | */ |
| 94 | static int raw_release(struct inode *inode, struct file *filp) |
| 95 | { |
| 96 | const int minor= iminor(inode); |
| 97 | struct block_device *bdev; |
| 98 | |
Arjan van de Ven | 8ed965d | 2006-03-23 03:00:21 -0800 | [diff] [blame] | 99 | mutex_lock(&raw_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | bdev = raw_devices[minor].binding; |
| 101 | if (--raw_devices[minor].inuse == 0) { |
| 102 | /* Here inode->i_mapping == bdev->bd_inode->i_mapping */ |
| 103 | inode->i_mapping = &inode->i_data; |
| 104 | inode->i_mapping->backing_dev_info = &default_backing_dev_info; |
| 105 | } |
Arjan van de Ven | 8ed965d | 2006-03-23 03:00:21 -0800 | [diff] [blame] | 106 | mutex_unlock(&raw_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
Tejun Heo | e525fd8 | 2010-11-13 11:55:17 +0100 | [diff] [blame] | 108 | blkdev_put(bdev, filp->f_mode | FMODE_EXCL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | /* |
| 113 | * Forward ioctls to the underlying block device. |
| 114 | */ |
Arnd Bergmann | 5592933 | 2010-04-27 00:24:05 +0200 | [diff] [blame] | 115 | static long |
| 116 | raw_ioctl(struct file *filp, unsigned int command, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | { |
| 118 | struct block_device *bdev = filp->private_data; |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 119 | return blkdev_ioctl(bdev, 0, command, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 122 | static int bind_set(int number, u64 major, u64 minor) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | { |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 124 | dev_t dev = MKDEV(major, minor); |
| 125 | struct raw_device_data *rawdev; |
| 126 | int err = 0; |
| 127 | |
| 128 | if (number <= 0 || number >= MAX_RAW_MINORS) |
| 129 | return -EINVAL; |
| 130 | |
| 131 | if (MAJOR(dev) != major || MINOR(dev) != minor) |
| 132 | return -EINVAL; |
| 133 | |
| 134 | rawdev = &raw_devices[number]; |
| 135 | |
| 136 | /* |
| 137 | * This is like making block devices, so demand the |
| 138 | * same capability |
| 139 | */ |
| 140 | if (!capable(CAP_SYS_ADMIN)) |
| 141 | return -EPERM; |
| 142 | |
| 143 | /* |
| 144 | * For now, we don't need to check that the underlying |
| 145 | * block device is present or not: we can do that when |
| 146 | * the raw device is opened. Just check that the |
| 147 | * major/minor numbers make sense. |
| 148 | */ |
| 149 | |
| 150 | if (MAJOR(dev) == 0 && dev != 0) |
| 151 | return -EINVAL; |
| 152 | |
| 153 | mutex_lock(&raw_mutex); |
| 154 | if (rawdev->inuse) { |
| 155 | mutex_unlock(&raw_mutex); |
| 156 | return -EBUSY; |
| 157 | } |
| 158 | if (rawdev->binding) { |
| 159 | bdput(rawdev->binding); |
| 160 | module_put(THIS_MODULE); |
| 161 | } |
| 162 | if (!dev) { |
| 163 | /* unbind */ |
| 164 | rawdev->binding = NULL; |
| 165 | device_destroy(raw_class, MKDEV(RAW_MAJOR, number)); |
| 166 | } else { |
| 167 | rawdev->binding = bdget(dev); |
| 168 | if (rawdev->binding == NULL) { |
| 169 | err = -ENOMEM; |
| 170 | } else { |
| 171 | dev_t raw = MKDEV(RAW_MAJOR, number); |
| 172 | __module_get(THIS_MODULE); |
| 173 | device_destroy(raw_class, raw); |
| 174 | device_create(raw_class, NULL, raw, NULL, |
| 175 | "raw%d", number); |
| 176 | } |
| 177 | } |
| 178 | mutex_unlock(&raw_mutex); |
| 179 | return err; |
| 180 | } |
| 181 | |
| 182 | static int bind_get(int number, dev_t *dev) |
| 183 | { |
| 184 | struct raw_device_data *rawdev; |
| 185 | struct block_device *bdev; |
| 186 | |
| 187 | if (number <= 0 || number >= MAX_RAW_MINORS) |
| 188 | return -EINVAL; |
| 189 | |
| 190 | rawdev = &raw_devices[number]; |
| 191 | |
| 192 | mutex_lock(&raw_mutex); |
| 193 | bdev = rawdev->binding; |
| 194 | *dev = bdev ? bdev->bd_dev : 0; |
| 195 | mutex_unlock(&raw_mutex); |
| 196 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | /* |
| 200 | * Deal with ioctls against the raw-device control interface, to bind |
| 201 | * and unbind other raw devices. |
| 202 | */ |
Arnd Bergmann | 5592933 | 2010-04-27 00:24:05 +0200 | [diff] [blame] | 203 | static long raw_ctl_ioctl(struct file *filp, unsigned int command, |
| 204 | unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | { |
| 206 | struct raw_config_request rq; |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 207 | dev_t dev; |
| 208 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
| 210 | switch (command) { |
| 211 | case RAW_SETBIND: |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 212 | if (copy_from_user(&rq, (void __user *) arg, sizeof(rq))) |
| 213 | return -EFAULT; |
| 214 | |
| 215 | return bind_set(rq.raw_minor, rq.block_major, rq.block_minor); |
| 216 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | case RAW_GETBIND: |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 218 | if (copy_from_user(&rq, (void __user *) arg, sizeof(rq))) |
| 219 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 221 | err = bind_get(rq.raw_minor, &dev); |
| 222 | if (err) |
| 223 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 225 | rq.block_major = MAJOR(dev); |
| 226 | rq.block_minor = MINOR(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 228 | if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) |
| 229 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 231 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | } |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 233 | |
| 234 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 237 | #ifdef CONFIG_COMPAT |
| 238 | struct raw32_config_request { |
| 239 | compat_int_t raw_minor; |
| 240 | compat_u64 block_major; |
| 241 | compat_u64 block_minor; |
| 242 | }; |
| 243 | |
| 244 | static long raw_ctl_compat_ioctl(struct file *file, unsigned int cmd, |
| 245 | unsigned long arg) |
| 246 | { |
| 247 | struct raw32_config_request __user *user_req = compat_ptr(arg); |
| 248 | struct raw32_config_request rq; |
| 249 | dev_t dev; |
| 250 | int err = 0; |
| 251 | |
| 252 | switch (cmd) { |
| 253 | case RAW_SETBIND: |
| 254 | if (copy_from_user(&rq, user_req, sizeof(rq))) |
| 255 | return -EFAULT; |
| 256 | |
| 257 | return bind_set(rq.raw_minor, rq.block_major, rq.block_minor); |
| 258 | |
| 259 | case RAW_GETBIND: |
| 260 | if (copy_from_user(&rq, user_req, sizeof(rq))) |
| 261 | return -EFAULT; |
| 262 | |
| 263 | err = bind_get(rq.raw_minor, &dev); |
| 264 | if (err) |
| 265 | return err; |
| 266 | |
| 267 | rq.block_major = MAJOR(dev); |
| 268 | rq.block_minor = MINOR(dev); |
| 269 | |
| 270 | if (copy_to_user(user_req, &rq, sizeof(rq))) |
| 271 | return -EFAULT; |
| 272 | |
| 273 | return 0; |
| 274 | } |
| 275 | |
| 276 | return -EINVAL; |
| 277 | } |
| 278 | #endif |
| 279 | |
Arjan van de Ven | 62322d2 | 2006-07-03 00:24:21 -0700 | [diff] [blame] | 280 | static const struct file_operations raw_fops = { |
Arnd Bergmann | 5592933 | 2010-04-27 00:24:05 +0200 | [diff] [blame] | 281 | .read = do_sync_read, |
| 282 | .aio_read = generic_file_aio_read, |
| 283 | .write = do_sync_write, |
| 284 | .aio_write = blkdev_aio_write, |
| 285 | .fsync = blkdev_fsync, |
| 286 | .open = raw_open, |
| 287 | .release = raw_release, |
| 288 | .unlocked_ioctl = raw_ioctl, |
Arnd Bergmann | cb3b9cf | 2010-07-06 23:03:55 +0200 | [diff] [blame] | 289 | .llseek = default_llseek, |
Arnd Bergmann | 5592933 | 2010-04-27 00:24:05 +0200 | [diff] [blame] | 290 | .owner = THIS_MODULE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | }; |
| 292 | |
Arjan van de Ven | 62322d2 | 2006-07-03 00:24:21 -0700 | [diff] [blame] | 293 | static const struct file_operations raw_ctl_fops = { |
Arnd Bergmann | 5592933 | 2010-04-27 00:24:05 +0200 | [diff] [blame] | 294 | .unlocked_ioctl = raw_ctl_ioctl, |
Al Viro | c4a0472 | 2009-08-24 22:42:56 +0000 | [diff] [blame] | 295 | #ifdef CONFIG_COMPAT |
| 296 | .compat_ioctl = raw_ctl_compat_ioctl, |
| 297 | #endif |
Arnd Bergmann | 5592933 | 2010-04-27 00:24:05 +0200 | [diff] [blame] | 298 | .open = raw_open, |
| 299 | .owner = THIS_MODULE, |
Arnd Bergmann | cb3b9cf | 2010-07-06 23:03:55 +0200 | [diff] [blame] | 300 | .llseek = noop_llseek, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | }; |
| 302 | |
Greg Kroah-Hartman | 7e7654a | 2007-09-12 15:06:57 -0700 | [diff] [blame] | 303 | static struct cdev raw_cdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | |
Kay Sievers | e454cea | 2009-09-18 23:01:12 +0200 | [diff] [blame] | 305 | static char *raw_devnode(struct device *dev, mode_t *mode) |
Kay Sievers | 6fd4693 | 2009-04-30 15:23:42 +0200 | [diff] [blame] | 306 | { |
| 307 | return kasprintf(GFP_KERNEL, "raw/%s", dev_name(dev)); |
| 308 | } |
| 309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | static int __init raw_init(void) |
| 311 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | dev_t dev = MKDEV(RAW_MAJOR, 0); |
Rolf Eike Beer | 3e26a42 | 2006-09-29 02:00:46 -0700 | [diff] [blame] | 313 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | |
Rolf Eike Beer | 3e26a42 | 2006-09-29 02:00:46 -0700 | [diff] [blame] | 315 | ret = register_chrdev_region(dev, MAX_RAW_MINORS, "raw"); |
| 316 | if (ret) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | goto error; |
| 318 | |
| 319 | cdev_init(&raw_cdev, &raw_fops); |
Rolf Eike Beer | 3e26a42 | 2006-09-29 02:00:46 -0700 | [diff] [blame] | 320 | ret = cdev_add(&raw_cdev, dev, MAX_RAW_MINORS); |
| 321 | if (ret) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | kobject_put(&raw_cdev.kobj); |
Rolf Eike Beer | 3e26a42 | 2006-09-29 02:00:46 -0700 | [diff] [blame] | 323 | goto error_region; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | } |
| 325 | |
gregkh@suse.de | ca8eca6 | 2005-03-23 09:53:09 -0800 | [diff] [blame] | 326 | raw_class = class_create(THIS_MODULE, "raw"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | if (IS_ERR(raw_class)) { |
| 328 | printk(KERN_ERR "Error creating raw class.\n"); |
| 329 | cdev_del(&raw_cdev); |
Rolf Eike Beer | 3e26a42 | 2006-09-29 02:00:46 -0700 | [diff] [blame] | 330 | ret = PTR_ERR(raw_class); |
| 331 | goto error_region; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | } |
Kay Sievers | e454cea | 2009-09-18 23:01:12 +0200 | [diff] [blame] | 333 | raw_class->devnode = raw_devnode; |
Greg Kroah-Hartman | 03457cd | 2008-07-21 20:03:34 -0700 | [diff] [blame] | 334 | device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | return 0; |
| 337 | |
Rolf Eike Beer | 3e26a42 | 2006-09-29 02:00:46 -0700 | [diff] [blame] | 338 | error_region: |
| 339 | unregister_chrdev_region(dev, MAX_RAW_MINORS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | error: |
Rolf Eike Beer | 3e26a42 | 2006-09-29 02:00:46 -0700 | [diff] [blame] | 341 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | static void __exit raw_exit(void) |
| 345 | { |
Greg Kroah-Hartman | 38ca6c3 | 2006-08-07 22:19:37 -0700 | [diff] [blame] | 346 | device_destroy(raw_class, MKDEV(RAW_MAJOR, 0)); |
gregkh@suse.de | ca8eca6 | 2005-03-23 09:53:09 -0800 | [diff] [blame] | 347 | class_destroy(raw_class); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | cdev_del(&raw_cdev); |
| 349 | unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), MAX_RAW_MINORS); |
| 350 | } |
| 351 | |
| 352 | module_init(raw_init); |
| 353 | module_exit(raw_exit); |
| 354 | MODULE_LICENSE("GPL"); |