summaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2015-06-18 10:54:47 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-06-18 21:19:02 -0700
commita69153f66f3caef506a6a03a6f6ba76f75f57d29 (patch)
treec3d09c06b0dc260d6e59584bbe58d69bc0a72f82 /drivers/staging
parentcf2f9224e7d0112b2a20056de7f8b23060140a1a (diff)
downloadblackbird-obmc-linux-a69153f66f3caef506a6a03a6f6ba76f75f57d29.tar.gz
blackbird-obmc-linux-a69153f66f3caef506a6a03a6f6ba76f75f57d29.zip
staging: comedi: das800: cleanup das800_probe()
Make this function return a pointer to the boardinfo instead of an index. Since it's not typical, add a comment to clarify why this legacy driver does a probe. For aesthetics, rename the local variable 'board' to 'index. Consolidate the dev_dbg() messages when a probed boardinfo is used and remove the extra dev_dbg() message when the boardinfo is not found. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/comedi/drivers/das800.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c
index 39d304a1259f..bc9fa4b317b2 100644
--- a/drivers/staging/comedi/drivers/das800.c
+++ b/drivers/staging/comedi/drivers/das800.c
@@ -604,44 +604,53 @@ static int das800_do_insn_bits(struct comedi_device *dev,
return insn->n;
}
-static int das800_probe(struct comedi_device *dev)
+static const struct das800_board *das800_probe(struct comedi_device *dev)
{
const struct das800_board *thisboard = dev->board_ptr;
- int board = thisboard ? thisboard - das800_boards : -EINVAL;
+ int index = thisboard ? thisboard - das800_boards : -EINVAL;
int id_bits;
unsigned long irq_flags;
+ /*
+ * The dev->board_ptr will be set by comedi_device_attach() if the
+ * board name provided by the user matches a board->name in this
+ * driver. If so, this function sanity checks the id_bits to verify
+ * that the board is correct.
+ *
+ * If the dev->board_ptr is not set, the user is trying to attach
+ * an unspecified board to this driver. In this case the id_bits
+ * are used to 'probe' for the correct dev->board_ptr.
+ */
spin_lock_irqsave(&dev->spinlock, irq_flags);
id_bits = das800_ind_read(dev, ID) & 0x3;
spin_unlock_irqrestore(&dev->spinlock, irq_flags);
switch (id_bits) {
case 0x0:
- if (board == BOARD_DAS800 || board == BOARD_CIODAS800)
- break;
- dev_dbg(dev->class_dev, "Board model (probed): DAS-800\n");
- board = BOARD_DAS800;
+ if (index == BOARD_DAS800 || index == BOARD_CIODAS800)
+ return thisboard;
+ index = BOARD_DAS800;
break;
case 0x2:
- if (board == BOARD_DAS801 || board == BOARD_CIODAS801)
- break;
- dev_dbg(dev->class_dev, "Board model (probed): DAS-801\n");
- board = BOARD_DAS801;
+ if (index == BOARD_DAS801 || index == BOARD_CIODAS801)
+ return thisboard;
+ index = BOARD_DAS801;
break;
case 0x3:
- if (board == BOARD_DAS802 || board == BOARD_CIODAS802 ||
- board == BOARD_CIODAS80216)
- break;
- dev_dbg(dev->class_dev, "Board model (probed): DAS-802\n");
- board = BOARD_DAS802;
+ if (index == BOARD_DAS802 || index == BOARD_CIODAS802 ||
+ index == BOARD_CIODAS80216)
+ return thisboard;
+ index = BOARD_DAS802;
break;
default:
dev_dbg(dev->class_dev, "Board model: 0x%x (unknown)\n",
id_bits);
- board = -EINVAL;
- break;
+ return NULL;
}
- return board;
+ dev_dbg(dev->class_dev, "Board model (probed): %s series\n",
+ das800_boards[index].name);
+
+ return &das800_boards[index];
}
static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
@@ -651,7 +660,6 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
struct comedi_subdevice *s;
unsigned int irq = it->options[1];
unsigned long irq_flags;
- int board;
int ret;
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
@@ -662,13 +670,10 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (ret)
return ret;
- board = das800_probe(dev);
- if (board < 0) {
- dev_dbg(dev->class_dev, "unable to determine board type\n");
+ thisboard = das800_probe(dev);
+ if (!thisboard)
return -ENODEV;
- }
- dev->board_ptr = das800_boards + board;
- thisboard = dev->board_ptr;
+ dev->board_ptr = thisboard;
dev->board_name = thisboard->name;
if (irq > 1 && irq <= 7) {
OpenPOWER on IntegriCloud