Skip to content

Commit b15fc7c

Browse files
hkallweitrafaeljw
authored andcommitted
PNP: Remove pnp_alloc()
The kernel will complain anyway if it runs out of memory, so it is not necessary to print an extra error message when that happens and kzalloc() can be called directly instead of pnp_alloc() which then becomes redundant and can be dropped. Signed-off-by: Heiner Kallweit <[email protected]> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent daadabf commit b15fc7c

File tree

4 files changed

+3
-16
lines changed

4 files changed

+3
-16
lines changed

drivers/pnp/base.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
extern struct mutex pnp_lock;
88
extern const struct attribute_group *pnp_dev_groups[];
9-
void *pnp_alloc(long size);
109

1110
int pnp_register_protocol(struct pnp_protocol *protocol);
1211
void pnp_unregister_protocol(struct pnp_protocol *protocol);

drivers/pnp/card.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
8080
if (!id)
8181
return 0;
8282

83-
clink = pnp_alloc(sizeof(*clink));
83+
clink = kzalloc(sizeof(*clink), GFP_KERNEL);
8484
if (!clink)
8585
return 0;
8686
clink->card = card;

drivers/pnp/core.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@ DEFINE_MUTEX(pnp_lock);
3131
int pnp_platform_devices;
3232
EXPORT_SYMBOL(pnp_platform_devices);
3333

34-
void *pnp_alloc(long size)
35-
{
36-
void *result;
37-
38-
result = kzalloc(size, GFP_KERNEL);
39-
if (!result) {
40-
printk(KERN_ERR "pnp: Out of Memory\n");
41-
return NULL;
42-
}
43-
return result;
44-
}
45-
4634
static void pnp_remove_protocol(struct pnp_protocol *protocol)
4735
{
4836
mutex_lock(&pnp_lock);

drivers/pnp/interface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static ssize_t options_show(struct device *dmdev, struct device_attribute *attr,
214214
int ret, dep = 0, set = 0;
215215
char *indent;
216216

217-
buffer = pnp_alloc(sizeof(pnp_info_buffer_t));
217+
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
218218
if (!buffer)
219219
return -ENOMEM;
220220

@@ -257,7 +257,7 @@ static ssize_t resources_show(struct device *dmdev,
257257
if (!dev)
258258
return -EINVAL;
259259

260-
buffer = pnp_alloc(sizeof(pnp_info_buffer_t));
260+
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
261261
if (!buffer)
262262
return -ENOMEM;
263263

0 commit comments

Comments
 (0)