Use a local pointer variable to access the comedi device private data
instead of calling the static inline function `priv()` all the time.
Get rid of the function.

Signed-off-by: Ian Abbott <[email protected]>
Cc: Frank Mori Hess <[email protected]>
---
 drivers/staging/comedi/drivers/adv_pci1724.c | 45 ++++++++++++++--------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c 
b/drivers/staging/comedi/drivers/adv_pci1724.c
index ea72936..55d2de3 100644
--- a/drivers/staging/comedi/drivers/adv_pci1724.c
+++ b/drivers/staging/comedi/drivers/adv_pci1724.c
@@ -143,14 +143,6 @@ struct adv_pci1724_private {
        int gain_value[NUM_AO_CHANNELS];
 };
 
-/* inline function that makes it easier to
- * access the private structure.
- */
-static inline struct adv_pci1724_private *priv(struct comedi_device *dev)
-{
-       return dev->private;
-}
-
 static int adv_pci1724_auto_attach(struct comedi_device *dev,
                                   unsigned long context_unused);
 static void adv_pci1724_detach(struct comedi_device *dev);
@@ -239,19 +231,22 @@ static int adv_pci1724_auto_attach(struct comedi_device 
*dev,
                                   unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+       struct adv_pci1724_private *devpriv;
        int i;
        int retval;
        unsigned int board_id;
 
-       dev->private = kzalloc(sizeof(struct adv_pci1724_private), GFP_KERNEL);
-       if (!dev->private)
+       devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
+       if (!devpriv)
                return -ENOMEM;
+       dev->private = devpriv;
+
        /* init software copies of output values to indicate we don't know
         * what the output value is since it has never been written. */
        for (i = 0; i < NUM_AO_CHANNELS; ++i) {
-               priv(dev)->ao_value[i] = -1;
-               priv(dev)->offset_value[i] = -1;
-               priv(dev)->gain_value[i] = -1;
+               devpriv->ao_value[i] = -1;
+               devpriv->offset_value[i] = -1;
+               devpriv->gain_value[i] = -1;
        }
 
        dev->board_name = dev->driver->driver_name;
@@ -319,6 +314,7 @@ static int set_dac(struct comedi_device *dev, unsigned 
mode, unsigned channel,
 static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
                    struct comedi_insn *insn, unsigned int *data)
 {
+       struct adv_pci1724_private *devpriv = dev->private;
        int channel = CR_CHAN(insn->chanspec);
        int retval;
        int i;
@@ -330,7 +326,7 @@ static int ao_winsn(struct comedi_device *dev, struct 
comedi_subdevice *s,
                retval = set_dac(dev, DAC_NORMAL_MODE, channel, data[i]);
                if (retval < 0)
                        return retval;
-               priv(dev)->ao_value[channel] = data[i];
+               devpriv->ao_value[channel] = data[i];
        }
        return 1;
 }
@@ -339,14 +335,15 @@ static int ao_readback_insn(struct comedi_device *dev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn, unsigned int *data)
 {
+       struct adv_pci1724_private *devpriv = dev->private;
        int channel = CR_CHAN(insn->chanspec);
 
-       if (priv(dev)->ao_value[channel] < 0) {
+       if (devpriv->ao_value[channel] < 0) {
                comedi_error(dev,
                             "Cannot read back channels which have not yet been 
written to.");
                return -EIO;
        }
-       data[0] = priv(dev)->ao_value[channel];
+       data[0] = devpriv->ao_value[channel];
 
        return 1;
 }
@@ -355,6 +352,7 @@ static int offset_write_insn(struct comedi_device *dev,
                             struct comedi_subdevice *s,
                             struct comedi_insn *insn, unsigned int *data)
 {
+       struct adv_pci1724_private *devpriv = dev->private;
        int channel = CR_CHAN(insn->chanspec);
        int retval;
        int i;
@@ -366,7 +364,7 @@ static int offset_write_insn(struct comedi_device *dev,
                retval = set_dac(dev, DAC_OFFSET_MODE, channel, data[i]);
                if (retval < 0)
                        return retval;
-               priv(dev)->offset_value[channel] = data[i];
+               devpriv->offset_value[channel] = data[i];
        }
 
        return 1;
@@ -376,14 +374,15 @@ static int offset_read_insn(struct comedi_device *dev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn, unsigned int *data)
 {
+       struct adv_pci1724_private *devpriv = dev->private;
        unsigned int channel = CR_CHAN(insn->chanspec);
 
-       if (priv(dev)->offset_value[channel] < 0) {
+       if (devpriv->offset_value[channel] < 0) {
                comedi_error(dev,
                             "Cannot read back channels which have not yet been 
written to.");
                return -EIO;
        }
-       data[0] = priv(dev)->offset_value[channel];
+       data[0] = devpriv->offset_value[channel];
 
        return 1;
 }
@@ -392,6 +391,7 @@ static int gain_write_insn(struct comedi_device *dev,
                           struct comedi_subdevice *s,
                           struct comedi_insn *insn, unsigned int *data)
 {
+       struct adv_pci1724_private *devpriv = dev->private;
        int channel = CR_CHAN(insn->chanspec);
        int retval;
        int i;
@@ -403,7 +403,7 @@ static int gain_write_insn(struct comedi_device *dev,
                retval = set_dac(dev, DAC_GAIN_MODE, channel, data[i]);
                if (retval < 0)
                        return retval;
-               priv(dev)->gain_value[channel] = data[i];
+               devpriv->gain_value[channel] = data[i];
        }
 
        return 1;
@@ -413,14 +413,15 @@ static int gain_read_insn(struct comedi_device *dev,
                          struct comedi_subdevice *s, struct comedi_insn *insn,
                          unsigned int *data)
 {
+       struct adv_pci1724_private *devpriv = dev->private;
        unsigned int channel = CR_CHAN(insn->chanspec);
 
-       if (priv(dev)->gain_value[channel] < 0) {
+       if (devpriv->gain_value[channel] < 0) {
                comedi_error(dev,
                             "Cannot read back channels which have not yet been 
written to.");
                return -EIO;
        }
-       data[0] = priv(dev)->gain_value[channel];
+       data[0] = devpriv->gain_value[channel];
 
        return 1;
 }
-- 
1.8.1.2

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to