staging: comedi: Use ARRAY_SIZE for sizes of arrays
authorJanani Ravichandran <janani.rvchndrn@gmail.com>
Fri, 12 Feb 2016 00:07:48 +0000 (19:07 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 12 Feb 2016 03:47:27 +0000 (19:47 -0800)
Use ARRAY_SIZE to calculate the size of an array to make code concise.
The semantic patch used can be found here:
https://github.com/coccinelle/coccinellery/commit/9cbab452a3a2e18439e8386d6c4a68ee42c3ee2b

Signed-off-by: Janani Ravichandran <janani.rvchndrn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/ni_mio_c_common.c [new file with mode: 0644]
drivers/staging/comedi/drivers/ni_mio_common.c

diff --git a/drivers/staging/comedi/drivers/ni_mio_c_common.c b/drivers/staging/comedi/drivers/ni_mio_c_common.c
new file mode 100644 (file)
index 0000000..e69de29
index 929389b52572a8aae6f0cf083057364ecacc6f2e..1c2abb3feb4277c15c71916256690025d822e7fb 100644 (file)
@@ -1166,8 +1166,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
                        comedi_buf_write_samples(s, &data, 1);
                }
        } else {
-               if (n > sizeof(devpriv->ai_fifo_buffer) /
-                   sizeof(devpriv->ai_fifo_buffer[0])) {
+               if (n > ARRAY_SIZE(devpriv->ai_fifo_buffer)) {
                        dev_err(dev->class_dev,
                                "bug! ai_fifo_buffer too small\n");
                        async->events |= COMEDI_CB_ERROR;
@@ -1242,9 +1241,7 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
                             NISTC_AI_STATUS1_FIFO_E;
                while (fifo_empty == 0) {
                        for (i = 0;
-                            i <
-                            sizeof(devpriv->ai_fifo_buffer) /
-                            sizeof(devpriv->ai_fifo_buffer[0]); i++) {
+                            i < ARRAY_SIZE(devpriv->ai_fifo_buffer); i++) {
                                fifo_empty = ni_stc_readw(dev,
                                                          NISTC_AI_STATUS1_REG) &
                                                NISTC_AI_STATUS1_FIFO_E;