Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: imx+mxs: Use the preferred form for passing a size of a struct

According to Documentation/CodingStyle - Chapter 14:

"The preferred form for passing a size of a struct is the following:

p = kmalloc(sizeof(*p), ...);

The alternative form where struct name is spelled out hurts readability and
introduces an opportunity for a bug when the pointer variable type is changed
but the corresponding sizeof that is passed to a memory allocator is not."

So do it as recommeded.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

Fabio Estevam and committed by
Wolfram Sang
d4ffeecb 206c5f60

+2 -3
+1 -2
drivers/i2c/busses/i2c-imx.c
··· 668 668 if (IS_ERR(base)) 669 669 return PTR_ERR(base); 670 670 671 - i2c_imx = devm_kzalloc(&pdev->dev, sizeof(struct imx_i2c_struct), 672 - GFP_KERNEL); 671 + i2c_imx = devm_kzalloc(&pdev->dev, sizeof(*i2c_imx), GFP_KERNEL); 673 672 if (!i2c_imx) 674 673 return -ENOMEM; 675 674
+1 -1
drivers/i2c/busses/i2c-mxs.c
··· 811 811 struct resource *res; 812 812 int err, irq; 813 813 814 - i2c = devm_kzalloc(dev, sizeof(struct mxs_i2c_dev), GFP_KERNEL); 814 + i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL); 815 815 if (!i2c) 816 816 return -ENOMEM; 817 817