summaryrefslogtreecommitdiffstats
path: root/arch/x86/platform
diff options
context:
space:
mode:
authorJérémy Lefaure <jeremy.lefaure@lse.epita.fr>2017-10-01 21:30:50 +0200
committerThomas Gleixner <tglx@linutronix.de>2017-10-19 16:15:47 +0200
commit0cfe5b5fc0277463fa795dea312a3a2fd5e8bac2 (patch)
tree8a572441fff7dbd736c7c9029fbe5b40932d5572 /arch/x86/platform
parentLinux 4.14-rc5 (diff)
downloadlinux-0cfe5b5fc0277463fa795dea312a3a2fd5e8bac2.tar.xz
linux-0cfe5b5fc0277463fa795dea312a3a2fd5e8bac2.zip
x86: Use ARRAY_SIZE
Using the ARRAY_SIZE macro improves the readability of the code. 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> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: linux-video@atrey.karlin.mff.cuni.cz Cc: Martin Mares <mj@ucw.cz> Cc: Andy Lutomirski <luto@amacapital.net> Link: https://lkml.kernel.org/r/20171001193101.8898-13-jeremy.lefaure@lse.epita.fr
Diffstat (limited to 'arch/x86/platform')
-rw-r--r--arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c b/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
index 74283875c7e8..e639e3116acf 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_gpio_keys.c
@@ -62,10 +62,9 @@ static struct platform_device pb_device = {
static int __init pb_keys_init(void)
{
struct gpio_keys_button *gb = gpio_button;
- int i, num, good = 0;
+ int i, good = 0;
- num = sizeof(gpio_button) / sizeof(struct gpio_keys_button);
- for (i = 0; i < num; i++) {
+ for (i = 0; i < ARRAY_SIZE(gpio_button); i++) {
gb[i].gpio = get_gpio_by_name(gb[i].desc);
pr_debug("info[%2d]: name = %s, gpio = %d\n", i, gb[i].desc,
gb[i].gpio);