From e40d14a89760632238f67c1f96c852652a137f2d Mon Sep 17 00:00:00 2001 From: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> Date: Sun, 1 Oct 2017 15:30:41 -0400 Subject: media: use ARRAY_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- drivers/media/pci/saa7146/hexium_gemini.c | 3 ++- drivers/media/pci/saa7146/hexium_orion.c | 3 ++- drivers/media/pci/saa7146/mxb.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/media/pci') diff --git a/drivers/media/pci/saa7146/hexium_gemini.c b/drivers/media/pci/saa7146/hexium_gemini.c index d31a2d4494d1..39357eddee32 100644 --- a/drivers/media/pci/saa7146/hexium_gemini.c +++ b/drivers/media/pci/saa7146/hexium_gemini.c @@ -27,6 +27,7 @@ #include <media/drv-intf/saa7146_vv.h> #include <linux/module.h> +#include <linux/kernel.h> static int debug; module_param(debug, int, 0); @@ -388,7 +389,7 @@ static struct saa7146_ext_vv vv_data = { .inputs = HEXIUM_INPUTS, .capabilities = 0, .stds = &hexium_standards[0], - .num_stds = sizeof(hexium_standards) / sizeof(struct saa7146_standard), + .num_stds = ARRAY_SIZE(hexium_standards), .std_callback = &std_callback, }; diff --git a/drivers/media/pci/saa7146/hexium_orion.c b/drivers/media/pci/saa7146/hexium_orion.c index 043318aa19e2..461e421080f3 100644 --- a/drivers/media/pci/saa7146/hexium_orion.c +++ b/drivers/media/pci/saa7146/hexium_orion.c @@ -27,6 +27,7 @@ #include <media/drv-intf/saa7146_vv.h> #include <linux/module.h> +#include <linux/kernel.h> static int debug; module_param(debug, int, 0); @@ -460,7 +461,7 @@ static struct saa7146_ext_vv vv_data = { .inputs = HEXIUM_INPUTS, .capabilities = 0, .stds = &hexium_standards[0], - .num_stds = sizeof(hexium_standards) / sizeof(struct saa7146_standard), + .num_stds = ARRAY_SIZE(hexium_standards), .std_callback = &std_callback, }; diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index 930218cc2de1..0144f305ea24 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -30,6 +30,7 @@ #include <media/v4l2-common.h> #include <media/i2c/saa7115.h> #include <linux/module.h> +#include <linux/kernel.h> #include "tea6415c.h" #include "tea6420.h" @@ -837,7 +838,7 @@ static struct saa7146_ext_vv vv_data = { .inputs = MXB_INPUTS, .capabilities = V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_AUDIO, .stds = &standard[0], - .num_stds = sizeof(standard)/sizeof(struct saa7146_standard), + .num_stds = ARRAY_SIZE(standard), .std_callback = &std_callback, }; -- cgit v1.2.3