From: H Hartley Sweeten Date: Wed, 19 Dec 2012 22:34:40 +0000 (-0700) Subject: staging: comedi: comedi_fops: introduce comedi_dev_from_minor() X-Git-Tag: upstream/snapshot3+hdmi~5696^2~537 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85104e9b409013c78624b367dec02e6ccc996635;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git 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 Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 38de7f7..647c7f3 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -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) { diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index a2123ae..fc2c179 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -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);