Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: comedi: comedi_fops: introduce comedi_dev_from_minor()

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>

authored by

H Hartley Sweeten and committed by
Greg Kroah-Hartman
85104e9b 43bd33f2

+12
+10
drivers/staging/comedi/comedi_fops.c
··· 90 90 static struct comedi_device_file_info 91 91 *comedi_file_info_table[COMEDI_NUM_MINORS]; 92 92 93 + struct comedi_device *comedi_dev_from_minor(unsigned minor) 94 + { 95 + struct comedi_device_file_info *info; 96 + 97 + info = comedi_get_device_file_info(minor); 98 + 99 + return info ? info->device : NULL; 100 + } 101 + EXPORT_SYMBOL_GPL(comedi_dev_from_minor); 102 + 93 103 static struct comedi_subdevice * 94 104 comedi_get_read_subdevice(const struct comedi_device_file_info *info) 95 105 {
+2
drivers/staging/comedi/comedidev.h
··· 282 282 283 283 struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor); 284 284 285 + struct comedi_device *comedi_dev_from_minor(unsigned minor); 286 + 285 287 int comedi_alloc_subdevices(struct comedi_device *, int); 286 288 287 289 void comedi_device_detach(struct comedi_device *dev);