mirror of
https://github.com/torvalds/linux.git
synced 2024-12-05 02:23:16 +00:00
staging: comedi: das1800: cleanup das1800_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. 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>
This commit is contained in:
parent
4f3aa186d3
commit
06ad6bd869
@ -1216,62 +1216,67 @@ static void das1800_free_dma(struct comedi_device *dev)
|
|||||||
comedi_isadma_free(devpriv->dma);
|
comedi_isadma_free(devpriv->dma);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int das1800_probe(struct comedi_device *dev)
|
static const struct das1800_board *das1800_probe(struct comedi_device *dev)
|
||||||
{
|
{
|
||||||
const struct das1800_board *board = dev->board_ptr;
|
const struct das1800_board *board = dev->board_ptr;
|
||||||
int index;
|
int index = board ? board - das1800_boards : -EINVAL;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
/* calc the offset to the boardinfo that was found by the core */
|
/*
|
||||||
index = board - das1800_boards;
|
* 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
|
||||||
/* verify that the board id matches the boardinfo */
|
* driver. If so, this function sanity checks the id 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 is used
|
||||||
|
* to 'probe' for the correct dev->board_ptr.
|
||||||
|
*/
|
||||||
id = (inb(dev->iobase + DAS1800_DIGITAL) >> 4) & 0xf;
|
id = (inb(dev->iobase + DAS1800_DIGITAL) >> 4) & 0xf;
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0x3:
|
case 0x3:
|
||||||
if (index == das1801st_da || index == das1802st_da ||
|
if (index == das1801st_da || index == das1802st_da ||
|
||||||
index == das1701st_da || index == das1702st_da)
|
index == das1701st_da || index == das1702st_da)
|
||||||
return index;
|
return board;
|
||||||
index = das1801st;
|
index = das1801st;
|
||||||
break;
|
break;
|
||||||
case 0x4:
|
case 0x4:
|
||||||
if (index == das1802hr_da || index == das1702hr_da)
|
if (index == das1802hr_da || index == das1702hr_da)
|
||||||
return index;
|
return board;
|
||||||
index = das1802hr;
|
index = das1802hr;
|
||||||
break;
|
break;
|
||||||
case 0x5:
|
case 0x5:
|
||||||
if (index == das1801ao || index == das1802ao ||
|
if (index == das1801ao || index == das1802ao ||
|
||||||
index == das1701ao || index == das1702ao)
|
index == das1701ao || index == das1702ao)
|
||||||
return index;
|
return board;
|
||||||
index = das1801ao;
|
index = das1801ao;
|
||||||
break;
|
break;
|
||||||
case 0x6:
|
case 0x6:
|
||||||
if (index == das1802hr || index == das1702hr)
|
if (index == das1802hr || index == das1702hr)
|
||||||
return index;
|
return board;
|
||||||
index = das1802hr;
|
index = das1802hr;
|
||||||
break;
|
break;
|
||||||
case 0x7:
|
case 0x7:
|
||||||
if (index == das1801st || index == das1802st ||
|
if (index == das1801st || index == das1802st ||
|
||||||
index == das1701st || index == das1702st)
|
index == das1701st || index == das1702st)
|
||||||
return index;
|
return board;
|
||||||
index = das1801st;
|
index = das1801st;
|
||||||
break;
|
break;
|
||||||
case 0x8:
|
case 0x8:
|
||||||
if (index == das1801hc || index == das1802hc)
|
if (index == das1801hc || index == das1802hc)
|
||||||
return index;
|
return board;
|
||||||
index = das1801hc;
|
index = das1801hc;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
dev_err(dev->class_dev,
|
dev_err(dev->class_dev,
|
||||||
"Board model: probe returned 0x%x (unknown, please report)\n",
|
"Board model: probe returned 0x%x (unknown, please report)\n",
|
||||||
id);
|
id);
|
||||||
break;
|
return NULL;
|
||||||
}
|
}
|
||||||
dev_err(dev->class_dev,
|
dev_err(dev->class_dev,
|
||||||
"Board model (probed, not recommended): %s series\n",
|
"Board model (probed, not recommended): %s series\n",
|
||||||
das1800_boards[index].name);
|
das1800_boards[index].name);
|
||||||
|
|
||||||
return index;
|
return &das1800_boards[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int das1800_attach(struct comedi_device *dev,
|
static int das1800_attach(struct comedi_device *dev,
|
||||||
@ -1281,7 +1286,6 @@ static int das1800_attach(struct comedi_device *dev,
|
|||||||
struct das1800_private *devpriv;
|
struct das1800_private *devpriv;
|
||||||
struct comedi_subdevice *s;
|
struct comedi_subdevice *s;
|
||||||
unsigned int irq = it->options[1];
|
unsigned int irq = it->options[1];
|
||||||
int board;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
|
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
|
||||||
@ -1292,14 +1296,12 @@ static int das1800_attach(struct comedi_device *dev,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
board = das1800_probe(dev);
|
thisboard = das1800_probe(dev);
|
||||||
if (board < 0) {
|
if (!thisboard) {
|
||||||
dev_err(dev->class_dev, "unable to determine board type\n");
|
dev_err(dev->class_dev, "unable to determine board type\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
dev->board_ptr = thisboard;
|
||||||
dev->board_ptr = das1800_boards + board;
|
|
||||||
thisboard = dev->board_ptr;
|
|
||||||
dev->board_name = thisboard->name;
|
dev->board_name = thisboard->name;
|
||||||
|
|
||||||
/* if it is an 'ao' board with fancy analog out then we need extra io ports */
|
/* if it is an 'ao' board with fancy analog out then we need extra io ports */
|
||||||
|
Loading…
Reference in New Issue
Block a user