[PATCH 1/4] mtd: rawnand: meson: use struct_size macro

Liang Yang liang.yang at amlogic.com
Sun Apr 14 23:01:11 PDT 2019


Hello Martin and Miquel,

On 2019/4/12 6:00, Martin Blumenstingl wrote:
> Use the recently introduced struct_size macro instead of open-coding
> it's logic.
> No functional changes.
> 
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl at googlemail.com>
> ---
>   drivers/mtd/nand/raw/meson_nand.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c
> index cb0b03e36a35..c1a6af57dab5 100644
> --- a/drivers/mtd/nand/raw/meson_nand.c
> +++ b/drivers/mtd/nand/raw/meson_nand.c
> @@ -1242,8 +1242,7 @@ meson_nfc_nand_chip_init(struct device *dev,
>   		return -EINVAL;
>   	}
>   
> -	meson_chip = devm_kzalloc(dev,
> -				  sizeof(*meson_chip) + (nsels * sizeof(u8)),
> +	meson_chip = devm_kzalloc(dev, struct_size(meson_chip, sels, nsels),
>   				  GFP_KERNEL);
Tested-by:Liang Yang <liang.yang at amlogic.com>
Acked-by: Liang Yang <liang.yang at amlogic.com>
>   	if (!meson_chip)
>   		return -ENOMEM;
> 



More information about the linux-mtd mailing list