[RFC] Add inline routine to free memory used in kobject name

From: Larry Finger
Date: Mon Oct 07 2013 - 13:50:54 EST


At present, if one wants to free the memory allocation used for
a dev->kobj name, it is necessary to go quite deeply into the structure.
To avoid this much dependence on the structure details in driver
code, a new inline routine is created.

Signed-off-by: Larry Finger <Larry.Finger@xxxxxxxxxxxx>
---

Index: wireless-testing-save/include/linux/device.h
===================================================================
--- wireless-testing-save.orig/include/linux/device.h
+++ wireless-testing-save/include/linux/device.h
@@ -27,6 +27,7 @@
#include <linux/ratelimit.h>
#include <linux/uidgid.h>
#include <asm/device.h>
+#include <linux/slab.h>

struct device;
struct device_private;
@@ -789,6 +790,11 @@ static inline const char *dev_name(const
return kobject_name(&dev->kobj);
}

+static inline void dev_free_name(struct device *dev)
+{
+ kfree(dev->kobj.name);
+}
+
extern __printf(2, 3)
int dev_set_name(struct device *dev, const char *name, ...);

--
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/