ALSA: sound/pci/asihpi: Use kzalloc

Use kzalloc rather than the combination of kmalloc and memset.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,size,flags;
statement S;
@@

-x = kmalloc(size,flags);
+x = kzalloc(size,flags);
 if (x == NULL) S
-memset(x, 0, size);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Julia Lawall 2010-05-13 21:58:37 +02:00 committed by Takashi Iwai
parent 1be1d76b8a
commit 550a8b691c
2 changed files with 2 additions and 4 deletions

View File

@ -448,14 +448,13 @@ static void subsys_create_adapter(struct hpi_message *phm,
if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_PCI2040) if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_PCI2040)
return; return;
ao.priv = kmalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL); ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL);
if (!ao.priv) { if (!ao.priv) {
HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n"); HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n");
phr->error = HPI_ERROR_MEMORY_ALLOC; phr->error = HPI_ERROR_MEMORY_ALLOC;
return; return;
} }
memset(ao.priv, 0, sizeof(struct hpi_hw_obj));
/* create the adapter object based on the resource information */ /* create the adapter object based on the resource information */
/*? memcpy(&ao.Pci,&phm->u.s.Resource.r.Pci,sizeof(ao.Pci)); */ /*? memcpy(&ao.Pci,&phm->u.s.Resource.r.Pci,sizeof(ao.Pci)); */
ao.pci = *phm->u.s.resource.r.pci; ao.pci = *phm->u.s.resource.r.pci;

View File

@ -482,13 +482,12 @@ static void subsys_create_adapter(struct hpi_message *phm,
if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_DSP6205) if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_DSP6205)
return; return;
ao.priv = kmalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL); ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL);
if (!ao.priv) { if (!ao.priv) {
HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n"); HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n");
phr->error = HPI_ERROR_MEMORY_ALLOC; phr->error = HPI_ERROR_MEMORY_ALLOC;
return; return;
} }
memset(ao.priv, 0, sizeof(struct hpi_hw_obj));
ao.pci = *phm->u.s.resource.r.pci; ao.pci = *phm->u.s.resource.r.pci;
err = create_adapter_obj(&ao, &os_error_code); err = create_adapter_obj(&ao, &os_error_code);