[PATCH v2 5/8] staging: comedi: amplc_dio200.h: rename 'has_enhancements' in boardinfo

H Hartley Sweeten hsweeten at visionengravers.com
Tue Aug 12 18:17:20 UTC 2014


This member of the boardinfor is only set for the PCIE boards. For
aeshetics, rename it to 'is_pcie'.

For clarity, use this flag in the (*auto_attach) to determine if the
dio200_pcie_board_setup() function needs to be called instead of using
the switch (context_model).

Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Reviewed-by: Ian Abbott <abbotti at mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 drivers/staging/comedi/drivers/amplc_dio200.h      |  2 +-
 .../staging/comedi/drivers/amplc_dio200_common.c   |  4 ++--
 drivers/staging/comedi/drivers/amplc_dio200_pci.c  | 28 ++++++++++------------
 3 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/comedi/drivers/amplc_dio200.h b/drivers/staging/comedi/drivers/amplc_dio200.h
index 60b7ae1..306a9d6 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200.h
+++ b/drivers/staging/comedi/drivers/amplc_dio200.h
@@ -40,7 +40,7 @@ struct dio200_board {
 	unsigned char sdinfo[DIO200_MAX_SUBDEVS];	/* depends on sdtype */
 	bool has_int_sce:1;		/* has interrupt enable/status reg */
 	bool has_clk_gat_sce:1;		/* has clock/gate selection registers */
-	bool has_enhancements:1;	/* has enhanced features */
+	bool is_pcie:1;			/* has enhanced features */
 };
 
 int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq,
diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c
index 275795d..2b33df7 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200_common.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c
@@ -638,7 +638,7 @@ static int dio200_subdev_8254_set_gate_src(struct comedi_device *dev,
 		return -1;
 	if (counter_number > 2)
 		return -1;
-	if (gate_src > (board->has_enhancements ? 31 : 7))
+	if (gate_src > (board->is_pcie ? 31 : 7))
 		return -1;
 
 	subpriv->gate_src[counter_number] = gate_src;
@@ -676,7 +676,7 @@ static int dio200_subdev_8254_set_clock_src(struct comedi_device *dev,
 		return -1;
 	if (counter_number > 2)
 		return -1;
-	if (clock_src > (board->has_enhancements ? 31 : 7))
+	if (clock_src > (board->is_pcie ? 31 : 7))
 		return -1;
 
 	subpriv->clock_src[counter_number] = clock_src;
diff --git a/drivers/staging/comedi/drivers/amplc_dio200_pci.c b/drivers/staging/comedi/drivers/amplc_dio200_pci.c
index e3d6a73..4030c70 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200_pci.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200_pci.c
@@ -276,7 +276,7 @@ static const struct dio200_board dio200_pci_boards[] = {
 		},
 		.has_int_sce	= true,
 		.has_clk_gat_sce = true,
-		.has_enhancements = true,
+		.is_pcie	= true,
 	},
 	[pcie236_model] = {
 		.name		= "pcie236",
@@ -292,7 +292,7 @@ static const struct dio200_board dio200_pci_boards[] = {
 		},
 		.has_int_sce	= true,
 		.has_clk_gat_sce = true,
-		.has_enhancements = true,
+		.is_pcie	= true,
 	},
 	[pcie296_model] = {
 		.name		= "pcie296",
@@ -308,7 +308,7 @@ static const struct dio200_board dio200_pci_boards[] = {
 		},
 		.has_int_sce	= true,
 		.has_clk_gat_sce = true,
-		.has_enhancements = true,
+		.is_pcie	= true,
 	},
 };
 
@@ -351,16 +351,16 @@ static int dio200_pci_auto_attach(struct comedi_device *dev,
 				  unsigned long context_model)
 {
 	struct pci_dev *pci_dev = comedi_to_pci_dev(dev);
-	const struct dio200_board *thisboard = NULL;
+	const struct dio200_board *board = NULL;
 	unsigned int bar;
 	int ret;
 
 	if (context_model < ARRAY_SIZE(dio200_pci_boards))
-		thisboard = &dio200_pci_boards[context_model];
-	if (!thisboard)
+		board = &dio200_pci_boards[context_model];
+	if (!board)
 		return -EINVAL;
-	dev->board_ptr = thisboard;
-	dev->board_name = thisboard->name;
+	dev->board_ptr = board;
+	dev->board_name = board->name;
 
 	dev_info(dev->class_dev, "%s: attach pci %s (%s)\n",
 		 dev->driver->driver_name, pci_name(pci_dev), dev->board_name);
@@ -369,7 +369,7 @@ static int dio200_pci_auto_attach(struct comedi_device *dev,
 	if (ret)
 		return ret;
 
-	bar = thisboard->mainbar;
+	bar = board->mainbar;
 	if (pci_resource_flags(pci_dev, bar) & IORESOURCE_MEM) {
 		dev->mmio = pci_ioremap_bar(pci_dev, bar);
 		if (!dev->mmio) {
@@ -380,17 +380,13 @@ static int dio200_pci_auto_attach(struct comedi_device *dev,
 	} else {
 		dev->iobase = pci_resource_start(pci_dev, bar);
 	}
-	switch (context_model) {
-	case pcie215_model:
-	case pcie236_model:
-	case pcie296_model:
+
+	if (board->is_pcie) {
 		ret = dio200_pcie_board_setup(dev);
 		if (ret < 0)
 			return ret;
-		break;
-	default:
-		break;
 	}
+
 	return amplc_dio200_common_attach(dev, pci_dev->irq, IRQF_SHARED);
 }
 
-- 
2.0.3



More information about the devel mailing list