コード例 #1
0
ファイル: main.c プロジェクト: crond/dd
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);
}
コード例 #2
0
ファイル: main.c プロジェクト: hunterhu/ldd3-examples-updated
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);
}
コード例 #3
0
ファイル: main.c プロジェクト: hunterhu/ldd3-examples-updated
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 */
}
コード例 #4
0
ファイル: main.c プロジェクト: crond/dd
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 */
}