mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
pinctrl: starfive: jh7110: use struct_size
Instead of an extra kcalloc, Use a flexible array member to combine allocations. Saves a pointer in the struct. Signed-off-by: Rosen Penev <rosenp@gmail.com> Acked-by: Hal Feng <hal.feng@starfivetech.com> Signed-off-by: Linus Walleij <linusw@kernel.org>
This commit is contained in:
parent
b316171846
commit
87182ef0bf
|
|
@ -857,17 +857,15 @@ int jh7110_pinctrl_probe(struct platform_device *pdev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_PM_SLEEP)
|
||||
sfp = devm_kzalloc(dev, struct_size(sfp, saved_regs, info->nsaved_regs),
|
||||
GFP_KERNEL);
|
||||
#else
|
||||
sfp = devm_kzalloc(dev, sizeof(*sfp), GFP_KERNEL);
|
||||
#endif
|
||||
if (!sfp)
|
||||
return -ENOMEM;
|
||||
|
||||
#if IS_ENABLED(CONFIG_PM_SLEEP)
|
||||
sfp->saved_regs = devm_kcalloc(dev, info->nsaved_regs,
|
||||
sizeof(*sfp->saved_regs), GFP_KERNEL);
|
||||
if (!sfp->saved_regs)
|
||||
return -ENOMEM;
|
||||
#endif
|
||||
|
||||
sfp->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(sfp->base))
|
||||
return PTR_ERR(sfp->base);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ struct jh7110_pinctrl {
|
|||
/* register read/write mutex */
|
||||
struct mutex mutex;
|
||||
const struct jh7110_pinctrl_soc_info *info;
|
||||
u32 *saved_regs;
|
||||
u32 saved_regs[];
|
||||
};
|
||||
|
||||
struct jh7110_gpio_irq_reg {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user