Commit a2822e7f authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Linus Torvalds

[PATCH] pnp: consolidate kmalloc wrappers

ISAPNP, PNPBIOS, and PNPACPI all had their own kmalloc wrappers that
reimplemented kcalloc().  Remove the wrappers and just use kcalloc()
directly.

Note that this also removes the PNPBIOS error message when the kmalloc
fails.
Signed-off-by: default avatarBjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ea2f1590
...@@ -142,17 +142,6 @@ static void isapnp_write_word(unsigned char idx, unsigned short val) ...@@ -142,17 +142,6 @@ static void isapnp_write_word(unsigned char idx, unsigned short val)
isapnp_write_byte(idx+1, val); isapnp_write_byte(idx+1, val);
} }
static void *isapnp_alloc(long size)
{
void *result;
result = kmalloc(size, GFP_KERNEL);
if (!result)
return NULL;
memset(result, 0, size);
return result;
}
static void isapnp_key(void) static void isapnp_key(void)
{ {
unsigned char code = 0x6a, msb; unsigned char code = 0x6a, msb;
...@@ -406,7 +395,7 @@ static void isapnp_parse_id(struct pnp_dev * dev, unsigned short vendor, unsigne ...@@ -406,7 +395,7 @@ static void isapnp_parse_id(struct pnp_dev * dev, unsigned short vendor, unsigne
struct pnp_id * id; struct pnp_id * id;
if (!dev) if (!dev)
return; return;
id = isapnp_alloc(sizeof(struct pnp_id)); id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL);
if (!id) if (!id)
return; return;
sprintf(id->id, "%c%c%c%x%x%x%x", sprintf(id->id, "%c%c%c%x%x%x%x",
...@@ -430,7 +419,7 @@ static struct pnp_dev * __init isapnp_parse_device(struct pnp_card *card, int si ...@@ -430,7 +419,7 @@ static struct pnp_dev * __init isapnp_parse_device(struct pnp_card *card, int si
struct pnp_dev *dev; struct pnp_dev *dev;
isapnp_peek(tmp, size); isapnp_peek(tmp, size);
dev = isapnp_alloc(sizeof(struct pnp_dev)); dev = kcalloc(1, sizeof(struct pnp_dev), GFP_KERNEL);
if (!dev) if (!dev)
return NULL; return NULL;
dev->number = number; dev->number = number;
...@@ -461,7 +450,7 @@ static void __init isapnp_parse_irq_resource(struct pnp_option *option, ...@@ -461,7 +450,7 @@ static void __init isapnp_parse_irq_resource(struct pnp_option *option,
unsigned long bits; unsigned long bits;
isapnp_peek(tmp, size); isapnp_peek(tmp, size);
irq = isapnp_alloc(sizeof(struct pnp_irq)); irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
if (!irq) if (!irq)
return; return;
bits = (tmp[1] << 8) | tmp[0]; bits = (tmp[1] << 8) | tmp[0];
...@@ -485,7 +474,7 @@ static void __init isapnp_parse_dma_resource(struct pnp_option *option, ...@@ -485,7 +474,7 @@ static void __init isapnp_parse_dma_resource(struct pnp_option *option,
struct pnp_dma *dma; struct pnp_dma *dma;
isapnp_peek(tmp, size); isapnp_peek(tmp, size);
dma = isapnp_alloc(sizeof(struct pnp_dma)); dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL);
if (!dma) if (!dma)
return; return;
dma->map = tmp[0]; dma->map = tmp[0];
...@@ -505,7 +494,7 @@ static void __init isapnp_parse_port_resource(struct pnp_option *option, ...@@ -505,7 +494,7 @@ static void __init isapnp_parse_port_resource(struct pnp_option *option,
struct pnp_port *port; struct pnp_port *port;
isapnp_peek(tmp, size); isapnp_peek(tmp, size);
port = isapnp_alloc(sizeof(struct pnp_port)); port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
if (!port) if (!port)
return; return;
port->min = (tmp[2] << 8) | tmp[1]; port->min = (tmp[2] << 8) | tmp[1];
...@@ -528,7 +517,7 @@ static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option, ...@@ -528,7 +517,7 @@ static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option,
struct pnp_port *port; struct pnp_port *port;
isapnp_peek(tmp, size); isapnp_peek(tmp, size);
port = isapnp_alloc(sizeof(struct pnp_port)); port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
if (!port) if (!port)
return; return;
port->min = port->max = (tmp[1] << 8) | tmp[0]; port->min = port->max = (tmp[1] << 8) | tmp[0];
...@@ -550,7 +539,7 @@ static void __init isapnp_parse_mem_resource(struct pnp_option *option, ...@@ -550,7 +539,7 @@ static void __init isapnp_parse_mem_resource(struct pnp_option *option,
struct pnp_mem *mem; struct pnp_mem *mem;
isapnp_peek(tmp, size); isapnp_peek(tmp, size);
mem = isapnp_alloc(sizeof(struct pnp_mem)); mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem) if (!mem)
return; return;
mem->min = ((tmp[2] << 8) | tmp[1]) << 8; mem->min = ((tmp[2] << 8) | tmp[1]) << 8;
...@@ -573,7 +562,7 @@ static void __init isapnp_parse_mem32_resource(struct pnp_option *option, ...@@ -573,7 +562,7 @@ static void __init isapnp_parse_mem32_resource(struct pnp_option *option,
struct pnp_mem *mem; struct pnp_mem *mem;
isapnp_peek(tmp, size); isapnp_peek(tmp, size);
mem = isapnp_alloc(sizeof(struct pnp_mem)); mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem) if (!mem)
return; return;
mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
...@@ -595,7 +584,7 @@ static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option, ...@@ -595,7 +584,7 @@ static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option,
struct pnp_mem *mem; struct pnp_mem *mem;
isapnp_peek(tmp, size); isapnp_peek(tmp, size);
mem = isapnp_alloc(sizeof(struct pnp_mem)); mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem) if (!mem)
return; return;
mem->min = mem->max = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; mem->min = mem->max = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
...@@ -838,7 +827,7 @@ static unsigned char __init isapnp_checksum(unsigned char *data) ...@@ -838,7 +827,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) static void isapnp_parse_card_id(struct pnp_card * card, unsigned short vendor, unsigned short device)
{ {
struct pnp_id * id = isapnp_alloc(sizeof(struct pnp_id)); struct pnp_id * id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL);
if (!id) if (!id)
return; return;
sprintf(id->id, "%c%c%c%x%x%x%x", sprintf(id->id, "%c%c%c%x%x%x%x",
...@@ -874,7 +863,7 @@ static int __init isapnp_build_device_list(void) ...@@ -874,7 +863,7 @@ static int __init isapnp_build_device_list(void)
header[4], header[5], header[6], header[7], header[8]); header[4], header[5], header[6], header[7], header[8]);
printk(KERN_DEBUG "checksum = 0x%x\n", checksum); printk(KERN_DEBUG "checksum = 0x%x\n", checksum);
#endif #endif
if ((card = isapnp_alloc(sizeof(struct pnp_card))) == NULL) if ((card = kcalloc(1, sizeof(struct pnp_card), GFP_KERNEL)) == NULL)
continue; continue;
card->number = csn; card->number = csn;
......
...@@ -41,14 +41,6 @@ static inline int is_exclusive_device(struct acpi_device *dev) ...@@ -41,14 +41,6 @@ static inline int is_exclusive_device(struct acpi_device *dev)
return (!acpi_match_ids(dev, excluded_id_list)); return (!acpi_match_ids(dev, excluded_id_list));
} }
void *pnpacpi_kmalloc(size_t size, int f)
{
void *p = kmalloc(size, f);
if (p)
memset(p, 0, size);
return p;
}
/* /*
* Compatible Device IDs * Compatible Device IDs
*/ */
...@@ -143,7 +135,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) ...@@ -143,7 +135,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
return 0; return 0;
pnp_dbg("ACPI device : hid %s", acpi_device_hid(device)); pnp_dbg("ACPI device : hid %s", acpi_device_hid(device));
dev = pnpacpi_kmalloc(sizeof(struct pnp_dev), GFP_KERNEL); dev = kcalloc(1, sizeof(struct pnp_dev), GFP_KERNEL);
if (!dev) { if (!dev) {
pnp_err("Out of memory"); pnp_err("Out of memory");
return -ENOMEM; return -ENOMEM;
...@@ -173,7 +165,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) ...@@ -173,7 +165,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
dev->number = num; dev->number = num;
/* set the initial values for the PnP device */ /* set the initial values for the PnP device */
dev_id = pnpacpi_kmalloc(sizeof(struct pnp_id), GFP_KERNEL); dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL);
if (!dev_id) if (!dev_id)
goto err; goto err;
pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id); pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id);
...@@ -205,8 +197,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) ...@@ -205,8 +197,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
for (i = 0; i < cid_list->count; i++) { for (i = 0; i < cid_list->count; i++) {
if (!ispnpidacpi(cid_list->id[i].value)) if (!ispnpidacpi(cid_list->id[i].value))
continue; continue;
dev_id = pnpacpi_kmalloc(sizeof(struct pnp_id), dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL);
GFP_KERNEL);
if (!dev_id) if (!dev_id)
continue; continue;
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/pnp.h> #include <linux/pnp.h>
void *pnpacpi_kmalloc(size_t size, int f);
acpi_status pnpacpi_parse_allocated_resource(acpi_handle, struct pnp_resource_table*); acpi_status pnpacpi_parse_allocated_resource(acpi_handle, struct pnp_resource_table*);
acpi_status pnpacpi_parse_resource_option_data(acpi_handle, struct pnp_dev*); acpi_status pnpacpi_parse_resource_option_data(acpi_handle, struct pnp_dev*);
int pnpacpi_encode_resources(struct pnp_resource_table *, struct acpi_buffer *); int pnpacpi_encode_resources(struct pnp_resource_table *, struct acpi_buffer *);
......
...@@ -244,7 +244,7 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso ...@@ -244,7 +244,7 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso
if (p->number_of_channels == 0) if (p->number_of_channels == 0)
return; return;
dma = pnpacpi_kmalloc(sizeof(struct pnp_dma), GFP_KERNEL); dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL);
if (!dma) if (!dma)
return; return;
...@@ -300,7 +300,7 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option, ...@@ -300,7 +300,7 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option,
if (p->number_of_interrupts == 0) if (p->number_of_interrupts == 0)
return; return;
irq = pnpacpi_kmalloc(sizeof(struct pnp_irq), GFP_KERNEL); irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
if (!irq) if (!irq)
return; return;
...@@ -321,7 +321,7 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, ...@@ -321,7 +321,7 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
if (p->number_of_interrupts == 0) if (p->number_of_interrupts == 0)
return; return;
irq = pnpacpi_kmalloc(sizeof(struct pnp_irq), GFP_KERNEL); irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
if (!irq) if (!irq)
return; return;
...@@ -342,7 +342,7 @@ pnpacpi_parse_port_option(struct pnp_option *option, ...@@ -342,7 +342,7 @@ pnpacpi_parse_port_option(struct pnp_option *option,
if (io->range_length == 0) if (io->range_length == 0)
return; return;
port = pnpacpi_kmalloc(sizeof(struct pnp_port), GFP_KERNEL); port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
if (!port) if (!port)
return; return;
port->min = io->min_base_address; port->min = io->min_base_address;
...@@ -363,7 +363,7 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option, ...@@ -363,7 +363,7 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,
if (io->range_length == 0) if (io->range_length == 0)
return; return;
port = pnpacpi_kmalloc(sizeof(struct pnp_port), GFP_KERNEL); port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
if (!port) if (!port)
return; return;
port->min = port->max = io->base_address; port->min = port->max = io->base_address;
...@@ -382,7 +382,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option, ...@@ -382,7 +382,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option,
if (p->range_length == 0) if (p->range_length == 0)
return; return;
mem = pnpacpi_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem) if (!mem)
return; return;
mem->min = p->min_base_address; mem->min = p->min_base_address;
...@@ -405,7 +405,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option, ...@@ -405,7 +405,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option,
if (p->range_length == 0) if (p->range_length == 0)
return; return;
mem = pnpacpi_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem) if (!mem)
return; return;
mem->min = p->min_base_address; mem->min = p->min_base_address;
...@@ -428,7 +428,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, ...@@ -428,7 +428,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
if (p->range_length == 0) if (p->range_length == 0)
return; return;
mem = pnpacpi_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem) if (!mem)
return; return;
mem->min = mem->max = p->range_base_address; mem->min = mem->max = p->range_base_address;
...@@ -612,7 +612,7 @@ int pnpacpi_build_resource_template(acpi_handle handle, ...@@ -612,7 +612,7 @@ int pnpacpi_build_resource_template(acpi_handle handle,
if (!res_cnt) if (!res_cnt)
return -EINVAL; return -EINVAL;
buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1;
buffer->pointer = pnpacpi_kmalloc(buffer->length - 1, GFP_KERNEL); buffer->pointer = kcalloc(1, buffer->length - 1, GFP_KERNEL);
if (!buffer->pointer) if (!buffer->pointer)
return -ENOMEM; return -ENOMEM;
pnp_dbg("Res cnt %d", res_cnt); pnp_dbg("Res cnt %d", res_cnt);
......
...@@ -86,16 +86,6 @@ int pnp_bios_present(void) ...@@ -86,16 +86,6 @@ int pnp_bios_present(void)
struct pnp_dev_node_info node_info; struct pnp_dev_node_info node_info;
void *pnpbios_kmalloc(size_t size, int f)
{
void *p = kmalloc( size, f );
if ( p == NULL )
printk(KERN_ERR "PnPBIOS: kmalloc() failed\n");
else
memset(p, 0, size);
return p;
}
/* /*
* *
* DOCKING FUNCTIONS * DOCKING FUNCTIONS
...@@ -121,10 +111,10 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) ...@@ -121,10 +111,10 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
if (!current->fs->root) { if (!current->fs->root) {
return -EAGAIN; return -EAGAIN;
} }
if (!(envp = (char **) pnpbios_kmalloc (20 * sizeof (char *), GFP_KERNEL))) { if (!(envp = (char **) kcalloc (20, sizeof (char *), GFP_KERNEL))) {
return -ENOMEM; return -ENOMEM;
} }
if (!(buf = pnpbios_kmalloc (256, GFP_KERNEL))) { if (!(buf = kcalloc (1, 256, GFP_KERNEL))) {
kfree (envp); kfree (envp);
return -ENOMEM; return -ENOMEM;
} }
...@@ -231,7 +221,7 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table ...@@ -231,7 +221,7 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table
if(!pnpbios_is_dynamic(dev)) if(!pnpbios_is_dynamic(dev))
return -EPERM; return -EPERM;
node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
if (!node) if (!node)
return -1; return -1;
if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) {
...@@ -254,7 +244,7 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table ...@@ -254,7 +244,7 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table
if (!pnpbios_is_dynamic(dev)) if (!pnpbios_is_dynamic(dev))
return -EPERM; return -EPERM;
node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
if (!node) if (!node)
return -1; return -1;
if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) {
...@@ -305,7 +295,7 @@ static int pnpbios_disable_resources(struct pnp_dev *dev) ...@@ -305,7 +295,7 @@ static int pnpbios_disable_resources(struct pnp_dev *dev)
if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev))
return -EPERM; return -EPERM;
node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
if (!node) if (!node)
return -ENOMEM; return -ENOMEM;
...@@ -347,7 +337,7 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node) ...@@ -347,7 +337,7 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node)
} }
/* set the initial values for the PnP device */ /* set the initial values for the PnP device */
dev_id = pnpbios_kmalloc(sizeof(struct pnp_id), GFP_KERNEL); dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL);
if (!dev_id) if (!dev_id)
return -1; return -1;
pnpid32_to_pnpid(node->eisa_id,id); pnpid32_to_pnpid(node->eisa_id,id);
...@@ -385,7 +375,7 @@ static void __init build_devlist(void) ...@@ -385,7 +375,7 @@ static void __init build_devlist(void)
struct pnp_bios_node *node; struct pnp_bios_node *node;
struct pnp_dev *dev; struct pnp_dev *dev;
node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
if (!node) if (!node)
return; return;
...@@ -402,7 +392,7 @@ static void __init build_devlist(void) ...@@ -402,7 +392,7 @@ static void __init build_devlist(void)
break; break;
} }
nodes_got++; nodes_got++;
dev = pnpbios_kmalloc(sizeof (struct pnp_dev), GFP_KERNEL); dev = kcalloc(1, sizeof (struct pnp_dev), GFP_KERNEL);
if (!dev) if (!dev)
break; break;
if(insert_device(dev,node)<0) if(insert_device(dev,node)<0)
......
...@@ -26,7 +26,6 @@ union pnp_bios_install_struct { ...@@ -26,7 +26,6 @@ union pnp_bios_install_struct {
extern int pnp_bios_present(void); extern int pnp_bios_present(void);
extern int pnpbios_dont_use_current_config; extern int pnpbios_dont_use_current_config;
extern void *pnpbios_kmalloc(size_t size, int f);
extern int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node); extern int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node);
extern int pnpbios_read_resources_from_node(struct pnp_resource_table *res, struct pnp_bios_node * node); extern int pnpbios_read_resources_from_node(struct pnp_resource_table *res, struct pnp_bios_node * node);
......
...@@ -87,7 +87,7 @@ static int proc_read_escd(char *buf, char **start, off_t pos, ...@@ -87,7 +87,7 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
return -EFBIG; return -EFBIG;
} }
tmpbuf = pnpbios_kmalloc(escd.escd_size, GFP_KERNEL); tmpbuf = kcalloc(1, escd.escd_size, GFP_KERNEL);
if (!tmpbuf) return -ENOMEM; if (!tmpbuf) return -ENOMEM;
if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) { if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) {
...@@ -133,7 +133,7 @@ static int proc_read_devices(char *buf, char **start, off_t pos, ...@@ -133,7 +133,7 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
if (pos >= 0xff) if (pos >= 0xff)
return 0; return 0;
node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
if (!node) return -ENOMEM; if (!node) return -ENOMEM;
for (nodenum=pos; nodenum<0xff; ) { for (nodenum=pos; nodenum<0xff; ) {
...@@ -168,7 +168,7 @@ static int proc_read_node(char *buf, char **start, off_t pos, ...@@ -168,7 +168,7 @@ static int proc_read_node(char *buf, char **start, off_t pos,
u8 nodenum = (long)data; u8 nodenum = (long)data;
int len; int len;
node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
if (!node) return -ENOMEM; if (!node) return -ENOMEM;
if (pnp_bios_get_dev_node(&nodenum, boot, node)) { if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
kfree(node); kfree(node);
...@@ -188,7 +188,7 @@ static int proc_write_node(struct file *file, const char __user *buf, ...@@ -188,7 +188,7 @@ static int proc_write_node(struct file *file, const char __user *buf,
u8 nodenum = (long)data; u8 nodenum = (long)data;
int ret = count; int ret = count;
node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); node = kcalloc(1, node_info.max_node_size, GFP_KERNEL);
if (!node) if (!node)
return -ENOMEM; return -ENOMEM;
if (pnp_bios_get_dev_node(&nodenum, boot, node)) { if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
......
...@@ -247,7 +247,7 @@ static void ...@@ -247,7 +247,7 @@ static void
pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option)
{ {
struct pnp_mem * mem; struct pnp_mem * mem;
mem = pnpbios_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem) if (!mem)
return; return;
mem->min = ((p[5] << 8) | p[4]) << 8; mem->min = ((p[5] << 8) | p[4]) << 8;
...@@ -263,7 +263,7 @@ static void ...@@ -263,7 +263,7 @@ static void
pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option)
{ {
struct pnp_mem * mem; struct pnp_mem * mem;
mem = pnpbios_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem) if (!mem)
return; return;
mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4];
...@@ -279,7 +279,7 @@ static void ...@@ -279,7 +279,7 @@ static void
pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option)
{ {
struct pnp_mem * mem; struct pnp_mem * mem;
mem = pnpbios_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
if (!mem) if (!mem)
return; return;
mem->min = mem->max = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; mem->min = mem->max = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4];
...@@ -296,7 +296,7 @@ pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option) ...@@ -296,7 +296,7 @@ pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option)
struct pnp_irq * irq; struct pnp_irq * irq;
unsigned long bits; unsigned long bits;
irq = pnpbios_kmalloc(sizeof(struct pnp_irq), GFP_KERNEL); irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
if (!irq) if (!irq)
return; return;
bits = (p[2] << 8) | p[1]; bits = (p[2] << 8) | p[1];
...@@ -313,7 +313,7 @@ static void ...@@ -313,7 +313,7 @@ static void
pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option)
{ {
struct pnp_dma * dma; struct pnp_dma * dma;
dma = pnpbios_kmalloc(sizeof(struct pnp_dma), GFP_KERNEL); dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL);
if (!dma) if (!dma)
return; return;
dma->map = p[1]; dma->map = p[1];
...@@ -326,7 +326,7 @@ static void ...@@ -326,7 +326,7 @@ static void
pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option)
{ {
struct pnp_port * port; struct pnp_port * port;
port = pnpbios_kmalloc(sizeof(struct pnp_port), GFP_KERNEL); port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
if (!port) if (!port)
return; return;
port->min = (p[3] << 8) | p[2]; port->min = (p[3] << 8) | p[2];
...@@ -342,7 +342,7 @@ static void ...@@ -342,7 +342,7 @@ static void
pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option)
{ {
struct pnp_port * port; struct pnp_port * port;
port = pnpbios_kmalloc(sizeof(struct pnp_port), GFP_KERNEL); port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
if (!port) if (!port)
return; return;
port->min = port->max = (p[2] << 8) | p[1]; port->min = port->max = (p[2] << 8) | p[1];
...@@ -530,7 +530,7 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de ...@@ -530,7 +530,7 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de
case SMALL_TAG_COMPATDEVID: /* compatible ID */ case SMALL_TAG_COMPATDEVID: /* compatible ID */
if (len != 4) if (len != 4)
goto len_err; goto len_err;
dev_id = pnpbios_kmalloc(sizeof (struct pnp_id), GFP_KERNEL); dev_id = kcalloc(1, sizeof (struct pnp_id), GFP_KERNEL);
if (!dev_id) if (!dev_id)
return NULL; return NULL;
memset(dev_id, 0, sizeof(struct pnp_id)); memset(dev_id, 0, sizeof(struct pnp_id));
......
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