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

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

staging: comedi: cb_pcidas64: use the pci id_table 'driver_data'



Create an enum to the boardinfo and pass that enum in the pci_driver
id_table as the driver_data.

Change the macro used to fill in the device table from PCI_DEVICE() to
PCI_VDEVICE(). This allows passing the enum as the next field.

This allows removing the 'device_id' data from the boardinfo as well
the search function that was used to locate the boardinfo for the PCI
device.

Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9b315bcb
Loading
Loading
Loading
Loading
+92 −98
Original line number Diff line number Diff line
@@ -593,9 +593,39 @@ struct hw_fifo_info {
	uint16_t fifo_size_reg_mask;
};

enum pcidas64_boardid {
	BOARD_PCIDAS6402_16,
	BOARD_PCIDAS6402_12,
	BOARD_PCIDAS64_M1_16,
	BOARD_PCIDAS64_M2_16,
	BOARD_PCIDAS64_M3_16,
	BOARD_PCIDAS6013,
	BOARD_PCIDAS6014,
	BOARD_PCIDAS6023,
	BOARD_PCIDAS6025,
	BOARD_PCIDAS6030,
	BOARD_PCIDAS6031,
	BOARD_PCIDAS6032,
	BOARD_PCIDAS6033,
	BOARD_PCIDAS6034,
	BOARD_PCIDAS6035,
	BOARD_PCIDAS6036,
	BOARD_PCIDAS6040,
	BOARD_PCIDAS6052,
	BOARD_PCIDAS6070,
	BOARD_PCIDAS6071,
	BOARD_PCIDAS4020_12,
	BOARD_PCIDAS6402_16_JR,
	BOARD_PCIDAS64_M1_16_JR,
	BOARD_PCIDAS64_M2_16_JR,
	BOARD_PCIDAS64_M3_16_JR,
	BOARD_PCIDAS64_M1_14,
	BOARD_PCIDAS64_M2_14,
	BOARD_PCIDAS64_M3_14,
};

struct pcidas64_board {
	const char *name;
	int device_id;		/*  pci device id */
	int ai_se_chans;	/*  number of ai inputs in single-ended mode */
	int ai_bits;		/*  analog input resolution */
	int ai_speed;		/*  fastest conversion period in ns */
@@ -648,9 +678,8 @@ static inline unsigned int ai_dma_ring_count(const struct pcidas64_board *board)
static const int bytes_in_sample = 2;

static const struct pcidas64_board pcidas64_boards[] = {
	{
	[BOARD_PCIDAS6402_16] = {
	 .name = "pci-das6402/16",
	 .device_id = 0x1d,
	 .ai_se_chans = 64,
	 .ai_bits = 16,
	 .ai_speed = 5000,
@@ -664,9 +693,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_64xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS6402_12] = {
	 .name = "pci-das6402/12",	/*  XXX check */
	 .device_id = 0x1e,
	 .ai_se_chans = 64,
	 .ai_bits = 12,
	 .ai_speed = 5000,
@@ -680,9 +708,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_64xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS64_M1_16] = {
	 .name = "pci-das64/m1/16",
	 .device_id = 0x35,
	 .ai_se_chans = 64,
	 .ai_bits = 16,
	 .ai_speed = 1000,
@@ -696,9 +723,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_64xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS64_M2_16] = {
	 .name = "pci-das64/m2/16",
	 .device_id = 0x36,
	 .ai_se_chans = 64,
	 .ai_bits = 16,
	 .ai_speed = 500,
@@ -712,9 +738,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_64xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS64_M3_16] = {
	 .name = "pci-das64/m3/16",
	 .device_id = 0x37,
	 .ai_se_chans = 64,
	 .ai_bits = 16,
	 .ai_speed = 333,
@@ -728,9 +753,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_64xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS6013] = {
	 .name = "pci-das6013",
	 .device_id = 0x78,
	 .ai_se_chans = 16,
	 .ai_bits = 16,
	 .ai_speed = 5000,
@@ -743,9 +767,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS6014] = {
	 .name = "pci-das6014",
	 .device_id = 0x79,
	 .ai_se_chans = 16,
	 .ai_bits = 16,
	 .ai_speed = 5000,
@@ -759,9 +782,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS6023] = {
	 .name = "pci-das6023",
	 .device_id = 0x5d,
	 .ai_se_chans = 16,
	 .ai_bits = 12,
	 .ai_speed = 5000,
@@ -774,9 +796,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS6025] = {
	 .name = "pci-das6025",
	 .device_id = 0x5e,
	 .ai_se_chans = 16,
	 .ai_bits = 12,
	 .ai_speed = 5000,
@@ -790,9 +811,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS6030] = {
	 .name = "pci-das6030",
	 .device_id = 0x5f,
	 .ai_se_chans = 16,
	 .ai_bits = 16,
	 .ai_speed = 10000,
@@ -806,9 +826,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS6031] = {
	 .name = "pci-das6031",
	 .device_id = 0x60,
	 .ai_se_chans = 64,
	 .ai_bits = 16,
	 .ai_speed = 10000,
@@ -822,9 +841,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS6032] = {
	 .name = "pci-das6032",
	 .device_id = 0x61,
	 .ai_se_chans = 16,
	 .ai_bits = 16,
	 .ai_speed = 10000,
@@ -834,9 +852,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS6033] = {
	 .name = "pci-das6033",
	 .device_id = 0x62,
	 .ai_se_chans = 64,
	 .ai_bits = 16,
	 .ai_speed = 10000,
@@ -846,9 +863,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS6034] = {
	 .name = "pci-das6034",
	 .device_id = 0x63,
	 .ai_se_chans = 16,
	 .ai_bits = 16,
	 .ai_speed = 5000,
@@ -859,9 +875,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS6035] = {
	 .name = "pci-das6035",
	 .device_id = 0x64,
	 .ai_se_chans = 16,
	 .ai_bits = 16,
	 .ai_speed = 5000,
@@ -875,9 +890,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS6036] = {
	 .name = "pci-das6036",
	 .device_id = 0x6f,
	 .ai_se_chans = 16,
	 .ai_bits = 16,
	 .ai_speed = 5000,
@@ -891,9 +905,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS6040] = {
	 .name = "pci-das6040",
	 .device_id = 0x65,
	 .ai_se_chans = 16,
	 .ai_bits = 12,
	 .ai_speed = 2000,
@@ -907,9 +920,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS6052] = {
	 .name = "pci-das6052",
	 .device_id = 0x66,
	 .ai_se_chans = 16,
	 .ai_bits = 16,
	 .ai_speed = 3333,
@@ -923,9 +935,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS6070] = {
	 .name = "pci-das6070",
	 .device_id = 0x67,
	 .ai_se_chans = 16,
	 .ai_bits = 12,
	 .ai_speed = 800,
@@ -939,9 +950,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS6071] = {
	 .name = "pci-das6071",
	 .device_id = 0x68,
	 .ai_se_chans = 64,
	 .ai_bits = 12,
	 .ai_speed = 800,
@@ -955,9 +965,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = &ai_fifo_60xx,
	 .has_8255 = 0,
	 },
	{
	[BOARD_PCIDAS4020_12] = {
	 .name = "pci-das4020/12",
	 .device_id = 0x52,
	 .ai_se_chans = 4,
	 .ai_bits = 12,
	 .ai_speed = 50,
@@ -972,9 +981,12 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .has_8255 = 1,
	 },
#if 0
	{
	/*
	 * The device id for these boards is unknown
	 */

	[BOARD_PCIDAS6402_16_JR] = {
	 .name = "pci-das6402/16/jr",
	 .device_id = 0		/*  XXX, */
	 .ai_se_chans = 64,
	 .ai_bits = 16,
	 .ai_speed = 5000,
@@ -985,9 +997,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = ai_fifo_64xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS64_M1_16_JR] = {
	 .name = "pci-das64/m1/16/jr",
	 .device_id = 0		/*  XXX, */
	 .ai_se_chans = 64,
	 .ai_bits = 16,
	 .ai_speed = 1000,
@@ -998,9 +1009,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = ai_fifo_64xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS64_M2_16_JR] = {
	 .name = "pci-das64/m2/16/jr",
	 .device_id = 0		/*  XXX, */
	 .ai_se_chans = 64,
	 .ai_bits = 16,
	 .ai_speed = 500,
@@ -1011,9 +1021,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = ai_fifo_64xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS64_M3_16_JR] = {
	 .name = "pci-das64/m3/16/jr",
	 .device_id = 0		/*  XXX, */
	 .ai_se_chans = 64,
	 .ai_bits = 16,
	 .ai_speed = 333,
@@ -1024,9 +1033,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = ai_fifo_64xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS64_M1_14] = {
	 .name = "pci-das64/m1/14",
	 .device_id = 0,	/*  XXX */
	 .ai_se_chans = 64,
	 .ai_bits = 14,
	 .ai_speed = 1000,
@@ -1037,9 +1045,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = ai_fifo_64xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS64_M2_14] = {
	 .name = "pci-das64/m2/14",
	 .device_id = 0,	/*  XXX */
	 .ai_se_chans = 64,
	 .ai_bits = 14,
	 .ai_speed = 500,
@@ -1050,9 +1057,8 @@ static const struct pcidas64_board pcidas64_boards[] = {
	 .ai_fifo = ai_fifo_64xx,
	 .has_8255 = 1,
	 },
	{
	[BOARD_PCIDAS64_M3_14] = {
	 .name = "pci-das64/m3/14",
	 .device_id = 0,	/*  XXX */
	 .ai_se_chans = 64,
	 .ai_bits = 14,
	 .ai_speed = 333,
@@ -4033,34 +4039,20 @@ static int setup_subdevices(struct comedi_device *dev)
	return 0;
}

static const struct pcidas64_board
*cb_pcidas64_find_pci_board(struct pci_dev *pcidev)
{
	unsigned int i;

	for (i = 0; i < ARRAY_SIZE(pcidas64_boards); i++)
		if (pcidev->device == pcidas64_boards[i].device_id)
			return &pcidas64_boards[i];
	return NULL;
}

static int auto_attach(struct comedi_device *dev,
				 unsigned long context_unused)
		       unsigned long context)
{
	const struct pcidas64_board *thisboard;
	struct pcidas64_private *devpriv;
	struct pci_dev *pcidev = comedi_to_pci_dev(dev);
	const struct pcidas64_board *thisboard = NULL;
	struct pcidas64_private *devpriv;
	uint32_t local_range, local_decode;
	int retval;

	dev->board_ptr = cb_pcidas64_find_pci_board(pcidev);
	if (!dev->board_ptr) {
		dev_err(dev->class_dev,
			"cb_pcidas64: does not support pci %s\n",
			pci_name(pcidev));
		return -EINVAL;
	}
	thisboard = comedi_board(dev);
	if (context < ARRAY_SIZE(pcidas64_boards))
		thisboard = &pcidas64_boards[context];
	if (!thisboard)
		return -ENODEV;
	dev->board_ptr = thisboard;

	devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
	if (!devpriv)
@@ -4223,25 +4215,27 @@ static int cb_pcidas64_pci_probe(struct pci_dev *dev,
}

static DEFINE_PCI_DEVICE_TABLE(cb_pcidas64_pci_table) = {
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001d) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001e) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0035) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0036) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0037) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0052) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x005d) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x005e) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x005f) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0061) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0062) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0063) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0064) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0066) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0067) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0068) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x006f) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0078) },
	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0079) },
	{ PCI_VDEVICE(CB, 0x001d), BOARD_PCIDAS6402_16 },
	{ PCI_VDEVICE(CB, 0x001e), BOARD_PCIDAS6402_12 },
	{ PCI_VDEVICE(CB, 0x0035), BOARD_PCIDAS64_M1_16 },
	{ PCI_VDEVICE(CB, 0x0036), BOARD_PCIDAS64_M2_16 },
	{ PCI_VDEVICE(CB, 0x0037), BOARD_PCIDAS64_M3_16 },
	{ PCI_VDEVICE(CB, 0x0052), BOARD_PCIDAS4020_12 },
	{ PCI_VDEVICE(CB, 0x005d), BOARD_PCIDAS6023 },
	{ PCI_VDEVICE(CB, 0x005e), BOARD_PCIDAS6025 },
	{ PCI_VDEVICE(CB, 0x005f), BOARD_PCIDAS6030 },
	{ PCI_VDEVICE(CB, 0x0060), BOARD_PCIDAS6031 },
	{ PCI_VDEVICE(CB, 0x0061), BOARD_PCIDAS6032 },
	{ PCI_VDEVICE(CB, 0x0062), BOARD_PCIDAS6033 },
	{ PCI_VDEVICE(CB, 0x0063), BOARD_PCIDAS6034 },
	{ PCI_VDEVICE(CB, 0x0064), BOARD_PCIDAS6035 },
	{ PCI_VDEVICE(CB, 0x0065), BOARD_PCIDAS6040 },
	{ PCI_VDEVICE(CB, 0x0066), BOARD_PCIDAS6052 },
	{ PCI_VDEVICE(CB, 0x0067), BOARD_PCIDAS6070 },
	{ PCI_VDEVICE(CB, 0x0068), BOARD_PCIDAS6071 },
	{ PCI_VDEVICE(CB, 0x006f), BOARD_PCIDAS6036 },
	{ PCI_VDEVICE(CB, 0x0078), BOARD_PCIDAS6013 },
	{ PCI_VDEVICE(CB, 0x0079), BOARD_PCIDAS6014 },
	{ 0 }
};
MODULE_DEVICE_TABLE(pci, cb_pcidas64_pci_table);