Staging: et131x: Correct WRAP bit handling
[safe/jmp/linux-2.6] / drivers / staging / comedi / drivers / comedi_bond.c
index 7d842a2..cf39a24 100644 (file)
@@ -59,7 +59,7 @@ Configuration Options:
  * Devices: a full list of the boards that attempt to be supported by
  *   the driver.  Format is "(manufacturer) board name [comedi name]",
  *   where comedi_name is the name that is used to configure the board.
- *   See the comment near board_name: in the comedi_driver structure
+ *   See the comment near board_name: in the struct comedi_driver structure
  *   below.  If (manufacturer) or [comedi name] is missing, the previous
  *   value is used.
  * Author: you
@@ -132,8 +132,8 @@ struct BondingBoard {
 
 static const struct BondingBoard bondingBoards[] = {
        {
-               .name = MODULE_NAME,
-       },
+        .name = MODULE_NAME,
+        },
 };
 
 /*
@@ -171,25 +171,26 @@ struct Private {
 #define devpriv ((struct Private *)dev->private)
 
 /*
- * The comedi_driver structure tells the Comedi core module
+ * The struct comedi_driver structure tells the Comedi core module
  * which functions to call to configure/deconfigure (attach/detach)
  * the board, and also about the kernel module that contains
  * the device code.
  */
-static int bonding_attach(struct comedi_device *dev, comedi_devconfig *it);
+static int bonding_attach(struct comedi_device *dev,
+                         struct comedi_devconfig *it);
 static int bonding_detach(struct comedi_device *dev);
 /** Build Private array of all devices.. */
-static int doDevConfig(struct comedi_device *dev, comedi_devconfig *it);
+static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it);
 static void doDevUnconfig(struct comedi_device *dev);
 /* Ugly implementation of realloc that always copies memory around -- I'm lazy,
  * what can I say?  I like to do wasteful memcopies.. :) */
 static void *Realloc(const void *ptr, size_t len, size_t old_len);
 
