drm/amd/powerplay: fix array_size.cocci warnings
authorkbuild test robot <fengguang.wu@intel.com>
Thu, 11 May 2017 01:30:28 +0000 (09:30 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 24 May 2017 21:41:58 +0000 (17:41 -0400)
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:75:42-43: WARNING: Use ARRAY_SIZE
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:466:22-23: WARNING: Use ARRAY_SIZE
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:468:22-23: WARNING: Use ARRAY_SIZE
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:470:20-21: WARNING: Use ARRAY_SIZE
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:473:22-23: WARNING: Use ARRAY_SIZE
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:475:21-22: WARNING: Use ARRAY_SIZE
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:477:21-22: WARNING: Use ARRAY_SIZE

 Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element

Semantic patch information:
 This makes an effort to find cases where ARRAY_SIZE can be used such as
 where there is a division of sizeof the array by the sizeof its first
 element or by any indexed element or the element type. It replaces the
 division of the two sizeofs by ARRAY_SIZE.

Generated by: scripts/coccinelle/misc/array_size.cocci

CC: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c

index fe7082a34cc7b7a9a38d3cc0333fca913a08ea7b..631ef82b5d7ffce835d013f313167db5e006e694 100644 (file)
@@ -72,7 +72,7 @@ static int rv_init_vq_budget_table(struct pp_hwmgr *hwmgr)
 {
        uint32_t table_size, i;
        struct phm_vq_budgeting_table *ptable;
-       uint32_t num_entries = (sizeof(rv_vqtable) / sizeof(*rv_vqtable));
+       uint32_t num_entries = ARRAY_SIZE(rv_vqtable);
 
        if (hwmgr->dyn_state.vq_budgeting_table != NULL)
                return 0;
@@ -463,18 +463,22 @@ static int rv_populate_clock_table(struct pp_hwmgr *hwmgr)
                                                &rv_data->clock_table.MemClocks[0]);
        } else {
                rv_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_dcefclk,
-                                               sizeof(VddDcfClk)/sizeof(*VddDcfClk), &VddDcfClk[0]);
+                                               ARRAY_SIZE(VddDcfClk),
+                                               &VddDcfClk[0]);
                rv_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_socclk,
-                                               sizeof(VddSocClk)/sizeof(*VddSocClk), &VddSocClk[0]);
+                                               ARRAY_SIZE(VddSocClk),
+                                               &VddSocClk[0]);
                rv_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_fclk,
-                                               sizeof(VddFClk)/sizeof(*VddFClk), &VddFClk[0]);
+                                               ARRAY_SIZE(VddFClk),
+                                               &VddFClk[0]);
        }
        rv_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_dispclk,
-                                       sizeof(VddDispClk)/sizeof(*VddDispClk), &VddDispClk[0]);
+                                       ARRAY_SIZE(VddDispClk),
+                                       &VddDispClk[0]);
        rv_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_dppclk,
-                                       sizeof(VddDppClk)/sizeof(*VddDppClk), &VddDppClk[0]);
+                                       ARRAY_SIZE(VddDppClk), &VddDppClk[0]);
        rv_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_phyclk,
-                                       sizeof(VddPhyClk)/sizeof(*VddPhyClk), &VddPhyClk[0]);
+                                       ARRAY_SIZE(VddPhyClk), &VddPhyClk[0]);
 
        return 0;
 }