[PATCH 1/4] staging: mt29f: fix malloc style for structs

Manuel Pégourié-Gonnard mpg at elzevir.fr
Tue Dec 29 03:32:19 PST 2015


According to CodingStyle, sizeof(*p) is better than sizeof(struct foo).

Signed-off-by: Manuel Pégourié-Gonnard <mpg at elzevir.fr>
---
 drivers/staging/mt29f_spinand/mt29f_spinand.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c
index 47bb56f1f8c0..dc2b1fc995c2 100644
--- a/drivers/staging/mt29f_spinand/mt29f_spinand.c
+++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c
@@ -852,8 +852,7 @@ static int spinand_probe(struct spi_device *spi_nand)
 	struct spinand_state *state;
 	struct mtd_part_parser_data ppdata;
 
-	info  = devm_kzalloc(&spi_nand->dev, sizeof(struct spinand_info),
-			     GFP_KERNEL);
+	info = devm_kzalloc(&spi_nand->dev, sizeof(*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
@@ -861,8 +860,7 @@ static int spinand_probe(struct spi_device *spi_nand)
 
 	spinand_lock_block(spi_nand, BL_ALL_UNLOCKED);
 
-	state = devm_kzalloc(&spi_nand->dev, sizeof(struct spinand_state),
-			     GFP_KERNEL);
+	state = devm_kzalloc(&spi_nand->dev, sizeof(*state), GFP_KERNEL);
 	if (!state)
 		return -ENOMEM;
 
@@ -872,8 +870,7 @@ static int spinand_probe(struct spi_device *spi_nand)
 	if (!state->buf)
 		return -ENOMEM;
 
-	chip = devm_kzalloc(&spi_nand->dev, sizeof(struct nand_chip),
-			    GFP_KERNEL);
+	chip = devm_kzalloc(&spi_nand->dev, sizeof(*chip), GFP_KERNEL);
 	if (!chip)
 		return -ENOMEM;
 
@@ -903,7 +900,7 @@ static int spinand_probe(struct spi_device *spi_nand)
 	chip->options	|= NAND_CACHEPRG;
 	chip->select_chip = spinand_select_chip;
 
-	mtd = devm_kzalloc(&spi_nand->dev, sizeof(struct mtd_info), GFP_KERNEL);
+	mtd = devm_kzalloc(&spi_nand->dev, sizeof(*mtd), GFP_KERNEL);
 	if (!mtd)
 		return -ENOMEM;
 
-- 
2.6.4




More information about the linux-mtd mailing list