]> Pileus Git - ~andy/linux/commitdiff
staging: comedi: comedi_fops: introduce comedi_dev_from_minor()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 19 Dec 2012 22:34:40 +0000 (15:34 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 Jan 2013 22:25:46 +0000 (14:25 -0800)
A number of functions have to call comedi_get_device_file_info()
to get the comedi_device_file_info pointer for a given minor. That
pointer is only used to get the actual comedi_device pointer for
the minor.

Introduce a new helper function, comedi_dev_from_minor(), to simplify
this operation. This will also allow us to make the comedi_device_file_info
struct private.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/comedi_fops.c
drivers/staging/comedi/comedidev.h

index 38de7f70f0b8388e2a05d936a608c65b43c7c706..647c7f347ee02b7e5ae2d16ab54bd8ea138459d8 100644 (file)
@@ -90,6 +90,16 @@ static DEFINE_SPINLOCK(comedi_file_info_table_lock);
 static struct comedi_device_file_info
 *comedi_file_info_table[COMEDI_NUM_MINORS];
 
+struct comedi_device *comedi_dev_from_minor(unsigned minor)
+{
+       struct comedi_device_file_info *info;
+
+       info = comedi_get_device_file_info(minor);
+
+       return info ? info->device : NULL;
+}
+EXPORT_SYMBOL_GPL(comedi_dev_from_minor);
+
 static struct comedi_subdevice *
 comedi_get_read_subdevice(const struct comedi_device_file_info *info)
 {
index a2123ae7daba8d2c4d38d6806a107e034bb03cd7..fc2c17925381766c7da377fcf49f6c4bc0aaf0b6 100644 (file)
@@ -282,6 +282,8 @@ static const unsigned COMEDI_SUBDEVICE_MINOR_OFFSET = 1;
 
 struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor);
 
+struct comedi_device *comedi_dev_from_minor(unsigned minor);
+
 int comedi_alloc_subdevices(struct comedi_device *, int);
 
 void comedi_device_detach(struct comedi_device *dev);