struct mutex mutex; /* Mutex for locking image */
struct device *device; /* Sysfs device */
struct vme_resource *resource; /* VME resource */
- int users; /* Number of current users */
int mmap_count; /* Number of current mmap's */
};
static struct image_desc image[VME_DEVS];
};
-static int vme_user_open(struct inode *inode, struct file *file)
-{
- int err;
- unsigned int minor = MINOR(inode->i_rdev);
-
- mutex_lock(&image[minor].mutex);
- /* Allow device to be opened if a resource is needed and allocated. */
- if (minor < CONTROL_MINOR && image[minor].resource == NULL) {
- pr_err("No resources allocated for device\n");
- err = -EINVAL;
- goto err_res;
- }
-
- /* Increment user count */
- image[minor].users++;
-
- mutex_unlock(&image[minor].mutex);
-
- return 0;
-
-err_res:
- mutex_unlock(&image[minor].mutex);
-
- return err;
-}
-
-static int vme_user_release(struct inode *inode, struct file *file)
-{
- unsigned int minor = MINOR(inode->i_rdev);
-
- mutex_lock(&image[minor].mutex);
-
- /* Decrement user count */
- image[minor].users--;
-
- mutex_unlock(&image[minor].mutex);
-
- return 0;
-}
-
/*
* We are going ot alloc a page during init per window for small transfers.
* Small transfers will go VME -> buffer -> user space. Larger (more than a
}
static const struct file_operations vme_user_fops = {
- .open = vme_user_open,
- .release = vme_user_release,
.read = vme_user_read,
.write = vme_user_write,
.llseek = vme_user_llseek,
mutex_init(&image[i].mutex);
image[i].device = NULL;
image[i].resource = NULL;
- image[i].users = 0;
}
/* Assign major and minor numbers for the driver */