ATOM_Tonga_MCLK_Dependency_Table const *mclk_dep_table
)
{
- uint32_t table_size, i;
+ uint32_t i;
phm_ppt_v1_clock_voltage_dependency_table *mclk_table;
phm_ppt_v1_clock_voltage_dependency_record *mclk_table_record;
ATOM_Tonga_MCLK_Dependency_Record *mclk_dep_record;
PP_ASSERT_WITH_CODE((0 != mclk_dep_table->ucNumEntries),
"Invalid PowerPlay Table!", return -1);
- table_size = sizeof(uint32_t) + sizeof(phm_ppt_v1_clock_voltage_dependency_record)
- * mclk_dep_table->ucNumEntries;
-
- mclk_table = kzalloc(table_size, GFP_KERNEL);
-
- if (NULL == mclk_table)
+ mclk_table = kzalloc(struct_size(mclk_table, entries, mclk_dep_table->ucNumEntries),
+ GFP_KERNEL);
+ if (!mclk_table)
return -ENOMEM;
mclk_table->count = (uint32_t)mclk_dep_table->ucNumEntries;
PPTable_Generic_SubTable_Header const *sclk_dep_table
)
{
- uint32_t table_size, i;
+ uint32_t i;
phm_ppt_v1_clock_voltage_dependency_table *sclk_table;
phm_ppt_v1_clock_voltage_dependency_record *sclk_table_record;
PP_ASSERT_WITH_CODE((0 != tonga_table->ucNumEntries),
"Invalid PowerPlay Table!", return -1);
- table_size = sizeof(uint32_t) + sizeof(phm_ppt_v1_clock_voltage_dependency_record)
- * tonga_table->ucNumEntries;
-
- sclk_table = kzalloc(table_size, GFP_KERNEL);
-
- if (NULL == sclk_table)
+ sclk_table = kzalloc(struct_size(sclk_table, entries, tonga_table->ucNumEntries),
+ GFP_KERNEL);
+ if (!sclk_table)
return -ENOMEM;
sclk_table->count = (uint32_t)tonga_table->ucNumEntries;
PP_ASSERT_WITH_CODE((0 != polaris_table->ucNumEntries),
"Invalid PowerPlay Table!", return -1);
- table_size = sizeof(uint32_t) + sizeof(phm_ppt_v1_clock_voltage_dependency_record)
- * polaris_table->ucNumEntries;
-
- sclk_table = kzalloc(table_size, GFP_KERNEL);
-
- if (NULL == sclk_table)
+ sclk_table = kzalloc(struct_size(sclk_table, entries, polaris_table->ucNumEntries),
+ GFP_KERNEL);
+ if (!sclk_table)
return -ENOMEM;
sclk_table->count = (uint32_t)polaris_table->ucNumEntries;
phm_ppt_v1_clock_voltage_dependency_table **pp_vega10_clk_dep_table,
const ATOM_Vega10_SOCCLK_Dependency_Table *clk_dep_table)
{
- uint32_t table_size, i;
+ uint32_t i;
phm_ppt_v1_clock_voltage_dependency_table *clk_table;
PP_ASSERT_WITH_CODE(clk_dep_table->ucNumEntries,
"Invalid PowerPlay Table!", return -1);
- table_size = sizeof(uint32_t) +
- sizeof(phm_ppt_v1_clock_voltage_dependency_record) *
- clk_dep_table->ucNumEntries;
-
- clk_table = kzalloc(table_size, GFP_KERNEL);
-
+ clk_table = kzalloc(struct_size(clk_table, entries, clk_dep_table->ucNumEntries),
+ GFP_KERNEL);
if (!clk_table)
return -ENOMEM;
phm_ppt_v1_clock_voltage_dependency_table **pp_vega10_mclk_dep_table,
const ATOM_Vega10_MCLK_Dependency_Table *mclk_dep_table)
{
- uint32_t table_size, i;
+ uint32_t i;
phm_ppt_v1_clock_voltage_dependency_table *mclk_table;
PP_ASSERT_WITH_CODE(mclk_dep_table->ucNumEntries,
"Invalid PowerPlay Table!", return -1);
- table_size = sizeof(uint32_t) +
- sizeof(phm_ppt_v1_clock_voltage_dependency_record) *
- mclk_dep_table->ucNumEntries;
-
- mclk_table = kzalloc(table_size, GFP_KERNEL);
-
+ mclk_table = kzalloc(struct_size(mclk_table, entries, mclk_dep_table->ucNumEntries),
+ GFP_KERNEL);
if (!mclk_table)
return -ENOMEM;
**pp_vega10_clk_dep_table,
const ATOM_Vega10_GFXCLK_Dependency_Table *clk_dep_table)
{
- uint32_t table_size, i;
+ uint32_t i;
struct phm_ppt_v1_clock_voltage_dependency_table
*clk_table;
ATOM_Vega10_GFXCLK_Dependency_Record_V2 *patom_record_v2;
PP_ASSERT_WITH_CODE((clk_dep_table->ucNumEntries != 0),
"Invalid PowerPlay Table!", return -1);
- table_size = sizeof(uint32_t) +
- sizeof(phm_ppt_v1_clock_voltage_dependency_record) *
- clk_dep_table->ucNumEntries;
-
- clk_table = kzalloc(table_size, GFP_KERNEL);
-
+ clk_table = kzalloc(struct_size(clk_table, entries, clk_dep_table->ucNumEntries),
+ GFP_KERNEL);
if (!clk_table)
return -ENOMEM;
**pp_vega10_clk_dep_table,
const ATOM_Vega10_PIXCLK_Dependency_Table *clk_dep_table)
{
- uint32_t table_size, i;
+ uint32_t i;
struct phm_ppt_v1_clock_voltage_dependency_table
*clk_table;
PP_ASSERT_WITH_CODE((clk_dep_table->ucNumEntries != 0),
"Invalid PowerPlay Table!", return -1);
- table_size = sizeof(uint32_t) +
- sizeof(phm_ppt_v1_clock_voltage_dependency_record) *
- clk_dep_table->ucNumEntries;
-
- clk_table = kzalloc(table_size, GFP_KERNEL);
-
+ clk_table = kzalloc(struct_size(clk_table, entries, clk_dep_table->ucNumEntries),
+ GFP_KERNEL);
if (!clk_table)
return -ENOMEM;
**pp_vega10_clk_dep_table,
const ATOM_Vega10_DCEFCLK_Dependency_Table *clk_dep_table)
{
- uint32_t table_size, i;
+ uint32_t i;
uint8_t num_entries;
struct phm_ppt_v1_clock_voltage_dependency_table
*clk_table;
num_entries = clk_dep_table->ucNumEntries;
- table_size = sizeof(uint32_t) +
- sizeof(phm_ppt_v1_clock_voltage_dependency_record) *
- num_entries;
-
- clk_table = kzalloc(table_size, GFP_KERNEL);
-
+ clk_table = kzalloc(struct_size(clk_table, entries, num_entries),
+ GFP_KERNEL);
if (!clk_table)
return -ENOMEM;