Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1a59171 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b678075f
Loading
Loading
Loading
Loading
+65 −81
Original line number Diff line number Diff line
@@ -169,46 +169,54 @@ 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[] = {
	{
	[BOARD_DAS800] = {
		.name		= "das-800",
		.ai_speed	= 25000,
		.ai_range	= &range_bipolar5,
		.resolution	= 12,
	},
	{
	[BOARD_CIODAS800] = {
		.name		= "cio-das800",
		.ai_speed	= 20000,
		.ai_range	= &range_bipolar5,
		.resolution	= 12,
	},
	{
	[BOARD_DAS801] = {
		.name		= "das-801",
		.ai_speed	= 25000,
		.ai_range	= &range_das801_ai,
		.resolution	= 12,
	},
	{
	[BOARD_CIODAS801] = {
		.name		= "cio-das801",
		.ai_speed	= 20000,
		.ai_range	= &range_cio_das801_ai,
		.resolution	= 12,
	},
	{
	[BOARD_DAS802] = {
		.name		= "das-802",
		.ai_speed	= 25000,
		.ai_range	= &range_das802_ai,
		.resolution	= 12,
	},
	{
	[BOARD_CIODAS802] = {
		.name		= "cio-das802",
		.ai_speed	= 20000,
		.ai_range	= &range_das802_ai,
		.resolution	= 12,
	},
	{
	[BOARD_CIODAS80216] = {
		.name		= "cio-das802/16",
		.ai_speed	= 10000,
		.ai_range	= &range_das80216_ai,
@@ -670,65 +678,41 @@ static int das800_do_wbits(struct comedi_device *dev,
static int das800_probe(struct comedi_device *dev)
{
	const struct das800_board *thisboard = comedi_board(dev);
	int board = thisboard ? thisboard - das800_boards : -EINVAL;
	int id_bits;
	unsigned long irq_flags;
	int board;

	spin_lock_irqsave(&dev->spinlock, irq_flags);
	id_bits = das800_ind_read(dev, ID) & 0x3;
	spin_unlock_irqrestore(&dev->spinlock, irq_flags);

	board = thisboard - das800_boards;

	switch (id_bits) {
	case 0x0:
		if (board == das800) {
			dev_dbg(dev->class_dev, "Board model: DAS-800\n");
			return board;
		}
		if (board == ciodas800) {
			dev_dbg(dev->class_dev, "Board model: CIO-DAS800\n");
			return board;
		}
		if (board == BOARD_DAS800 || board == BOARD_CIODAS800)
			break;
		dev_dbg(dev->class_dev, "Board model (probed): DAS-800\n");
		return das800;
		board = BOARD_DAS800;
		break;
	case 0x2:
		if (board == das801) {
			dev_dbg(dev->class_dev, "Board model: DAS-801\n");
			return board;
		}
		if (board == ciodas801) {
			dev_dbg(dev->class_dev, "Board model: CIO-DAS801\n");
			return board;
		}
		if (board == BOARD_DAS801 || board == BOARD_CIODAS801)
			break;
		dev_dbg(dev->class_dev, "Board model (probed): DAS-801\n");
		return das801;
		board = BOARD_DAS801;
		break;
	case 0x3:
		if (board == das802) {
			dev_dbg(dev->class_dev, "Board model: DAS-802\n");
			return board;
		}
		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;
		}
		if (board == BOARD_DAS802 || board == BOARD_CIODAS802 ||
		    board == BOARD_CIODAS80216)
			break;
		dev_dbg(dev->class_dev, "Board model (probed): DAS-802\n");
		return das802;
		board = BOARD_DAS802;
		break;
	default:
		dev_dbg(dev->class_dev,
			"Board model: probe returned 0x%x (unknown)\n",
		dev_dbg(dev->class_dev, "Board model: 0x%x (unknown)\n",
			id_bits);
		return board;
		board = -EINVAL;
		break;
	}
	return -1;
	return board;
}

static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)