From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Driver Core patches for 2.6.9-rc1
Date: Wed, 25 Aug 2004 15:36:27 -0700 [thread overview]
Message-ID: <1093473387435@kroah.com> (raw)
In-Reply-To: <10934733871723@kroah.com>
ChangeSet 1.1803.64.2, 2004/08/06 14:18:50-07:00, rml@ximian.com
[PATCH] KOBJECT: add kobject_get_path
Add a new kobject helper, kobject_get_path(), which is the greatest
function ever.
Signed-Off-By: Robert Love <rml@ximian.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
include/linux/kobject.h | 2 ++
lib/kobject.c | 36 +++++++++++++++++++++++++++---------
2 files changed, 29 insertions(+), 9 deletions(-)
diff -Nru a/include/linux/kobject.h b/include/linux/kobject.h
--- a/include/linux/kobject.h 2004-08-25 14:57:25 -07:00
+++ b/include/linux/kobject.h 2004-08-25 14:57:25 -07:00
@@ -58,6 +58,8 @@
extern void kobject_hotplug(const char *action, struct kobject *);
+extern char * kobject_get_path(struct kset *, struct kobject *, int);
+
struct kobj_type {
void (*release)(struct kobject *);
struct sysfs_ops * sysfs_ops;
diff -Nru a/lib/kobject.c b/lib/kobject.c
--- a/lib/kobject.c 2004-08-25 14:57:25 -07:00
+++ b/lib/kobject.c 2004-08-25 14:57:25 -07:00
@@ -58,14 +58,11 @@
return error;
}
-
static inline struct kobject * to_kobj(struct list_head * entry)
{
return container_of(entry,struct kobject,entry);
}
-
-#ifdef CONFIG_HOTPLUG
static int get_kobj_path_length(struct kset *kset, struct kobject *kobj)
{
int length = 1;
@@ -98,6 +95,31 @@
pr_debug("%s: path = '%s'\n",__FUNCTION__,path);
}
+/**
+ * kobject_get_path - generate and return the path associated with a given kobj
+ * and kset pair. The result must be freed by the caller with kfree().
+ *
+ * @kset: kset in question, with which to build the path
+ * @kobj: kobject in question, with which to build the path
+ * @gfp_mask: the allocation type used to allocate the path
+ */
+char * kobject_get_path(struct kset *kset, struct kobject *kobj, int gfp_mask)
+{
+ char *path;
+ int len;
+
+ len = get_kobj_path_length(kset, kobj);
+ path = kmalloc(len, gfp_mask);
+ if (!path)
+ return NULL;
+ memset(path, 0x00, len);
+ fill_kobj_path(kset, kobj, path, len);
+
+ return path;
+}
+
+#ifdef CONFIG_HOTPLUG
+
#define BUFFER_SIZE 1024 /* should be enough memory for the env */
#define NUM_ENVP 32 /* number of env pointers */
static unsigned long sequence_num;
@@ -112,7 +134,6 @@
char *scratch;
int i = 0;
int retval;
- int kobj_path_length;
char *kobj_path = NULL;
char *name = NULL;
unsigned long seq;
@@ -163,12 +184,9 @@
envp [i++] = scratch;
scratch += sprintf(scratch, "SEQNUM=%ld", seq) + 1;
- kobj_path_length = get_kobj_path_length (kset, kobj);
- kobj_path = kmalloc (kobj_path_length, GFP_KERNEL);
+ kobj_path = kobject_get_path(kset, kobj, GFP_KERNEL);
if (!kobj_path)
goto exit;
- memset (kobj_path, 0x00, kobj_path_length);
- fill_kobj_path (kset, kobj, kobj_path, kobj_path_length);
envp [i++] = scratch;
scratch += sprintf (scratch, "DEVPATH=%s", kobj_path) + 1;
@@ -626,7 +644,7 @@
}
}
-
+EXPORT_SYMBOL(kobject_get_path);
EXPORT_SYMBOL(kobject_init);
EXPORT_SYMBOL(kobject_register);
EXPORT_SYMBOL(kobject_unregister);
next prev parent reply other threads:[~2004-08-25 22:50 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-25 22:35 [BK PATCH] Driver Core patches for 2.6.9-rc1 Greg KH
2005-05-19 6:25 ` Greg KH
2004-08-25 22:36 ` [PATCH] " Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH [this message]
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-26 2:04 ` Benjamin Herrenschmidt
2004-08-26 4:10 ` Greg KH
2005-05-19 6:25 ` Greg KH
2004-08-26 12:26 ` Jean Delvare
2005-05-19 6:25 ` Jean Delvare
2004-08-26 23:33 ` Benjamin Herrenschmidt
2005-05-19 6:25 ` Benjamin Herrenschmidt
2004-08-27 10:16 ` Jean Delvare
2005-05-19 6:25 ` Jean Delvare
-- strict thread matches above, loose matches on Subject: below --
2004-08-26 18:15 Margit Schubert-While
[not found] <200408261957.58105.margitsw@t-online.de>
[not found] ` <5.1.0.14.2.20040908220127.02a9daa8@pop.t-online.de>
2004-09-08 20:21 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1093473387435@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.