* [PATCH] driver core: platform: Simplify platform_device_alloc()
@ 2026-09-25 9:39 Cezary Rojewski
2026-09-25 12:38 ` Vishal Moola (Fractile)
0 siblings, 1 reply; 2+ messages in thread
From: Cezary Rojewski @ 2026-09-25 9:39 UTC (permalink / raw)
To: driver-core, gregkh, rafael, dakr
Cc: linux-kernel, dawid.osuchowski, Cezary Rojewski
There is no need to double check the 'pa' object.
Reviewed-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
drivers/base/platform.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index b45d41b018ca..461ffcddad2c 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -620,16 +620,17 @@ struct platform_device *platform_device_alloc(const char *name, int id)
struct platform_object *pa;
pa = kzalloc(sizeof(*pa) + strlen(name) + 1, GFP_KERNEL);
- if (pa) {
- strcpy(pa->name, name);
- pa->pdev.name = pa->name;
- pa->pdev.id = id;
- device_initialize(&pa->pdev.dev);
- pa->pdev.dev.release = platform_device_release;
- setup_pdev_dma_masks(&pa->pdev);
- }
+ if (!pa)
+ return NULL;
- return pa ? &pa->pdev : NULL;
+ strcpy(pa->name, name);
+ pa->pdev.name = pa->name;
+ pa->pdev.id = id;
+ device_initialize(&pa->pdev.dev);
+ pa->pdev.dev.release = platform_device_release;
+ setup_pdev_dma_masks(&pa->pdev);
+
+ return &pa->pdev;
}
EXPORT_SYMBOL_GPL(platform_device_alloc);
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] driver core: platform: Simplify platform_device_alloc()
2026-09-25 9:39 [PATCH] driver core: platform: Simplify platform_device_alloc() Cezary Rojewski
@ 2026-09-25 12:38 ` Vishal Moola (Fractile)
0 siblings, 0 replies; 2+ messages in thread
From: Vishal Moola (Fractile) @ 2026-09-25 12:38 UTC (permalink / raw)
To: Cezary Rojewski
Cc: driver-core, gregkh, rafael, dakr, linux-kernel, dawid.osuchowski
On Fri, Sep 25, 2026 at 11:39:28AM +0200, Cezary Rojewski wrote:
> There is no need to double check the 'pa' object.
>
> Reviewed-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Minor nit: The commit message could be more descriptive (i.e. something
like "Check whether platform_object allocation failed once instead of
checking for success twice"). Although I imagine compilers are smart
enough to avoid double checking anyway (I haven't looked at the
generated code myself).
Either way the new code is more readable, so LGTM.
Reviewed-by: Vishal Moola (Fractile) <vishal.moola@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-25 12:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 9:39 [PATCH] driver core: platform: Simplify platform_device_alloc() Cezary Rojewski
2026-09-25 12:38 ` Vishal Moola (Fractile)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®