Skip to content

Commit

Permalink
staging: comedi: comedi_fops: introduce comedi_dev_from_minor()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jan 7, 2013
1 parent 43bd33f commit 85104e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/staging/comedi/comedi_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions drivers/staging/comedi/comedidev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 85104e9

Please sign in to comment.