void scullv_cleanup(void) { int i; unregister_chrdev(scullv_major, "scullv"); #ifdef SCULLV_USE_PROC remove_proc_entry("scullvmem", 0); #endif for (i=0; i<scullv_devs; i++) scullv_trim(scullv_devices+i); kfree(scullv_devices); }
void cleanup_module(void) { int i; unregister_chrdev(scullv_major, "scullv"); #ifdef SCULLV_USE_PROC proc_unregister(&proc_root, scullv_proc_entry.low_ino); #endif for (i=0; i<scullv_devs; i++) scullv_trim(scullv_devices+i); kfree(scullv_devices); }
void scullv_cleanup(void) { int i; #ifdef SCULLV_USE_PROC remove_proc_entry("scullvmem", NULL); #endif for (i = 0; i < scullv_devs; i++) { cdev_del(&scullv_devices[i].cdev); scullv_trim(scullv_devices + i); } kfree(scullv_devices); unregister_chrdev_region(MKDEV (scullv_major, 0), scullv_devs); }
int scullv_open (struct inode *inode, struct file *filp) { int num = MINOR(inode->i_rdev); ScullV_Dev *dev; /* device information */ /* check the device number */ if (num >= scullv_devs) return -ENODEV; dev = &scullv_devices[num]; /* now trim to 0 the length of the device if open was write-only */ if ( (filp->f_flags & O_ACCMODE) == O_WRONLY) scullv_trim(dev); /* and use filp->private_data to point to the device data */ filp->private_data = dev; MOD_INC_USE_COUNT; return 0; /* success */ }
int scullv_open (struct inode *inode, struct file *filp) { struct scullv_dev *dev; /* device information */ /* Find the device */ dev = container_of(inode->i_cdev, struct scullv_dev, cdev); /* now trim to 0 the length of the device if open was write-only */ if ( (filp->f_flags & O_ACCMODE) == O_WRONLY) { if (down_interruptible (&dev->sem)) return -ERESTARTSYS; scullv_trim(dev); /* ignore errors */ up (&dev->sem); } /* and use filp->private_data to point to the device data */ filp->private_data = dev; return 0; /* success */ }