Skip to content

Commit

Permalink
[PATCH] Fix numerous kcalloc() calls, convert to kzalloc()
Browse files Browse the repository at this point in the history
All kcalloc() calls of the form "kcalloc(1,...)" are converted to the
equivalent kzalloc() calls, and a few kcalloc() calls with the incorrect
ordering of the first two arguments are fixed.

Signed-off-by: Robert P. J. Day <[email protected]>
Cc: Jeff Garzik <[email protected]>
Cc: Alan Cox <[email protected]>
Cc: Dominik Brodowski <[email protected]>
Cc: Adam Belay <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Greg KH <[email protected]>
Cc: Mark Fasheh <[email protected]>
Cc: Trond Myklebust <[email protected]>
Cc: Neil Brown <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Robert P. J. Day authored and Linus Torvalds committed Dec 13, 2006
1 parent 90aef12 commit cd86128
Show file tree
Hide file tree
Showing 33 changed files with 89 additions and 89 deletions.
4 changes: 2 additions & 2 deletions drivers/ata/pdc_adma.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ static int adma_port_start(struct ata_port *ap)
return rc;
adma_enter_reg_mode(ap);
rc = -ENOMEM;
pp = kcalloc(1, sizeof(*pp), GFP_KERNEL);
pp = kzalloc(sizeof(*pp), GFP_KERNEL);
if (!pp)
goto err_out;
pp->pkt = dma_alloc_coherent(dev, ADMA_PKT_BYTES, &pp->pkt_dma,
Expand Down Expand Up @@ -672,7 +672,7 @@ static int adma_ata_init_one(struct pci_dev *pdev,
if (rc)
goto err_out_iounmap;

probe_ent = kcalloc(1, sizeof(*probe_ent), GFP_KERNEL);
probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
if (probe_ent == NULL) {
rc = -ENOMEM;
goto err_out_iounmap;
Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/smu.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ static struct smu_sdbp_header *smu_create_sdb_partition(int id)
*/
tlen = sizeof(struct property) + len + 18;

prop = kcalloc(tlen, 1, GFP_KERNEL);
prop = kzalloc(tlen, GFP_KERNEL);
if (prop == NULL)
return NULL;
hdr = (struct smu_sdbp_header *)(prop + 1);
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/rfd_ftl.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
if (mtd->type != MTD_NORFLASH)
return;

part = kcalloc(1, sizeof(struct partition), GFP_KERNEL);
part = kzalloc(sizeof(struct partition), GFP_KERNEL);
if (!part)
return;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/phy/phy_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
struct phy_device *dev;
/* We allocate the device, and initialize the
* default values */
dev = kcalloc(1, sizeof(*dev), GFP_KERNEL);
dev = kzalloc(sizeof(*dev), GFP_KERNEL);

if (NULL == dev)
return (struct phy_device*) PTR_ERR((void*)-ENOMEM);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/skge.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u32 base)
struct skge_element *e;
int i;

ring->start = kcalloc(sizeof(*e), ring->count, GFP_KERNEL);
ring->start = kcalloc(ring->count, sizeof(*e), GFP_KERNEL);
if (!ring->start)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion drivers/pcmcia/at91_cf.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ static int __init at91_cf_probe(struct platform_device *pdev)
if (!io)
return -ENODEV;

cf = kcalloc(1, sizeof *cf, GFP_KERNEL);
cf = kzalloc(sizeof *cf, GFP_KERNEL);
if (!cf)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion drivers/pcmcia/omap_cf.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static int __devinit omap_cf_probe(struct device *dev)
if (irq < 0)
return -EINVAL;

cf = kcalloc(1, sizeof *cf, GFP_KERNEL);
cf = kzalloc(sizeof *cf, GFP_KERNEL);
if (!cf)
return -ENOMEM;
init_timer(&cf->timer);
Expand Down
22 changes: 11 additions & 11 deletions drivers/pnp/isapnp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ static void isapnp_parse_id(struct pnp_dev * dev, unsigned short vendor, unsigne
struct pnp_id * id;
if (!dev)
return;
id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL);
id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
if (!id)
return;
sprintf(id->id, "%c%c%c%x%x%x%x",
Expand All @@ -419,7 +419,7 @@ static struct pnp_dev * __init isapnp_parse_device(struct pnp_card *card, int si
struct pnp_dev *dev;

isapnp_peek(tmp, size);
dev = kcalloc(1, sizeof(struct pnp_dev), GFP_KERNEL);
dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
if (!dev)
return NULL;
dev->number = number;
Expand Down Expand Up @@ -450,7 +450,7 @@ static void __init isapnp_parse_irq_resource(struct pnp_option *option,
unsigned long bits;

isapnp_peek(tmp, size);
irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
if (!irq)
return;
bits = (tmp[1] << 8) | tmp[0];
Expand All @@ -474,7 +474,7 @@ static void __init isapnp_parse_dma_resource(struct pnp_option *option,
struct pnp_dma *dma;

isapnp_peek(tmp, size);
dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL);
dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
if (!dma)
return;
dma->map = tmp[0];
Expand All @@ -494,7 +494,7 @@ static void __init isapnp_parse_port_resource(struct pnp_option *option,
struct pnp_port *port;

isapnp_peek(tmp, size);
port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
if (!port)
return;
port->min = (tmp[2] << 8) | tmp[1];
Expand All @@ -517,7 +517,7 @@ static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option,
struct pnp_port *port;

isapnp_peek(tmp, size);
port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
if (!port)
return;
port->min = port->max = (tmp[1] << 8) | tmp[0];
Expand All @@ -539,7 +539,7 @@ static void __init isapnp_parse_mem_resource(struct pnp_option *option,
struct pnp_mem *mem;

isapnp_peek(tmp, size);
mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem)
return;
mem->min = ((tmp[2] << 8) | tmp[1]) << 8;
Expand All @@ -562,7 +562,7 @@ static void __init isapnp_parse_mem32_resource(struct pnp_option *option,
struct pnp_mem *mem;

isapnp_peek(tmp, size);
mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem)
return;
mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
Expand All @@ -584,7 +584,7 @@ static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option,
struct pnp_mem *mem;

isapnp_peek(tmp, size);
mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem)
return;
mem->min = mem->max = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
Expand Down Expand Up @@ -829,7 +829,7 @@ static unsigned char __init isapnp_checksum(unsigned char *data)

static void isapnp_parse_card_id(struct pnp_card * card, unsigned short vendor, unsigned short device)
{
struct pnp_id * id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL);
struct pnp_id * id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
if (!id)
return;
sprintf(id->id, "%c%c%c%x%x%x%x",
Expand Down Expand Up @@ -865,7 +865,7 @@ static int __init isapnp_build_device_list(void)
header[4], header[5], header[6], header[7], header[8]);
printk(KERN_DEBUG "checksum = 0x%x\n", checksum);
#endif
if ((card = kcalloc(1, sizeof(struct pnp_card), GFP_KERNEL)) == NULL)
if ((card = kzalloc(sizeof(struct pnp_card), GFP_KERNEL)) == NULL)
continue;

card->number = csn;
Expand Down
6 changes: 3 additions & 3 deletions drivers/pnp/pnpacpi/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
return 0;

pnp_dbg("ACPI device : hid %s", acpi_device_hid(device));
dev = kcalloc(1, sizeof(struct pnp_dev), GFP_KERNEL);
dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
if (!dev) {
pnp_err("Out of memory");
return -ENOMEM;
Expand Down Expand Up @@ -169,7 +169,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
dev->number = num;

/* set the initial values for the PnP device */
dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL);
dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
if (!dev_id)
goto err;
pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id);
Expand Down Expand Up @@ -201,7 +201,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
for (i = 0; i < cid_list->count; i++) {
if (!ispnpidacpi(cid_list->id[i].value))
continue;
dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL);
dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
if (!dev_id)
continue;

Expand Down
22 changes: 11 additions & 11 deletions drivers/pnp/pnpacpi/rsparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso

if (p->channel_count == 0)
return;
dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL);
dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
if (!dma)
return;

Expand Down Expand Up @@ -354,7 +354,7 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option,

if (p->interrupt_count == 0)
return;
irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
if (!irq)
return;

Expand All @@ -375,7 +375,7 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,

if (p->interrupt_count == 0)
return;
irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
if (!irq)
return;

Expand All @@ -396,7 +396,7 @@ pnpacpi_parse_port_option(struct pnp_option *option,

if (io->address_length == 0)
return;
port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
if (!port)
return;
port->min = io->minimum;
Expand All @@ -417,7 +417,7 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,

if (io->address_length == 0)
return;
port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
if (!port)
return;
port->min = port->max = io->address;
Expand All @@ -436,7 +436,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option,

if (p->address_length == 0)
return;
mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem)
return;
mem->min = p->minimum;
Expand All @@ -459,7 +459,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option,

if (p->address_length == 0)
return;
mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem)
return;
mem->min = p->minimum;
Expand All @@ -482,7 +482,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,

if (p->address_length == 0)
return;
mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem)
return;
mem->min = mem->max = p->address;
Expand Down Expand Up @@ -514,7 +514,7 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
return;

if (p->resource_type == ACPI_MEMORY_RANGE) {
mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem)
return;
mem->min = mem->max = p->minimum;
Expand All @@ -524,7 +524,7 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0;
pnp_register_mem_resource(option, mem);
} else if (p->resource_type == ACPI_IO_RANGE) {
port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
if (!port)
return;
port->min = port->max = p->minimum;
Expand Down Expand Up @@ -721,7 +721,7 @@ int pnpacpi_build_resource_template(acpi_handle handle,
if (!res_cnt)
return -EINVAL;
buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1;
buffer->pointer = kcalloc(1, buffer->length - 1, GFP_KERNEL);
buffer->pointer = kzalloc(buffer->length - 1, GFP_KERNEL);
if (!buffer->pointer)
return -ENOMEM;
pnp_dbg("Res cnt %d", res_cnt);
Expand Down
14 changes: 7 additions & 7 deletions drivers/pnp/pnpbios/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
if (!(envp = (char **) kcalloc (20, sizeof (char *), GFP_KERNEL))) {
return -ENOMEM;
}
if (!(buf = kcalloc (1, 256, GFP_KERNEL))) {
if (!(buf = kzalloc(256, GFP_KERNEL))) {
kfree (envp);
return -ENOMEM;
}
Expand Down Expand Up @@ -220,7 +220,7 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table
if(!pnpbios_is_dynamic(dev))
return -EPERM;

node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
node = kzalloc(node_info.max_node_size, GFP_KERNEL);
if (!node)
return -1;
if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) {
Expand All @@ -243,7 +243,7 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table
if (!pnpbios_is_dynamic(dev))
return -EPERM;

node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
node = kzalloc(node_info.max_node_size, GFP_KERNEL);
if (!node)
return -1;
if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) {
Expand Down Expand Up @@ -294,7 +294,7 @@ static int pnpbios_disable_resources(struct pnp_dev *dev)
if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev))
return -EPERM;

node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
node = kzalloc(node_info.max_node_size, GFP_KERNEL);
if (!node)
return -ENOMEM;

Expand Down Expand Up @@ -336,7 +336,7 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node)
}

/* set the initial values for the PnP device */
dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL);
dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
if (!dev_id)
return -1;
pnpid32_to_pnpid(node->eisa_id,id);
Expand Down Expand Up @@ -374,7 +374,7 @@ static void __init build_devlist(void)
struct pnp_bios_node *node;
struct pnp_dev *dev;

node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
node = kzalloc(node_info.max_node_size, GFP_KERNEL);
if (!node)
return;

Expand All @@ -391,7 +391,7 @@ static void __init build_devlist(void)
break;
}
nodes_got++;
dev = kcalloc(1, sizeof (struct pnp_dev), GFP_KERNEL);
dev = kzalloc(sizeof (struct pnp_dev), GFP_KERNEL);
if (!dev)
break;
if(insert_device(dev,node)<0)
Expand Down
8 changes: 4 additions & 4 deletions drivers/pnp/pnpbios/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
return -EFBIG;
}

tmpbuf = kcalloc(1, escd.escd_size, GFP_KERNEL);
tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL);
if (!tmpbuf) return -ENOMEM;

if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) {
Expand Down Expand Up @@ -133,7 +133,7 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
if (pos >= 0xff)
return 0;

node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
node = kzalloc(node_info.max_node_size, GFP_KERNEL);
if (!node) return -ENOMEM;

for (nodenum=pos; nodenum<0xff; ) {
Expand Down Expand Up @@ -168,7 +168,7 @@ static int proc_read_node(char *buf, char **start, off_t pos,
u8 nodenum = (long)data;
int len;

node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
node = kzalloc(node_info.max_node_size, GFP_KERNEL);
if (!node) return -ENOMEM;
if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
kfree(node);
Expand All @@ -188,7 +188,7 @@ static int proc_write_node(struct file *file, const char __user *buf,
u8 nodenum = (long)data;
int ret = count;

node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
node = kzalloc(node_info.max_node_size, GFP_KERNEL);
if (!node)
return -ENOMEM;
if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
Expand Down
Loading

0 comments on commit cd86128

Please sign in to comment.