-static comedi_driver driver_bonding = {
-      .driver_name =   MODULE_NAME,
-      .module =                THIS_MODULE,
-      .attach =                bonding_attach,
-      .detach =                bonding_detach,
+static struct comedi_driver driver_bonding = {
+       .driver_name = MODULE_NAME,
+       .module = THIS_MODULE,
+       .attach = bonding_attach,
+       .detach = bonding_detach,
        /* It is not necessary to implement the following members if you are
         * writing a driver for a ISA PnP or PCI card */
        /* Most drivers will support multiple types of boards by
@@ -208,15 +209,18 @@ static comedi_driver driver_bonding = {
         * the type of board in software.  ISA PnP, PCI, and PCMCIA
         * devices are such boards.
         */
-      .board_name =    &bondingBoards[0].name,
-      .offset =                sizeof(struct BondingBoard),
-      .num_names =     sizeof(bondingBoards) / sizeof(struct BondingBoard),
+       .board_name = &bondingBoards[0].name,
+       .offset = sizeof(struct BondingBoard),
+       .num_names = ARRAY_SIZE(bondingBoards),
 };
 
-static int bonding_dio_insn_bits(struct comedi_device *dev, comedi_subdevice *s,
-                                comedi_insn *insn, unsigned int *data);
-static int bonding_dio_insn_config(struct comedi_device *dev, comedi_subdevice *s,
-                                  comedi_insn *insn, unsigned int *data);
+static int bonding_dio_insn_bits(struct comedi_device *dev,
+                                struct comedi_subdevice *s,
+                                struct comedi_insn *insn, unsigned int *data);
+static int bonding_dio_insn_config(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_insn *insn,
+                                  unsigned int *data);
 
 /*
  * Attach is called by the Comedi core to configure the driver
@@ -224,9 +228,10 @@ static int bonding_dio_insn_config(struct comedi_device *dev, comedi_subdevice *
  * in the driver structure, dev->board_ptr contains that
  * address.
  */
-static int bonding_attach(struct comedi_device *dev, comedi_devconfig *it)
+static int bonding_attach(struct comedi_device *dev,
+                         struct comedi_devconfig *it)
 {
-       comedi_subdevice *s;
+       struct comedi_subdevice *s;
 
        LOG_MSG("comedi%d\n", dev->minor);
 
@@ -293,8 +298,9 @@ static int bonding_detach(struct comedi_device *dev)
  * useful to applications if you implement the insn_bits interface.
  * This allows packed reading/writing of the DIO channels.  The
  * comedi core can convert between insn_bits and insn_read/write */
-static int bonding_dio_insn_bits(struct comedi_device *dev, comedi_subdevice *s,
-                                comedi_insn *insn, unsigned int *data)
+static int bonding_dio_insn_bits(struct comedi_device *dev,
+                                struct comedi_subdevice *s,
+                                struct comedi_insn *insn, unsigned int *data)
 {
 #define LSAMPL_BITS (sizeof(unsigned int)*8)
        unsigned nchans = LSAMPL_BITS, num_done = 0, i;
@@ -317,14 +323,14 @@ static int bonding_dio_insn_bits(struct comedi_device *dev, comedi_subdevice *s,
 
                /* Argh, we have >= LSAMPL_BITS chans.. take all bits */
                if (bdev->nchans >= LSAMPL_BITS)
-                       subdevMask = (unsigned int) (-1);
+                       subdevMask = (unsigned int)(-1);
 
                writeMask = (data[0] >> num_done) & subdevMask;
                dataBits = (data[1] >> num_done) & subdevMask;
 
                /* Read/Write the new digital lines */
                if (comedi_dio_bitfield(bdev->dev, bdev->subdev, writeMask,
-                               &dataBits) != 2)
+                                       &dataBits) != 2)
                        return -EINVAL;
 
                /* Make room for the new bits in data[1], the return value */
@@ -340,8 +346,9 @@ static int bonding_dio_insn_bits(struct comedi_device *dev, comedi_subdevice *s,
        return insn->n;
 }
 
-static int bonding_dio_insn_config(struct comedi_device *dev, comedi_subdevice *s,
-                                  comedi_insn *insn, unsigned int *data)
+static int bonding_dio_insn_config(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_insn *insn, unsigned int *data)
 {
        int chan = CR_CHAN(insn->chanspec), ret, io_bits = s->io_bits;
        unsigned int io;
@@ -366,7 +373,7 @@ static int bonding_dio_insn_config(struct comedi_device *dev, comedi_subdevice *
                break;
        case INSN_CONFIG_DIO_QUERY:
                data[1] =
-                       (io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+                   (io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
                return insn->n;
                break;
        default:
@@ -394,7 +401,7 @@ static void *Realloc(const void *oldmem, size_t newlen, size_t oldlen)
        return newmem;
 }
 
-static int doDevConfig(struct comedi_device *dev, comedi_devconfig *it)
+static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it)
 {
        int i;
        void *devs_opened[COMEDI_NUM_BOARD_MINORS];
@@ -435,7 +442,7 @@ static int doDevConfig(struct comedi_device *dev, comedi_devconfig *it)
 
                /* Do DIO, as that's all we support now.. */
                while ((sdev = comedi_find_subdevice_by_type(d, COMEDI_SUBD_DIO,
-                                       sdev + 1)) > -1) {
+                                                            sdev + 1)) > -1) {
                        nchans = comedi_get_n_channels(d, sdev);
                        if (nchans <= 0) {
                                ERROR("comedi_get_n_channels() returned %d "
@@ -465,8 +472,8 @@ static int doDevConfig(struct comedi_device *dev, comedi_devconfig *it)
                        /* ergh.. ugly.. we need to realloc :(  */
                        tmp = devpriv->ndevs * sizeof(bdev);
                        devpriv->devs =
-                               Realloc(devpriv->devs,
-                               ++devpriv->ndevs * sizeof(bdev), tmp);
+                           Realloc(devpriv->devs,
+                                   ++devpriv->ndevs * sizeof(bdev), tmp);
                        if (!devpriv->devs) {
                                ERROR("Could not allocate memory. "
                                      "Out of memory?");
@@ -478,10 +485,9 @@ static int doDevConfig(struct comedi_device *dev, comedi_devconfig *it)
        /** Append dev:subdev to devpriv->name */
                                char buf[20];
                                int left =
-                                       MAX_BOARD_NAME - strlen(devpriv->name) -
-                                       1;
+                                   MAX_BOARD_NAME - strlen(devpriv->name) - 1;
                                snprintf(buf, sizeof(buf), "%d:%d ", dev->minor,
-                                       bdev->subdev);
+                                        bdev->subdev);
                                buf[sizeof(buf) - 1] = 0;
                                strncat(devpriv->name, buf, left);
                        }