amdgpu/pp: use array_size to size the pwrvirus tables.
authorDave Airlie <airlied@redhat.com>
Fri, 29 Sep 2017 01:12:30 +0000 (11:12 +1000)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 29 Sep 2017 16:24:37 +0000 (12:24 -0400)
This avoids fragile hardcoding of array size.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/inc/fiji_pwrvirus.h
drivers/gpu/drm/amd/powerplay/inc/polaris10_pwrvirus.h
drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c

index 243de29..e202e56 100644 (file)
@@ -35,8 +35,7 @@ struct PWR_Command_Table
 };
 typedef struct PWR_Command_Table PWR_Command_Table;
 
-#define PWR_VIRUS_TABLE_SIZE  10243
-static const PWR_Command_Table PwrVirusTable[PWR_VIRUS_TABLE_SIZE] =
+static const PWR_Command_Table PwrVirusTable[] =
 {
     { 0x100100b6, mmPCIE_INDEX                               },
     { 0x00000000, mmPCIE_DATA                                },
index 7603986..8edd3e7 100644 (file)
@@ -36,10 +36,7 @@ struct PWR_Command_Table {
 
 typedef struct PWR_Command_Table PWR_Command_Table;
 
-
-#define PWR_VIRUS_TABLE_SIZE  10031
-
-static const PWR_Command_Table pwr_virus_table[PWR_VIRUS_TABLE_SIZE] = {
+static const PWR_Command_Table pwr_virus_table[] = {
        { 0x00000000, mmRLC_CNTL                                 },
        { 0x00000002, mmRLC_SRM_CNTL                             },
        { 0x15000000, mmCP_ME_CNTL                               },
index 3820fe8..289006b 100644 (file)
@@ -167,7 +167,7 @@ static int fiji_setup_pwr_virus(struct pp_hwmgr *hwmgr)
 
        const PWR_Command_Table *pvirus = PwrVirusTable;
 
-       for (i = 0; i < PWR_VIRUS_TABLE_SIZE; i++) {
+       for (i = 0; i < ARRAY_SIZE(PwrVirusTable); i++) {
                reg  = pvirus->reg;
                data = pvirus->data;
                if (reg != 0xffffffff)
index b73b2b4..f039320 100644 (file)
@@ -68,7 +68,7 @@ static int polaris10_setup_pwr_virus(struct pp_hwmgr *hwmgr)
 
        const PWR_Command_Table *pvirus = pwr_virus_table;
 
-       for (i = 0; i < PWR_VIRUS_TABLE_SIZE; i++) {
+       for (i = 0; i < ARRAY_SIZE(pwr_virus_table); i++) {
                reg  = pvirus->reg;
                data = pvirus->data;
                if (reg != 0xffffffff) {