Commit 8084b372 authored by Dominik Brodowski's avatar Dominik Brodowski

[PATCH] pcmcia: kzalloc conversion

Convert users of kmalloc and memset to kzalloc
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 6423efaa
...@@ -354,13 +354,12 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops, ...@@ -354,13 +354,12 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops,
struct skt_dev_info *sinfo; struct skt_dev_info *sinfo;
int ret, i; int ret, i;
sinfo = kmalloc(sizeof(struct skt_dev_info), GFP_KERNEL); sinfo = kzalloc(sizeof(struct skt_dev_info), GFP_KERNEL);
if (!sinfo) { if (!sinfo) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
memset(sinfo, 0, sizeof(struct skt_dev_info));
sinfo->nskt = nr; sinfo->nskt = nr;
/* /*
......
...@@ -264,12 +264,10 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename) ...@@ -264,12 +264,10 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
if (fw->size >= CISTPL_MAX_CIS_SIZE) if (fw->size >= CISTPL_MAX_CIS_SIZE)
goto release; goto release;
cis = kmalloc(sizeof(cisdump_t), GFP_KERNEL); cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL);
if (!cis) if (!cis)
goto release; goto release;
memset(cis, 0, sizeof(cisdump_t));
cis->Length = fw->size + 1; cis->Length = fw->size + 1;
memcpy(cis->Data, fw->data, fw->size); memcpy(cis->Data, fw->data, fw->size);
...@@ -387,13 +385,12 @@ static int pcmcia_device_probe(struct device * dev) ...@@ -387,13 +385,12 @@ static int pcmcia_device_probe(struct device * dev)
s->functions = mfc.nfn; s->functions = mfc.nfn;
else else
s->functions = 1; s->functions = 1;
s->config = kmalloc(sizeof(config_t) * s->functions, s->config = kzalloc(sizeof(config_t) * s->functions,
GFP_KERNEL); GFP_KERNEL);
if (!s->config) { if (!s->config) {
ret = -ENOMEM; ret = -ENOMEM;
goto put_module; goto put_module;
} }
memset(s->config, 0, sizeof(config_t) * s->functions);
} }
ret = p_drv->probe(p_dev); ret = p_drv->probe(p_dev);
...@@ -572,10 +569,9 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f ...@@ -572,10 +569,9 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
if (s->device_count == 2) if (s->device_count == 2)
goto err_put; goto err_put;
p_dev = kmalloc(sizeof(struct pcmcia_device), GFP_KERNEL); p_dev = kzalloc(sizeof(struct pcmcia_device), GFP_KERNEL);
if (!p_dev) if (!p_dev)
goto err_put; goto err_put;
memset(p_dev, 0, sizeof(struct pcmcia_device));
p_dev->socket = s; p_dev->socket = s;
p_dev->device_no = (s->device_count++); p_dev->device_no = (s->device_count++);
......
...@@ -634,13 +634,11 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev, ...@@ -634,13 +634,11 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
char configbyte; char configbyte;
struct pd6729_socket *socket; struct pd6729_socket *socket;
socket = kmalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS, socket = kzalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS,
GFP_KERNEL); GFP_KERNEL);
if (!socket) if (!socket)
return -ENOMEM; return -ENOMEM;
memset(socket, 0, sizeof(struct pd6729_socket) * MAX_SOCKETS);
if ((ret = pci_enable_device(dev))) if ((ret = pci_enable_device(dev)))
goto err_out_free_mem; goto err_out_free_mem;
......
...@@ -171,10 +171,9 @@ static int __init mst_pcmcia_init(void) ...@@ -171,10 +171,9 @@ static int __init mst_pcmcia_init(void)
{ {
int ret; int ret;
mst_pcmcia_device = kmalloc(sizeof(*mst_pcmcia_device), GFP_KERNEL); mst_pcmcia_device = kzalloc(sizeof(*mst_pcmcia_device), GFP_KERNEL);
if (!mst_pcmcia_device) if (!mst_pcmcia_device)
return -ENOMEM; return -ENOMEM;
memset(mst_pcmcia_device, 0, sizeof(*mst_pcmcia_device));
mst_pcmcia_device->name = "pxa2xx-pcmcia"; mst_pcmcia_device->name = "pxa2xx-pcmcia";
mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops; mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops;
......
...@@ -264,11 +264,10 @@ static int __init sharpsl_pcmcia_init(void) ...@@ -264,11 +264,10 @@ static int __init sharpsl_pcmcia_init(void)
int ret; int ret;
sharpsl_pcmcia_ops.nr=platform_scoop_config->num_devs; sharpsl_pcmcia_ops.nr=platform_scoop_config->num_devs;
sharpsl_pcmcia_device = kmalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL); sharpsl_pcmcia_device = kzalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL);
if (!sharpsl_pcmcia_device) if (!sharpsl_pcmcia_device)
return -ENOMEM; return -ENOMEM;
memset(sharpsl_pcmcia_device, 0, sizeof(*sharpsl_pcmcia_device));
sharpsl_pcmcia_device->name = "pxa2xx-pcmcia"; sharpsl_pcmcia_device->name = "pxa2xx-pcmcia";
sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops; sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops;
sharpsl_pcmcia_device->dev.parent=platform_scoop_config->devs[0].dev; sharpsl_pcmcia_device->dev.parent=platform_scoop_config->devs[0].dev;
......
...@@ -75,10 +75,9 @@ static DECLARE_MUTEX(rsrc_sem); ...@@ -75,10 +75,9 @@ static DECLARE_MUTEX(rsrc_sem);
static struct resource * static struct resource *
make_resource(unsigned long b, unsigned long n, int flags, char *name) make_resource(unsigned long b, unsigned long n, int flags, char *name)
{ {
struct resource *res = kmalloc(sizeof(*res), GFP_KERNEL); struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
if (res) { if (res) {
memset(res, 0, sizeof(*res));
res->name = name; res->name = name;
res->start = b; res->start = b;
res->end = b + n - 1; res->end = b + n - 1;
...@@ -200,12 +199,11 @@ static void do_io_probe(struct pcmcia_socket *s, kio_addr_t base, kio_addr_t num ...@@ -200,12 +199,11 @@ static void do_io_probe(struct pcmcia_socket *s, kio_addr_t base, kio_addr_t num
base, base+num-1); base, base+num-1);
/* First, what does a floating port look like? */ /* First, what does a floating port look like? */
b = kmalloc(256, GFP_KERNEL); b = kzalloc(256, GFP_KERNEL);
if (!b) { if (!b) {
printk(KERN_ERR "do_io_probe: unable to kmalloc 256 bytes"); printk(KERN_ERR "do_io_probe: unable to kmalloc 256 bytes");
return; return;
} }
memset(b, 0, 256);
for (i = base, most = 0; i < base+num; i += 8) { for (i = base, most = 0; i < base+num; i += 8) {
res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe"); res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe");
if (!res) if (!res)
...@@ -850,10 +848,9 @@ static int nonstatic_init(struct pcmcia_socket *s) ...@@ -850,10 +848,9 @@ static int nonstatic_init(struct pcmcia_socket *s)
{ {
struct socket_data *data; struct socket_data *data;
data = kmalloc(sizeof(struct socket_data), GFP_KERNEL); data = kzalloc(sizeof(struct socket_data), GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
memset(data, 0, sizeof(struct socket_data));
data->mem_db.next = &data->mem_db; data->mem_db.next = &data->mem_db;
data->io_db.next = &data->io_db; data->io_db.next = &data->io_db;
......
...@@ -645,13 +645,12 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops ...@@ -645,13 +645,12 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops
down(&soc_pcmcia_sockets_lock); down(&soc_pcmcia_sockets_lock);
sinfo = kmalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL); sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
if (!sinfo) { if (!sinfo) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
memset(sinfo, 0, SKT_DEV_INFO_SIZE(nr));
sinfo->nskt = nr; sinfo->nskt = nr;
/* /*
......
...@@ -285,10 +285,9 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz ...@@ -285,10 +285,9 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz
if (!(s->state & SOCKET_PRESENT)) if (!(s->state & SOCKET_PRESENT))
return -ENODEV; return -ENODEV;
cis = kmalloc(sizeof(cisdump_t), GFP_KERNEL); cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL);
if (!cis) if (!cis)
return -ENOMEM; return -ENOMEM;
memset(cis, 0, sizeof(cisdump_t));
cis->Length = count + 1; cis->Length = count + 1;
memcpy(cis->Data, buf, count); memcpy(cis->Data, buf, count);
......
...@@ -1019,10 +1019,9 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i ...@@ -1019,10 +1019,9 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
return -ENODEV; return -ENODEV;
} }
socket = kmalloc(sizeof(struct yenta_socket), GFP_KERNEL); socket = kzalloc(sizeof(struct yenta_socket), GFP_KERNEL);
if (!socket) if (!socket)
return -ENOMEM; return -ENOMEM;
memset(socket, 0, sizeof(*socket));
/* prepare pcmcia_socket */ /* prepare pcmcia_socket */
socket->socket.ops = &yenta_socket_operations; socket->socket.ops = &yenta_socket_operations;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment