staging: comedi: das800: cleanup the boardinfo
For aesthetic reasons, name the enum used for the boardinfo indexes and change them to uppercase with the prefix BOARD_. Add some whitespace to the boardinfo declaration and use the enum values to clarify the table. Tidy up the das800_probe() function and only output a dev_dbg() message if a board model is actually probed. If the user provided the correct boardname when attaching to this driver the message is just added noise. For the 'default' case when checking the proded id, output the id_bits and return -EINVAL. It should not be assumed that unknown boards will work with this driver. 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
b678075f9a
commit
c1a5917157
|
@ -169,51 +169,59 @@ static const struct comedi_lrange range_das80216_ai = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { das800, ciodas800, das801, ciodas801, das802, ciodas802, ciodas80216 };
|
enum das800_boardinfo {
|
||||||
|
BOARD_DAS800,
|
||||||
|
BOARD_CIODAS800,
|
||||||
|
BOARD_DAS801,
|
||||||
|
BOARD_CIODAS801,
|
||||||
|
BOARD_DAS802,
|
||||||
|
BOARD_CIODAS802,
|
||||||
|
BOARD_CIODAS80216,
|
||||||
|
};
|
||||||
|
|
||||||
static const struct das800_board das800_boards[] = {
|
static const struct das800_board das800_boards[] = {
|
||||||
{
|
[BOARD_DAS800] = {
|
||||||
.name = "das-800",
|
.name = "das-800",
|
||||||
.ai_speed = 25000,
|
.ai_speed = 25000,
|
||||||
.ai_range = &range_bipolar5,
|
.ai_range = &range_bipolar5,
|
||||||
.resolution = 12,
|
.resolution = 12,
|
||||||
},
|
},
|
||||||
{
|
[BOARD_CIODAS800] = {
|
||||||
.name = "cio-das800",
|
.name = "cio-das800",
|
||||||
.ai_speed = 20000,
|
.ai_speed = 20000,
|
||||||
.ai_range = &range_bipolar5,
|
.ai_range = &range_bipolar5,
|
||||||
.resolution = 12,
|
.resolution = 12,
|
||||||
},
|
},
|
||||||
{
|
[BOARD_DAS801] = {
|
||||||
.name = "das-801",
|
.name = "das-801",
|
||||||
.ai_speed = 25000,
|
.ai_speed = 25000,
|
||||||
.ai_range = &range_das801_ai,
|
.ai_range = &range_das801_ai,
|
||||||
.resolution = 12,
|
.resolution = 12,
|
||||||
},
|
},
|
||||||
{
|
[BOARD_CIODAS801] = {
|
||||||
.name = "cio-das801",
|
.name = "cio-das801",
|
||||||
.ai_speed = 20000,
|
.ai_speed = 20000,
|
||||||
.ai_range = &range_cio_das801_ai,
|
.ai_range = &range_cio_das801_ai,
|
||||||
.resolution = 12,
|
.resolution = 12,
|
||||||
},
|
},
|
||||||
{
|
[BOARD_DAS802] = {
|
||||||
.name = "das-802",
|
.name = "das-802",
|
||||||
.ai_speed = 25000,
|
.ai_speed = 25000,
|
||||||
.ai_range = &range_das802_ai,
|
.ai_range = &range_das802_ai,
|
||||||
.resolution = 12,
|
.resolution = 12,
|
||||||
},
|
},
|
||||||
{
|
[BOARD_CIODAS802] = {
|
||||||
.name = "cio-das802",
|
.name = "cio-das802",
|
||||||
.ai_speed = 20000,
|
.ai_speed = 20000,
|
||||||
.ai_range = &range_das802_ai,
|
.ai_range = &range_das802_ai,
|
||||||
.resolution = 12,
|
.resolution = 12,
|
||||||
},
|
},
|
||||||
{
|
[BOARD_CIODAS80216] = {
|
||||||
.name = "cio-das802/16",
|
.name = "cio-das802/16",
|
||||||
.ai_speed = 10000,
|
.ai_speed = 10000,
|
||||||
.ai_range = &range_das80216_ai,
|
.ai_range = &range_das80216_ai,
|
||||||
.resolution = 16,
|
.resolution = 16,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
struct das800_private {
|
struct das800_private {
|
||||||
|
@ -670,65 +678,41 @@ static int das800_do_wbits(struct comedi_device *dev,
|
||||||
static int das800_probe(struct comedi_device *dev)
|
static int das800_probe(struct comedi_device *dev)
|
||||||
{
|
{
|
||||||
const struct das800_board *thisboard = comedi_board(dev);
|
const struct das800_board *thisboard = comedi_board(dev);
|
||||||
|
int board = thisboard ? thisboard - das800_boards : -EINVAL;
|
||||||
int id_bits;
|
int id_bits;
|
||||||
unsigned long irq_flags;
|
unsigned long irq_flags;
|
||||||
int board;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->spinlock, irq_flags);
|
spin_lock_irqsave(&dev->spinlock, irq_flags);
|
||||||
id_bits = das800_ind_read(dev, ID) & 0x3;
|
id_bits = das800_ind_read(dev, ID) & 0x3;
|
||||||
spin_unlock_irqrestore(&dev->spinlock, irq_flags);
|
spin_unlock_irqrestore(&dev->spinlock, irq_flags);
|
||||||
|
|
||||||
board = thisboard - das800_boards;
|
|
||||||
|
|
||||||
switch (id_bits) {
|
switch (id_bits) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
if (board == das800) {
|
if (board == BOARD_DAS800 || board == BOARD_CIODAS800)
|
||||||
dev_dbg(dev->class_dev, "Board model: DAS-800\n");
|
break;
|
||||||
return board;
|
|
||||||
}
|
|
||||||
if (board == ciodas800) {
|
|
||||||
dev_dbg(dev->class_dev, "Board model: CIO-DAS800\n");
|
|
||||||
return board;
|
|
||||||
}
|
|
||||||
dev_dbg(dev->class_dev, "Board model (probed): DAS-800\n");
|
dev_dbg(dev->class_dev, "Board model (probed): DAS-800\n");
|
||||||
return das800;
|
board = BOARD_DAS800;
|
||||||
break;
|
break;
|
||||||
case 0x2:
|
case 0x2:
|
||||||
if (board == das801) {
|
if (board == BOARD_DAS801 || board == BOARD_CIODAS801)
|
||||||
dev_dbg(dev->class_dev, "Board model: DAS-801\n");
|
break;
|
||||||
return board;
|
|
||||||
}
|
|
||||||
if (board == ciodas801) {
|
|
||||||
dev_dbg(dev->class_dev, "Board model: CIO-DAS801\n");
|
|
||||||
return board;
|
|
||||||
}
|
|
||||||
dev_dbg(dev->class_dev, "Board model (probed): DAS-801\n");
|
dev_dbg(dev->class_dev, "Board model (probed): DAS-801\n");
|
||||||
return das801;
|
board = BOARD_DAS801;
|
||||||
break;
|
break;
|
||||||
case 0x3:
|
case 0x3:
|
||||||
if (board == das802) {
|
if (board == BOARD_DAS802 || board == BOARD_CIODAS802 ||
|
||||||
dev_dbg(dev->class_dev, "Board model: DAS-802\n");
|
board == BOARD_CIODAS80216)
|
||||||
return board;
|
break;
|
||||||
}
|
|
||||||
if (board == ciodas802) {
|
|
||||||
dev_dbg(dev->class_dev, "Board model: CIO-DAS802\n");
|
|
||||||
return board;
|
|
||||||
}
|
|
||||||
if (board == ciodas80216) {
|
|
||||||
dev_dbg(dev->class_dev, "Board model: CIO-DAS802/16\n");
|
|
||||||
return board;
|
|
||||||
}
|
|
||||||
dev_dbg(dev->class_dev, "Board model (probed): DAS-802\n");
|
dev_dbg(dev->class_dev, "Board model (probed): DAS-802\n");
|
||||||
return das802;
|
board = BOARD_DAS802;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_dbg(dev->class_dev,
|
dev_dbg(dev->class_dev, "Board model: 0x%x (unknown)\n",
|
||||||
"Board model: probe returned 0x%x (unknown)\n",
|
|
||||||
id_bits);
|
id_bits);
|
||||||
return board;
|
board = -EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return -1;
|
return board;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||||
|
|
Loading…
Reference in New Issue