pinctrl: tegra: use flexible array member for array
Simplifies allocation slightly by removing a kcalloc call and using struct_size. Signed-off-by: Rosen Penev <rosenp@gmail.com> [linusw@kernel.org: Add in count variable and use __counted_by()] Signed-off-by: Linus Walleij <linusw@kernel.org>
This commit is contained in:
parent
47a9050e67
commit
d453086996
2 changed files with 5 additions and 9 deletions
|
|
@ -832,18 +832,14 @@ int tegra_pinctrl_probe(struct platform_device *pdev,
|
|||
int fn, gn, gfn;
|
||||
unsigned long backup_regs_size = 0;
|
||||
|
||||
pmx = devm_kzalloc(&pdev->dev, sizeof(*pmx), GFP_KERNEL);
|
||||
pmx = devm_kzalloc(&pdev->dev,
|
||||
struct_size(pmx, pingroup_configs, soc_data->ngroups), GFP_KERNEL);
|
||||
if (!pmx)
|
||||
return -ENOMEM;
|
||||
|
||||
pmx->dev = &pdev->dev;
|
||||
pmx->soc = soc_data;
|
||||
|
||||
pmx->pingroup_configs = devm_kcalloc(&pdev->dev,
|
||||
pmx->soc->ngroups, sizeof(*pmx->pingroup_configs),
|
||||
GFP_KERNEL);
|
||||
if (!pmx->pingroup_configs)
|
||||
return -ENOMEM;
|
||||
pmx->num_pingroup_configs = soc_data->ngroups;
|
||||
|
||||
/*
|
||||
* Each mux group will appear in 4 functions' list of groups.
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ struct tegra_pmx {
|
|||
int nbanks;
|
||||
void __iomem **regs;
|
||||
u32 *backup_regs;
|
||||
/* Array of size soc->ngroups */
|
||||
struct tegra_pingroup_config *pingroup_configs;
|
||||
unsigned int num_pingroup_configs;
|
||||
struct tegra_pingroup_config pingroup_configs[] __counted_by(num_pingroup_configs);
|
||||
};
|
||||
|
||||
enum tegra_pinconf_param {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue