[PATCH] drivers/base: a little speedup and cleanup

From: Jiri Slaby
Date: Fri Sep 16 2005 - 07:26:45 EST


Generated in 2.6.14-rc1-mm1 kernel version.

Signed-off-by: Jiri Slaby <xslaby@xxxxxxxxxx>
---

platform.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)

Performance improvement -- we don't need to zero all allocated memory, only a
few bytes from the beginning.
sizeof cleanup -- we want struct a *b; sizeof(*b) rather than sizeof(struct a).

---
commit 0173dea2b934339a62947115081483278c289d1d
tree 3fb8fcd0afa14f636972d2fa7d0a6d136a12654e
parent ee677410285dd60b28e9a5503365e7f0c961f01e
author root <root@bellona.(none)> Fri, 16 Sep 2005 14:16:10 +0200
committer root <root@bellona.(none)> Fri, 16 Sep 2005 14:16:10 +0200

drivers/base/platform.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -225,18 +225,19 @@ struct platform_device *platform_device_
struct platform_object *pobj;
int retval;

- pobj = kzalloc(sizeof(*pobj) + sizeof(struct resource) * num, GFP_KERNEL);
+ pobj = kmalloc(sizeof(*pobj) + sizeof(*res) * num, GFP_KERNEL);
if (!pobj) {
retval = -ENOMEM;
goto error;
}
+ memset(pobj, 0, sizeof(*pobj));

pobj->pdev.name = name;
pobj->pdev.id = id;
pobj->pdev.dev.release = platform_device_release_simple;

if (num) {
- memcpy(pobj->resources, res, sizeof(struct resource) * num);
+ memcpy(pobj->resources, res, sizeof(*res) * num);
pobj->pdev.resource = pobj->resources;
pobj->pdev.num_resources = num;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/