Skip to content

Commit

Permalink
PNP: Remove pnp_alloc()
Browse files Browse the repository at this point in the history
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 <hkallweit1@gmail.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Heiner Kallweit authored and Rafael J. Wysocki committed May 17, 2021
1 parent daadabf commit b15fc7c
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 16 deletions.
1 change: 0 additions & 1 deletion drivers/pnp/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

extern struct mutex pnp_lock;
extern const struct attribute_group *pnp_dev_groups[];
void *pnp_alloc(long size);

int pnp_register_protocol(struct pnp_protocol *protocol);
void pnp_unregister_protocol(struct pnp_protocol *protocol);
Expand Down
2 changes: 1 addition & 1 deletion drivers/pnp/card.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
if (!id)
return 0;

clink = pnp_alloc(sizeof(*clink));
clink = kzalloc(sizeof(*clink), GFP_KERNEL);
if (!clink)
return 0;
clink->card = card;
Expand Down
12 changes: 0 additions & 12 deletions drivers/pnp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@ DEFINE_MUTEX(pnp_lock);
int pnp_platform_devices;
EXPORT_SYMBOL(pnp_platform_devices);

void *pnp_alloc(long size)
{
void *result;

result = kzalloc(size, GFP_KERNEL);
if (!result) {
printk(KERN_ERR "pnp: Out of Memory\n");
return NULL;
}
return result;
}

static void pnp_remove_protocol(struct pnp_protocol *protocol)
{
mutex_lock(&pnp_lock);
Expand Down
4 changes: 2 additions & 2 deletions drivers/pnp/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static ssize_t options_show(struct device *dmdev, struct device_attribute *attr,
int ret, dep = 0, set = 0;
char *indent;

buffer = pnp_alloc(sizeof(pnp_info_buffer_t));
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
if (!buffer)
return -ENOMEM;

Expand Down Expand Up @@ -257,7 +257,7 @@ static ssize_t resources_show(struct device *dmdev,
if (!dev)
return -EINVAL;

buffer = pnp_alloc(sizeof(pnp_info_buffer_t));
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
if (!buffer)
return -ENOMEM;

Expand Down

0 comments on commit b15fc7c

Please sign in to comment.