Commit 4da5fa9a authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: use comedi_dev_from_minor()

Remove the need to export comedi_get_device_file_info() by using the
new helper comedi_dev_from_minor(). This will also allow us to make
the comedi_device_file_info struct private.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 85104e9b
...@@ -1608,14 +1608,11 @@ static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, ...@@ -1608,14 +1608,11 @@ static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
const unsigned minor = iminor(file->f_dentry->d_inode); const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_device_file_info *dev_file_info = struct comedi_device *dev = comedi_dev_from_minor(minor);
comedi_get_device_file_info(minor);
struct comedi_device *dev;
int rc; int rc;
if (dev_file_info == NULL || dev_file_info->device == NULL) if (!dev)
return -ENODEV; return -ENODEV;
dev = dev_file_info->device;
mutex_lock(&dev->mutex); mutex_lock(&dev->mutex);
...@@ -2088,12 +2085,9 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, ...@@ -2088,12 +2085,9 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
static int comedi_open(struct inode *inode, struct file *file) static int comedi_open(struct inode *inode, struct file *file)
{ {
const unsigned minor = iminor(inode); const unsigned minor = iminor(inode);
struct comedi_device_file_info *dev_file_info = struct comedi_device *dev = comedi_dev_from_minor(minor);
comedi_get_device_file_info(minor);
struct comedi_device *dev =
dev_file_info ? dev_file_info->device : NULL;
if (dev == NULL) { if (!dev) {
DPRINTK("invalid minor number\n"); DPRINTK("invalid minor number\n");
return -ENODEV; return -ENODEV;
} }
...@@ -2168,14 +2162,9 @@ static int comedi_open(struct inode *inode, struct file *file) ...@@ -2168,14 +2162,9 @@ static int comedi_open(struct inode *inode, struct file *file)
static int comedi_fasync(int fd, struct file *file, int on) static int comedi_fasync(int fd, struct file *file, int on)
{ {
const unsigned minor = iminor(file->f_dentry->d_inode); const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_device_file_info *dev_file_info; struct comedi_device *dev = comedi_dev_from_minor(minor);
struct comedi_device *dev;
dev_file_info = comedi_get_device_file_info(minor);
if (dev_file_info == NULL) if (!dev)
return -ENODEV;
dev = dev_file_info->device;
if (dev == NULL)
return -ENODEV; return -ENODEV;
return fasync_helper(fd, file, on, &dev->async_queue); return fasync_helper(fd, file, on, &dev->async_queue);
...@@ -2184,16 +2173,11 @@ static int comedi_fasync(int fd, struct file *file, int on) ...@@ -2184,16 +2173,11 @@ static int comedi_fasync(int fd, struct file *file, int on)
static int comedi_close(struct inode *inode, struct file *file) static int comedi_close(struct inode *inode, struct file *file)
{ {
const unsigned minor = iminor(inode); const unsigned minor = iminor(inode);
struct comedi_device *dev = comedi_dev_from_minor(minor);
struct comedi_subdevice *s = NULL; struct comedi_subdevice *s = NULL;
int i; int i;
struct comedi_device_file_info *dev_file_info;
struct comedi_device *dev;
dev_file_info = comedi_get_device_file_info(minor);
if (dev_file_info == NULL) if (!dev)
return -ENODEV;
dev = dev_file_info->device;
if (dev == NULL)
return -ENODEV; return -ENODEV;
mutex_lock(&dev->mutex); mutex_lock(&dev->mutex);
......
...@@ -213,13 +213,10 @@ int comedi_driver_unregister(struct comedi_driver *driver) ...@@ -213,13 +213,10 @@ int comedi_driver_unregister(struct comedi_driver *driver)
/* check for devices using this driver */ /* check for devices using this driver */
for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
struct comedi_device_file_info *dev_file_info = struct comedi_device *dev = comedi_dev_from_minor(i);
comedi_get_device_file_info(i);
struct comedi_device *dev;
if (dev_file_info == NULL) if (!dev)
continue; continue;
dev = dev_file_info->device;
mutex_lock(&dev->mutex); mutex_lock(&dev->mutex);
if (dev->attached && dev->driver == driver) { if (dev->attached && dev->driver == driver) {
...@@ -834,7 +831,6 @@ int comedi_auto_config(struct device *hardware_device, ...@@ -834,7 +831,6 @@ int comedi_auto_config(struct device *hardware_device,
struct comedi_driver *driver, unsigned long context) struct comedi_driver *driver, unsigned long context)
{ {
int minor; int minor;
struct comedi_device_file_info *dev_file_info;
struct comedi_device *comedi_dev; struct comedi_device *comedi_dev;
int ret; int ret;
...@@ -852,8 +848,7 @@ int comedi_auto_config(struct device *hardware_device, ...@@ -852,8 +848,7 @@ int comedi_auto_config(struct device *hardware_device,
if (minor < 0) if (minor < 0)
return minor; return minor;
dev_file_info = comedi_get_device_file_info(minor); comedi_dev = comedi_dev_from_minor(minor);
comedi_dev = dev_file_info->device;
mutex_lock(&comedi_dev->mutex); mutex_lock(&comedi_dev->mutex);
if (comedi_dev->attached) if (comedi_dev->attached)
......
...@@ -42,7 +42,6 @@ MODULE_LICENSE("GPL"); ...@@ -42,7 +42,6 @@ MODULE_LICENSE("GPL");
struct comedi_device *comedi_open(const char *filename) struct comedi_device *comedi_open(const char *filename)
{ {
struct comedi_device_file_info *dev_file_info;
struct comedi_device *dev; struct comedi_device *dev;
unsigned int minor; unsigned int minor;
...@@ -54,12 +53,9 @@ struct comedi_device *comedi_open(const char *filename) ...@@ -54,12 +53,9 @@ struct comedi_device *comedi_open(const char *filename)
if (minor >= COMEDI_NUM_BOARD_MINORS) if (minor >= COMEDI_NUM_BOARD_MINORS)
return NULL; return NULL;
dev_file_info = comedi_get_device_file_info(minor); dev = comedi_dev_from_minor(minor);
if (dev_file_info == NULL)
return NULL;
dev = dev_file_info->device;
if (dev == NULL || !dev->attached) if (!dev || !dev->attached)
return NULL; return NULL;
if (!try_module_get(dev->driver->module)) if (!try_module_get(dev->driver->module))
......
...@@ -49,13 +49,10 @@ static int comedi_read(char *buf, char **start, off_t offset, int len, ...@@ -49,13 +49,10 @@ static int comedi_read(char *buf, char **start, off_t offset, int len,
"driver_name, board_name, n_subdevices"); "driver_name, board_name, n_subdevices");
for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
struct comedi_device_file_info *dev_file_info = struct comedi_device *dev = comedi_dev_from_minor(i);
comedi_get_device_file_info(i);
struct comedi_device *dev;
if (dev_file_info == NULL) if (!dev)
continue; continue;
dev = dev_file_info->device;
if (dev->attached) { if (dev->attached) {
devices_q = 1; devices_q = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment