diff options
author | Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> | 2017-10-15 22:30:46 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2017-10-16 05:29:05 -0400 |
commit | c7d234dc671d17c4c9b89fd30102a2fc619ecf7e (patch) | |
tree | 8dc31811d65284c5895f5bdeb1a70d5ec20eb98c | |
parent | bfddd1469740ea27439afa866bff41ef1cd22bb1 (diff) |
drm/gma500: use ARRAY_SIZE
Using the ARRAY_SIZE macro improves the readability of the code. Also,
it is useless to re-invent it.
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))
)
Reviewed-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20171016023047.19145-1-jeremy.lefaure@lse.epita.fr
-rw-r--r-- | drivers/gpu/drm/gma500/psb_intel_sdvo.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/gpu/drm/gma500/psb_intel_sdvo.c b/drivers/gpu/drm/gma500/psb_intel_sdvo.c index e787d376ba67..84507912be84 100644 --- a/drivers/gpu/drm/gma500/psb_intel_sdvo.c +++ b/drivers/gpu/drm/gma500/psb_intel_sdvo.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include "psb_drv.h" | 37 | #include "psb_drv.h" |
38 | #include "psb_intel_sdvo_regs.h" | 38 | #include "psb_intel_sdvo_regs.h" |
39 | #include "psb_intel_reg.h" | 39 | #include "psb_intel_reg.h" |
40 | #include <linux/kernel.h> | ||
40 | 41 | ||
41 | #define SDVO_TMDS_MASK (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1) | 42 | #define SDVO_TMDS_MASK (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1) |
42 | #define SDVO_RGB_MASK (SDVO_OUTPUT_RGB0 | SDVO_OUTPUT_RGB1) | 43 | #define SDVO_RGB_MASK (SDVO_OUTPUT_RGB0 | SDVO_OUTPUT_RGB1) |
@@ -62,8 +63,6 @@ static const char *tv_format_names[] = { | |||
62 | "SECAM_60" | 63 | "SECAM_60" |
63 | }; | 64 | }; |
64 | 65 | ||
65 | #define TV_FORMAT_NUM (sizeof(tv_format_names) / sizeof(*tv_format_names)) | ||
66 | |||
67 | struct psb_intel_sdvo { | 66 | struct psb_intel_sdvo { |
68 | struct gma_encoder base; | 67 | struct gma_encoder base; |
69 | 68 | ||
@@ -148,7 +147,7 @@ struct psb_intel_sdvo_connector { | |||
148 | int force_audio; | 147 | int force_audio; |
149 | 148 | ||
150 | /* This contains all current supported TV format */ | 149 | /* This contains all current supported TV format */ |
151 | u8 tv_format_supported[TV_FORMAT_NUM]; | 150 | u8 tv_format_supported[ARRAY_SIZE(tv_format_names)]; |
152 | int format_supported_num; | 151 | int format_supported_num; |
153 | struct drm_property *tv_format; | 152 | struct drm_property *tv_format; |
154 | 153 | ||
@@ -1709,7 +1708,7 @@ psb_intel_sdvo_set_property(struct drm_connector *connector, | |||
1709 | } | 1708 | } |
1710 | 1709 | ||
1711 | if (property == psb_intel_sdvo_connector->tv_format) { | 1710 | if (property == psb_intel_sdvo_connector->tv_format) { |
1712 | if (val >= TV_FORMAT_NUM) | 1711 | if (val >= ARRAY_SIZE(tv_format_names)) |
1713 | return -EINVAL; | 1712 | return -EINVAL; |
1714 | 1713 | ||
1715 | if (psb_intel_sdvo->tv_format_index == | 1714 | if (psb_intel_sdvo->tv_format_index == |
@@ -2269,7 +2268,7 @@ static bool psb_intel_sdvo_tv_create_property(struct psb_intel_sdvo *psb_intel_s | |||
2269 | return false; | 2268 | return false; |
2270 | 2269 | ||
2271 | psb_intel_sdvo_connector->format_supported_num = 0; | 2270 | psb_intel_sdvo_connector->format_supported_num = 0; |
2272 | for (i = 0 ; i < TV_FORMAT_NUM; i++) | 2271 | for (i = 0 ; i < ARRAY_SIZE(tv_format_names); i++) |
2273 | if (format_map & (1 << i)) | 2272 | if (format_map & (1 << i)) |
2274 | psb_intel_sdvo_connector->tv_format_supported[psb_intel_sdvo_connector->format_supported_num++] = i; | 2273 | psb_intel_sdvo_connector->tv_format_supported[psb_intel_sdvo_connector->format_supported_num++] = i; |
2275 | 2274 | ||