mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
pinctrl: sophgo: allocate power_cfg with priv
Use a flexible array member to combine allocations and simplify code slightly. Signed-off-by: Rosen Penev <rosenp@gmail.com> [linusw@kernel.org: add a counter and __counted_by() annotation] Signed-off-by: Linus Walleij <linusw@kernel.org>
This commit is contained in:
parent
13fffbc21e
commit
041e5ea203
|
|
@ -27,8 +27,9 @@
|
|||
#include "pinctrl-cv18xx.h"
|
||||
|
||||
struct cv1800_priv {
|
||||
u32 *power_cfg;
|
||||
void __iomem *regs[2];
|
||||
void __iomem *regs[2];
|
||||
unsigned int num_power_cfg;
|
||||
u32 power_cfg[] __counted_by(num_power_cfg);
|
||||
};
|
||||
|
||||
static unsigned int cv1800_dt_get_pin_mux(u32 value)
|
||||
|
|
@ -417,14 +418,11 @@ static int cv1800_pinctrl_init(struct platform_device *pdev,
|
|||
const struct sophgo_pinctrl_data *pctrl_data = pctrl->data;
|
||||
struct cv1800_priv *priv;
|
||||
|
||||
priv = devm_kzalloc(&pdev->dev, sizeof(struct cv1800_priv), GFP_KERNEL);
|
||||
priv = devm_kzalloc(&pdev->dev, struct_size(priv, power_cfg, pctrl_data->npds),
|
||||
GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
priv->power_cfg = devm_kcalloc(&pdev->dev, pctrl_data->npds,
|
||||
sizeof(u32), GFP_KERNEL);
|
||||
if (!priv->power_cfg)
|
||||
return -ENOMEM;
|
||||
priv->num_power_cfg = pctrl_data->npds;
|
||||
|
||||
priv->regs[0] = devm_platform_ioremap_resource_byname(pdev, "sys");
|
||||
if (IS_ERR(priv->regs[0]))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user