void scullp_cleanup(void) { int i; unregister_chrdev(scullp_major, "scullp"); #ifdef SCULLP_USE_PROC remove_proc_entry("scullpmem", 0); #endif for (i=0; i<scullp_devs; i++) scullp_trim(scullp_devices+i); kfree(scullp_devices); }
void scullp_cleanup(void) { int i; #ifdef SCULLP_USE_PROC remove_proc_entry("scullpmem", NULL); #endif for (i = 0; i < scullp_devs; i++) { cdev_del(&scullp_devices[i].cdev); scullp_trim(scullp_devices + i); } kfree(scullp_devices); unregister_chrdev_region(MKDEV (scullp_major, 0), scullp_devs); }
int scullp_open (struct inode *inode, struct file *filp) { struct scullp_dev *dev; /* device information */ /* Find the device */ dev = container_of(inode->i_cdev, struct scullp_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; scullp_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 */ }
int scullp_open (struct inode *inode, struct file *filp) { int num = MINOR(inode->i_rdev); ScullP_Dev *dev; /* device information */ /* check the device number */ if (num >= scullp_devs) return -ENODEV; dev = &scullp_devices[num]; /* 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; scullp_trim(dev); /* ignore errors */ up (&dev->sem); } /* and use filp->private_data to point to the device data */ filp->private_data = dev; MOD_INC_USE_COUNT; return 0; /* success */ }