Skip to content

Commit 2d23661

Browse files
LiquidityCalexdeucher
authored andcommitted
drm/amd/display: Replace inline NUM_ELEMENTS macro with ARRAY_SIZE
Replaces the use of local NUM_ELEMENTS macro with the ARRAY_SIZE macro defined in <linux/array_size.h>. This aligns with existing coccinelle script array_size.cocci which has been applied to other sources in order to remove inline sizeof(a)/sizeof(a[0]) patterns from other source files. Suggested-by: Robert P. J. Day <rpjday@crashcourse.ca> Signed-off-by: Linus Probert <linus.probert@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent eea8591 commit 2d23661

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*
2424
*/
2525

26+
#include <linux/array_size.h>
27+
2628
#include "dm_services.h"
2729
#include "core_types.h"
2830
#include "timing_generator.h"
@@ -40,7 +42,6 @@
4042
#include "dcn10/dcn10_hubbub.h"
4143
#include "dce/dmub_hw_lock_mgr.h"
4244

43-
#define NUM_ELEMENTS(a) (sizeof(a) / sizeof((a)[0]))
4445
#define MAX_NUM_MCACHE 8
4546

4647
/* used as index in array of black_color_format */
@@ -230,7 +231,7 @@ const uint16_t *find_color_matrix(enum dc_color_space color_space,
230231
int i;
231232
enum dc_color_space_type type;
232233
const uint16_t *val = NULL;
233-
int arr_size = NUM_ELEMENTS(output_csc_matrix);
234+
int arr_size = ARRAY_SIZE(output_csc_matrix);
234235

235236
type = get_color_space_type(color_space);
236237
for (i = 0; i < arr_size; i++)

drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*
2424
*/
2525

26+
#include <linux/array_size.h>
27+
2628
#include "dm_services.h"
2729

2830

@@ -57,8 +59,6 @@
5759
#define CALC_PLL_CLK_SRC_ERR_TOLERANCE 1
5860
#define MAX_PLL_CALC_ERROR 0xFFFFFFFF
5961

60-
#define NUM_ELEMENTS(a) (sizeof(a) / sizeof((a)[0]))
61-
6262
static const struct spread_spectrum_data *get_ss_data_entry(
6363
struct dce110_clk_src *clk_src,
6464
enum signal_type signal,
@@ -1271,7 +1271,7 @@ const struct pixel_rate_range_table_entry *look_up_in_video_optimized_rate_tlb(
12711271
{
12721272
int i;
12731273

1274-
for (i = 0; i < NUM_ELEMENTS(video_optimized_pixel_rates); i++) {
1274+
for (i = 0; i < ARRAY_SIZE(video_optimized_pixel_rates); i++) {
12751275
const struct pixel_rate_range_table_entry *e = &video_optimized_pixel_rates[i];
12761276

12771277
if (e->range_min_khz <= pixel_rate_khz && pixel_rate_khz <= e->range_max_khz) {

0 commit comments

Comments
 (0)