* [PATCH] pnp: Remove pnp_alloc
@ 2021-05-12 20:36 Heiner Kallweit
2021-05-17 14:55 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Heiner Kallweit @ 2021-05-12 20:36 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: linux-acpi
Kernel will complain anyway if it runs out of memory. Therefore we
don't need the error message in pnp_alloc() and hence can remove it
and use kzalloc() directly.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/pnp/base.h | 1 -
drivers/pnp/card.c | 2 +-
drivers/pnp/core.c | 12 ------------
drivers/pnp/interface.c | 4 ++--
4 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index cdcfa39cf..e74a0f6a3 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -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);
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index c2464ee08..2430c14f4 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -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;
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index a50ab002e..ccdfbf397 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -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);
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index 602c46893..44efcdb87 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -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;
@@ -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;
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pnp: Remove pnp_alloc
2021-05-12 20:36 [PATCH] pnp: Remove pnp_alloc Heiner Kallweit
@ 2021-05-17 14:55 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2021-05-17 14:55 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: Rafael J. Wysocki, ACPI Devel Maling List
On Thu, May 13, 2021 at 12:25 AM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>
> Kernel will complain anyway if it runs out of memory. Therefore we
> don't need the error message in pnp_alloc() and hence can remove it
> and use kzalloc() directly.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/pnp/base.h | 1 -
> drivers/pnp/card.c | 2 +-
> drivers/pnp/core.c | 12 ------------
> drivers/pnp/interface.c | 4 ++--
> 4 files changed, 3 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
> index cdcfa39cf..e74a0f6a3 100644
> --- a/drivers/pnp/base.h
> +++ b/drivers/pnp/base.h
> @@ -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);
> diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
> index c2464ee08..2430c14f4 100644
> --- a/drivers/pnp/card.c
> +++ b/drivers/pnp/card.c
> @@ -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;
> diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
> index a50ab002e..ccdfbf397 100644
> --- a/drivers/pnp/core.c
> +++ b/drivers/pnp/core.c
> @@ -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);
> diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
> index 602c46893..44efcdb87 100644
> --- a/drivers/pnp/interface.c
> +++ b/drivers/pnp/interface.c
> @@ -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;
>
> @@ -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;
>
> --
Applied as 5.14 material with edits in the subject and changelog, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-17 14:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-12 20:36 [PATCH] pnp: Remove pnp_alloc Heiner Kallweit
2021-05-17 14:55 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox