diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2005-09-06 18:16:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-07 19:57:21 -0400 |
commit | a2822e7f00cdccbff8e507b5ebbddce1aa95eb5d (patch) | |
tree | 07ac5760bb7771744daa59b759c34190fb39f3ae /drivers/pnp/pnpbios | |
parent | ea2f1590aaffbd02f1850c19c3895ff4d092c6e0 (diff) |
[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: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/pnp/pnpbios')
-rw-r--r-- | drivers/pnp/pnpbios/core.c | 26 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/pnpbios.h | 1 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/proc.c | 8 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/rsparser.c | 16 |
4 files changed, 20 insertions, 31 deletions
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index 778a324028f4..f49674f07949 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c | |||
@@ -86,16 +86,6 @@ int pnp_bios_present(void) | |||
86 | 86 | ||
87 | struct pnp_dev_node_info node_info; | 87 | struct pnp_dev_node_info node_info; |
88 | 88 | ||
89 | void *pnpbios_kmalloc(size_t size, int f) | ||
90 | { | ||
91 | void *p = kmalloc( size, f ); | ||
92 | if ( p == NULL ) | ||
93 | printk(KERN_ERR "PnPBIOS: kmalloc() failed\n"); | ||
94 | else | ||
95 | memset(p, 0, size); | ||
96 | return p; | ||
97 | } | ||
98 | |||
99 | /* | 89 | /* |
100 | * | 90 | * |
101 | * DOCKING FUNCTIONS | 91 | * DOCKING FUNCTIONS |
@@ -121,10 +111,10 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) | |||
121 | if (!current->fs->root) { | 111 | if (!current->fs->root) { |
122 | return -EAGAIN; | 112 | return -EAGAIN; |
123 | } | 113 | } |
124 | if (!(envp = (char **) pnpbios_kmalloc (20 * sizeof (char *), GFP_KERNEL))) { | 114 | if (!(envp = (char **) kcalloc (20, sizeof (char *), GFP_KERNEL))) { |
125 | return -ENOMEM; | 115 | return -ENOMEM; |
126 | } | 116 | } |
127 | if (!(buf = pnpbios_kmalloc (256, GFP_KERNEL))) { | 117 | if (!(buf = kcalloc (1, 256, GFP_KERNEL))) { |
128 | kfree (envp); | 118 | kfree (envp); |
129 | return -ENOMEM; | 119 | return -ENOMEM; |
130 | } | 120 | } |
@@ -231,7 +221,7 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table | |||
231 | if(!pnpbios_is_dynamic(dev)) | 221 | if(!pnpbios_is_dynamic(dev)) |
232 | return -EPERM; | 222 | return -EPERM; |
233 | 223 | ||
234 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 224 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
235 | if (!node) | 225 | if (!node) |
236 | return -1; | 226 | return -1; |
237 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { | 227 | 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 | if (!pnpbios_is_dynamic(dev)) | 244 | if (!pnpbios_is_dynamic(dev)) |
255 | return -EPERM; | 245 | return -EPERM; |
256 | 246 | ||
257 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 247 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
258 | if (!node) | 248 | if (!node) |
259 | return -1; | 249 | return -1; |
260 | if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { | 250 | 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 | if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) | 295 | if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) |
306 | return -EPERM; | 296 | return -EPERM; |
307 | 297 | ||
308 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 298 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
309 | if (!node) | 299 | if (!node) |
310 | return -ENOMEM; | 300 | return -ENOMEM; |
311 | 301 | ||
@@ -347,7 +337,7 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node) | |||
347 | } | 337 | } |
348 | 338 | ||
349 | /* set the initial values for the PnP device */ | 339 | /* set the initial values for the PnP device */ |
350 | dev_id = pnpbios_kmalloc(sizeof(struct pnp_id), GFP_KERNEL); | 340 | dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); |
351 | if (!dev_id) | 341 | if (!dev_id) |
352 | return -1; | 342 | return -1; |
353 | pnpid32_to_pnpid(node->eisa_id,id); | 343 | pnpid32_to_pnpid(node->eisa_id,id); |
@@ -385,7 +375,7 @@ static void __init build_devlist(void) | |||
385 | struct pnp_bios_node *node; | 375 | struct pnp_bios_node *node; |
386 | struct pnp_dev *dev; | 376 | struct pnp_dev *dev; |
387 | 377 | ||
388 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 378 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
389 | if (!node) | 379 | if (!node) |
390 | return; | 380 | return; |
391 | 381 | ||
@@ -402,7 +392,7 @@ static void __init build_devlist(void) | |||
402 | break; | 392 | break; |
403 | } | 393 | } |
404 | nodes_got++; | 394 | nodes_got++; |
405 | dev = pnpbios_kmalloc(sizeof (struct pnp_dev), GFP_KERNEL); | 395 | dev = kcalloc(1, sizeof (struct pnp_dev), GFP_KERNEL); |
406 | if (!dev) | 396 | if (!dev) |
407 | break; | 397 | break; |
408 | if(insert_device(dev,node)<0) | 398 | if(insert_device(dev,node)<0) |
diff --git a/drivers/pnp/pnpbios/pnpbios.h b/drivers/pnp/pnpbios/pnpbios.h index 01896e705ed4..d8cb2fd1f127 100644 --- a/drivers/pnp/pnpbios/pnpbios.h +++ b/drivers/pnp/pnpbios/pnpbios.h | |||
@@ -26,7 +26,6 @@ union pnp_bios_install_struct { | |||
26 | 26 | ||
27 | extern int pnp_bios_present(void); | 27 | extern int pnp_bios_present(void); |
28 | extern int pnpbios_dont_use_current_config; | 28 | extern int pnpbios_dont_use_current_config; |
29 | extern void *pnpbios_kmalloc(size_t size, int f); | ||
30 | 29 | ||
31 | extern int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node); | 30 | extern int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node); |
32 | extern int pnpbios_read_resources_from_node(struct pnp_resource_table *res, struct pnp_bios_node * node); | 31 | extern int pnpbios_read_resources_from_node(struct pnp_resource_table *res, struct pnp_bios_node * node); |
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c index 6bb8e1973fd4..5a3dfc97f5e9 100644 --- a/drivers/pnp/pnpbios/proc.c +++ b/drivers/pnp/pnpbios/proc.c | |||
@@ -87,7 +87,7 @@ static int proc_read_escd(char *buf, char **start, off_t pos, | |||
87 | return -EFBIG; | 87 | return -EFBIG; |
88 | } | 88 | } |
89 | 89 | ||
90 | tmpbuf = pnpbios_kmalloc(escd.escd_size, GFP_KERNEL); | 90 | tmpbuf = kcalloc(1, escd.escd_size, GFP_KERNEL); |
91 | if (!tmpbuf) return -ENOMEM; | 91 | if (!tmpbuf) return -ENOMEM; |
92 | 92 | ||
93 | if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) { | 93 | 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 | if (pos >= 0xff) | 133 | if (pos >= 0xff) |
134 | return 0; | 134 | return 0; |
135 | 135 | ||
136 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 136 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
137 | if (!node) return -ENOMEM; | 137 | if (!node) return -ENOMEM; |
138 | 138 | ||
139 | for (nodenum=pos; nodenum<0xff; ) { | 139 | for (nodenum=pos; nodenum<0xff; ) { |
@@ -168,7 +168,7 @@ static int proc_read_node(char *buf, char **start, off_t pos, | |||
168 | u8 nodenum = (long)data; | 168 | u8 nodenum = (long)data; |
169 | int len; | 169 | int len; |
170 | 170 | ||
171 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 171 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
172 | if (!node) return -ENOMEM; | 172 | if (!node) return -ENOMEM; |
173 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { | 173 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { |
174 | kfree(node); | 174 | kfree(node); |
@@ -188,7 +188,7 @@ static int proc_write_node(struct file *file, const char __user *buf, | |||
188 | u8 nodenum = (long)data; | 188 | u8 nodenum = (long)data; |
189 | int ret = count; | 189 | int ret = count; |
190 | 190 | ||
191 | node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL); | 191 | node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); |
192 | if (!node) | 192 | if (!node) |
193 | return -ENOMEM; | 193 | return -ENOMEM; |
194 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { | 194 | if (pnp_bios_get_dev_node(&nodenum, boot, node)) { |
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index e305bb132c24..b0ca65b68645 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c | |||
@@ -247,7 +247,7 @@ static void | |||
247 | pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) | 247 | pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) |
248 | { | 248 | { |
249 | struct pnp_mem * mem; | 249 | struct pnp_mem * mem; |
250 | mem = pnpbios_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 250 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
251 | if (!mem) | 251 | if (!mem) |
252 | return; | 252 | return; |
253 | mem->min = ((p[5] << 8) | p[4]) << 8; | 253 | mem->min = ((p[5] << 8) | p[4]) << 8; |
@@ -263,7 +263,7 @@ static void | |||
263 | pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) | 263 | pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) |
264 | { | 264 | { |
265 | struct pnp_mem * mem; | 265 | struct pnp_mem * mem; |
266 | mem = pnpbios_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 266 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
267 | if (!mem) | 267 | if (!mem) |
268 | return; | 268 | return; |
269 | mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; | 269 | mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; |
@@ -279,7 +279,7 @@ static void | |||
279 | pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) | 279 | pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) |
280 | { | 280 | { |
281 | struct pnp_mem * mem; | 281 | struct pnp_mem * mem; |
282 | mem = pnpbios_kmalloc(sizeof(struct pnp_mem), GFP_KERNEL); | 282 | mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); |
283 | if (!mem) | 283 | if (!mem) |
284 | return; | 284 | return; |
285 | mem->min = mem->max = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; | 285 | 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 | struct pnp_irq * irq; | 296 | struct pnp_irq * irq; |
297 | unsigned long bits; | 297 | unsigned long bits; |
298 | 298 | ||
299 | irq = pnpbios_kmalloc(sizeof(struct pnp_irq), GFP_KERNEL); | 299 | irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); |
300 | if (!irq) | 300 | if (!irq) |
301 | return; | 301 | return; |
302 | bits = (p[2] << 8) | p[1]; | 302 | bits = (p[2] << 8) | p[1]; |
@@ -313,7 +313,7 @@ static void | |||
313 | pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) | 313 | pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) |
314 | { | 314 | { |
315 | struct pnp_dma * dma; | 315 | struct pnp_dma * dma; |
316 | dma = pnpbios_kmalloc(sizeof(struct pnp_dma), GFP_KERNEL); | 316 | dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); |
317 | if (!dma) | 317 | if (!dma) |
318 | return; | 318 | return; |
319 | dma->map = p[1]; | 319 | dma->map = p[1]; |
@@ -326,7 +326,7 @@ static void | |||
326 | pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) | 326 | pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) |
327 | { | 327 | { |
328 | struct pnp_port * port; | 328 | struct pnp_port * port; |
329 | port = pnpbios_kmalloc(sizeof(struct pnp_port), GFP_KERNEL); | 329 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); |
330 | if (!port) | 330 | if (!port) |
331 | return; | 331 | return; |
332 | port->min = (p[3] << 8) | p[2]; | 332 | port->min = (p[3] << 8) | p[2]; |
@@ -342,7 +342,7 @@ static void | |||
342 | pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) | 342 | pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) |
343 | { | 343 | { |
344 | struct pnp_port * port; | 344 | struct pnp_port * port; |
345 | port = pnpbios_kmalloc(sizeof(struct pnp_port), GFP_KERNEL); | 345 | port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); |
346 | if (!port) | 346 | if (!port) |
347 | return; | 347 | return; |
348 | port->min = port->max = (p[2] << 8) | p[1]; | 348 | 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 | case SMALL_TAG_COMPATDEVID: /* compatible ID */ | 530 | case SMALL_TAG_COMPATDEVID: /* compatible ID */ |
531 | if (len != 4) | 531 | if (len != 4) |
532 | goto len_err; | 532 | goto len_err; |
533 | dev_id = pnpbios_kmalloc(sizeof (struct pnp_id), GFP_KERNEL); | 533 | dev_id = kcalloc(1, sizeof (struct pnp_id), GFP_KERNEL); |
534 | if (!dev_id) | 534 | if (!dev_id) |
535 | return NULL; | 535 | return NULL; |
536 | memset(dev_id, 0, sizeof(struct pnp_id)); | 536 | memset(dev_id, 0, sizeof(struct pnp_id)); |