From 7a6cb0d5497418599d2125b670926b75e673861c Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 13 May 2010 22:00:05 +0200 Subject: Staging: Use kcalloc or kzalloc Use kcalloc or kzalloc rather than the combination of kmalloc and memset. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression x,y,flags; statement S; type T; @@ x = - kmalloc + kcalloc ( - y * sizeof(T), + y, sizeof(T), flags); if (x == NULL) S -memset(x, 0, y * sizeof(T)); @@ expression x,size,flags; statement S; @@ -x = kmalloc(size,flags); +x = kzalloc(size,flags); if (x == NULL) S -memset(x, 0, size); // Signed-off-by: Julia Lawall --- drivers/staging/vme/bridges/vme_ca91cx42.c | 8 ++------ drivers/staging/vme/bridges/vme_tsi148.c | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'drivers/staging/vme') diff --git a/drivers/staging/vme/bridges/vme_ca91cx42.c b/drivers/staging/vme/bridges/vme_ca91cx42.c index c35dead..0c82eb4 100644 --- a/drivers/staging/vme/bridges/vme_ca91cx42.c +++ b/drivers/staging/vme/bridges/vme_ca91cx42.c @@ -1494,7 +1494,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* We want to support more than one of each bridge so we need to * dynamically allocate the bridge structure */ - ca91cx42_bridge = kmalloc(sizeof(struct vme_bridge), GFP_KERNEL); + ca91cx42_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); if (ca91cx42_bridge == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for device " @@ -1503,9 +1503,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_struct; } - memset(ca91cx42_bridge, 0, sizeof(struct vme_bridge)); - - ca91cx42_device = kmalloc(sizeof(struct ca91cx42_driver), GFP_KERNEL); + ca91cx42_device = kzalloc(sizeof(struct ca91cx42_driver), GFP_KERNEL); if (ca91cx42_device == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for device " @@ -1514,8 +1512,6 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_driver; } - memset(ca91cx42_device, 0, sizeof(struct ca91cx42_driver)); - ca91cx42_bridge->driver_priv = ca91cx42_device; /* Enable the device */ diff --git a/drivers/staging/vme/bridges/vme_tsi148.c b/drivers/staging/vme/bridges/vme_tsi148.c index 7539cce..cf8cf37 100644 --- a/drivers/staging/vme/bridges/vme_tsi148.c +++ b/drivers/staging/vme/bridges/vme_tsi148.c @@ -2230,7 +2230,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* If we want to support more than one of each bridge, we need to * dynamically generate this so we get one per device */ - tsi148_bridge = kmalloc(sizeof(struct vme_bridge), GFP_KERNEL); + tsi148_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); if (tsi148_bridge == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for device " "structure\n"); @@ -2238,9 +2238,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_struct; } - memset(tsi148_bridge, 0, sizeof(struct vme_bridge)); - - tsi148_device = kmalloc(sizeof(struct tsi148_driver), GFP_KERNEL); + tsi148_device = kzalloc(sizeof(struct tsi148_driver), GFP_KERNEL); if (tsi148_device == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for device " "structure\n"); @@ -2248,8 +2246,6 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_driver; } - memset(tsi148_device, 0, sizeof(struct tsi148_driver)); - tsi148_bridge->driver_priv = tsi148_device; /* Enable the device */ -- cgit v1.1