diff options
author | Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> | 2017-10-01 15:30:41 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-08 10:11:00 -0500 |
commit | e40d14a89760632238f67c1f96c852652a137f2d (patch) | |
tree | 3c9a1c7729242a9725254a1ffe3e6a5de40da63d /drivers/media/usb/dvb-usb/friio-fe.c | |
parent | 37d5efb01910752d8d3846a2c4db0528c1dfa137 (diff) | |
download | talos-obmc-linux-e40d14a89760632238f67c1f96c852652a137f2d.tar.gz talos-obmc-linux-e40d14a89760632238f67c1f96c852652a137f2d.zip |
media: use ARRAY_SIZE
Using the ARRAY_SIZE macro improves the readability of the code. Also,
it is not always useful to use a variable to store this constant
calculated at compile time.
Found with Coccinelle with the following semantic patch:
@r depends on (org || report)@
type T;
T[] E;
position p;
@@
(
(sizeof(E)@p /sizeof(*E))
|
(sizeof(E)@p /sizeof(E[...]))
|
(sizeof(E)@p /sizeof(T))
)
Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/usb/dvb-usb/friio-fe.c')
-rw-r--r-- | drivers/media/usb/dvb-usb/friio-fe.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/media/usb/dvb-usb/friio-fe.c b/drivers/media/usb/dvb-usb/friio-fe.c index b6046e0e07f6..b2830c157548 100644 --- a/drivers/media/usb/dvb-usb/friio-fe.c +++ b/drivers/media/usb/dvb-usb/friio-fe.c @@ -13,6 +13,7 @@ #include <linux/init.h> #include <linux/string.h> #include <linux/slab.h> +#include <linux/kernel.h> #include "friio.h" @@ -340,8 +341,6 @@ static u8 init_code[][2] = { {0x76, 0x0C}, }; -static const int init_code_len = sizeof(init_code) / sizeof(u8[2]); - static int jdvbt90502_init(struct dvb_frontend *fe) { int i = -1; @@ -355,7 +354,7 @@ static int jdvbt90502_init(struct dvb_frontend *fe) msg.addr = state->config.demod_address; msg.flags = 0; msg.len = 2; - for (i = 0; i < init_code_len; i++) { + for (i = 0; i < ARRAY_SIZE(init_code); i++) { msg.buf = init_code[i]; ret = i2c_transfer(state->i2c, &msg, 1); if (ret != 1) |