Skip to content

Commit

Permalink
staging: comedi: don't override read/write subdevice if not supported
Browse files Browse the repository at this point in the history
For comedi devices that support asynchronous commands on some of their
subdevices, the comedi core creates extra device files for each of those
subdevices of the form "/dev/comedi%i_subd%i".  These use the same
comedi device as the corresponding "/dev/comedi%i" but override the
default "read" and "write" subdevice for the device.  Currently it
overrides both the read and write subdevice, but it only makes sense to
override the "read" subdevice if the subdevice supports "read" commands,
and to override the "write" subdevice if the subdevice supports "write"
commands.

In `comedi_alloc_subdevice_minor()`, only set `info->read_subdevice`
non-NULL if the subdevice has the `SDF_CMD_READ` flag set, and only set
`info->write_subdevice` non-NULL if the subdevice has the
`SDF_CMD_WRITE` flag set.  (`comedi_read_subdevice(info)` will use the
device's default read subdevice if `info->read_subdevice` is NULL.
`comedi_write_subdevice(info)` will use the device's default write
subdevice if `info->write_subdevice` is NULL.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Jan 30, 2013
1 parent 12e9a5f commit 1046406
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/staging/comedi/comedi_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -2358,8 +2358,10 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
if (!info)
return -ENOMEM;
info->device = dev;
info->read_subdevice = s;
info->write_subdevice = s;
if (s->subdev_flags & SDF_CMD_READ)
info->read_subdevice = s;
if (s->subdev_flags & SDF_CMD_WRITE)
info->write_subdevice = s;
spin_lock(&comedi_file_info_table_lock);
for (i = COMEDI_FIRST_SUBDEVICE_MINOR; i < COMEDI_NUM_MINORS; ++i) {
if (comedi_file_info_table[i] == NULL) {
Expand Down

0 comments on commit 1046406

Please sign in to comment.