[PATCH 7/9] staging: comedi: das08: Remove thisboard and devpriv macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The 'thisboard' and 'devpriv' macros rely on a local variable having a
specific name and yield pointers derived from that local variable.
Replace the macros with local variables wherever they occur.

Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
---
 drivers/staging/comedi/drivers/das08.c |   33 +++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c
index 996d71a..ae60d39 100644
--- a/drivers/staging/comedi/drivers/das08.c
+++ b/drivers/staging/comedi/drivers/das08.c
@@ -236,9 +236,6 @@ static const int *const das08_gainlists[] = {
 	das08_pgm_gainlist,
 };
 
-#define devpriv ((struct das08_private_struct *)dev->private)
-#define thisboard ((const struct das08_board_struct *)dev->board_ptr)
-
 #define TIMEOUT 100000
 
 static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -248,6 +245,8 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 	int chan;
 	int range;
 	int lsb, msb;
+	const struct das08_board_struct *thisboard = comedi_board(dev);
+	struct das08_private_struct *devpriv = dev->private;
 
 	chan = CR_CHAN(insn->chanspec);
 	range = CR_RANGE(insn->chanspec);
@@ -322,6 +321,7 @@ static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
 			  struct comedi_insn *insn, unsigned int *data)
 {
 	int wbits;
+	struct das08_private_struct *devpriv = dev->private;
 
 	/*  get current settings of digital output lines */
 	wbits = (devpriv->do_mux_bits >> 4) & 0xf;
@@ -359,6 +359,8 @@ static int das08jr_do_wbits(struct comedi_device *dev,
 			    struct comedi_subdevice *s,
 			    struct comedi_insn *insn, unsigned int *data)
 {
+	struct das08_private_struct *devpriv = dev->private;
+
 	/*  null bits we are going to set */
 	devpriv->do_bits &= ~data[0];
 	/*  set new bit values */
@@ -379,6 +381,7 @@ static int das08jr_ao_winsn(struct comedi_device *dev,
 	int n;
 	int lsb, msb;
 	int chan;
+	struct das08_private_struct *devpriv = dev->private;
 
 	lsb = data[0] & 0xff;
 	msb = (data[0] >> 8) & 0xf;
@@ -416,6 +419,7 @@ static int das08ao_ao_winsn(struct comedi_device *dev,
 	int n;
 	int lsb, msb;
 	int chan;
+	struct das08_private_struct *devpriv = dev->private;
 
 	lsb = data[0] & 0xff;
 	msb = (data[0] >> 8) & 0xf;
@@ -530,6 +534,7 @@ static int das08_counter_read(struct comedi_device *dev,
 			      struct comedi_insn *insn, unsigned int *data)
 {
 	int chan = insn->chanspec;
+	struct das08_private_struct *devpriv = dev->private;
 	data[0] = i8254_read_channel(&devpriv->i8254, chan);
 	/* dev_dbg(dev->class_dev, "Read counter channel %d => 0x%08X\n",
 		   chan, data[0]); */
@@ -541,7 +546,7 @@ static int das08_counter_write(struct comedi_device *dev,
 			       struct comedi_insn *insn, unsigned int *data)
 {
 	int chan = insn->chanspec;
-
+	struct das08_private_struct *devpriv = dev->private;
 	/* dev_dbg(dev->class_dev, "Writing counter channel %d with 0x%04X\n",
 	           chan,data[0]); */
 	i8254_write_channel(&devpriv->i8254, chan, data[0]);
@@ -554,6 +559,7 @@ static int das08_counter_config(struct comedi_device *dev,
 				struct comedi_insn *insn, unsigned int *data)
 {
 	int chan = insn->chanspec;
+	struct das08_private_struct *devpriv = dev->private;
 
 	if (insn->n != 2)
 		return -EINVAL;
@@ -830,7 +836,9 @@ EXPORT_SYMBOL_GPL(das08_cs_boards);
 
 int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
 {
+	const struct das08_board_struct *thisboard = comedi_board(dev);
 	struct comedi_subdevice *s;
+	struct das08_private_struct *devpriv = dev->private;
 	int ret;
 
 	switch (thisboard->bustype) {
@@ -973,10 +981,13 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	unsigned long pci_iobase = 0;
 	struct pci_dev *pdev = NULL;
 #endif
+	const struct das08_board_struct *thisboard = comedi_board(dev);
+	struct das08_private_struct *devpriv;
 
 	ret = alloc_private(dev, sizeof(struct das08_private_struct));
 	if (ret < 0)
 		return ret;
+	devpriv = dev->private;
 
 	dev_info(dev->class_dev, "attach\n");
 	switch (thisboard->bustype)
@@ -1042,6 +1053,8 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
 void das08_common_detach(struct comedi_device *dev)
 {
+	const struct das08_board_struct *thisboard = comedi_board(dev);
+
 	if (dev->subdevices)
 		subdev_8255_cleanup(dev, dev->subdevices + 4);
 	switch (thisboard->bustype) {
@@ -1053,12 +1066,14 @@ void das08_common_detach(struct comedi_device *dev)
 		break;
 #endif
 #if IS_ENABLED(CONFIG_COMEDI_DAS08_PCI)
-	case pci:
-		if (devpriv && devpriv->pdev) {
-			if (devpriv->pci_iobase)
-				comedi_pci_disable(devpriv->pdev);
+	case pci: {
+			struct das08_private_struct *devpriv = dev->private;
+			if (devpriv && devpriv->pdev) {
+				if (devpriv->pci_iobase)
+					comedi_pci_disable(devpriv->pdev);
 
-			pci_dev_put(devpriv->pdev);
+				pci_dev_put(devpriv->pdev);
+			}
 		}
 		break;
 #endif
-- 
1.7.8.6

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux