Commit e563637b authored by Janani Ravichandran's avatar Janani Ravichandran Committed by Greg Kroah-Hartman

staging: comedi: Use ARRAY_SIZE for sizes of arrays

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/9cbab452a3a2e18439e8386d6c4a68ee42c3ee2bSigned-off-by: default avatarJanani Ravichandran <janani.rvchndrn@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 222c402a
...@@ -1166,8 +1166,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev, ...@@ -1166,8 +1166,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
comedi_buf_write_samples(s, &data, 1); comedi_buf_write_samples(s, &data, 1);
} }
} else { } else {
if (n > sizeof(devpriv->ai_fifo_buffer) / if (n > ARRAY_SIZE(devpriv->ai_fifo_buffer)) {
sizeof(devpriv->ai_fifo_buffer[0])) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
"bug! ai_fifo_buffer too small\n"); "bug! ai_fifo_buffer too small\n");
async->events |= COMEDI_CB_ERROR; async->events |= COMEDI_CB_ERROR;
...@@ -1242,9 +1241,7 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev) ...@@ -1242,9 +1241,7 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
NISTC_AI_STATUS1_FIFO_E; NISTC_AI_STATUS1_FIFO_E;
while (fifo_empty == 0) { while (fifo_empty == 0) {
for (i = 0; for (i = 0;
i < i < ARRAY_SIZE(devpriv->ai_fifo_buffer); i++) {
sizeof(devpriv->ai_fifo_buffer) /
sizeof(devpriv->ai_fifo_buffer[0]); i++) {
fifo_empty = ni_stc_readw(dev, fifo_empty = ni_stc_readw(dev,
NISTC_AI_STATUS1_REG) & NISTC_AI_STATUS1_REG) &
NISTC_AI_STATUS1_FIFO_E; NISTC_AI_STATUS1_FIFO_E;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment