public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH v2 08/11] sysfs: introduce new interface sysfs_get_kobject
@ 2010-05-19  1:48 Lin Ming
  2010-05-18 20:08 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Lin Ming @ 2010-05-19  1:48 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Corey Ashford
  Cc: Frederic Weisbecker, Paul Mundt, eranian@gmail.com,
	Gary.Mohr@Bull.com, arjan@linux.intel.com, Zhang, Yanmin,
	Paul Mackerras, David S. Miller, Russell King,
	Arnaldo Carvalho de Melo, Will Deacon, Maynard Johnson, Carl Love,
	greg@kroah.com, Kay Sievers, lkml

Need this interface in the later sysfs pmu lookup.

struct kobject *sysfs_get_kobject(struct file *file);
Return the relative kobject of the sysfs file.

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
---
 fs/sysfs/file.c       |   15 +++++++++++++++
 include/linux/sysfs.h |    2 ++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index e222b25..0c5d6fe 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -748,6 +748,21 @@ int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *),
 }
 EXPORT_SYMBOL_GPL(sysfs_schedule_callback);
 
+struct kobject *sysfs_get_kobject(struct file *file)
+{
+	struct sysfs_dirent *attr_sd;
+	struct kobject *kobj;
+
+	if (!file)
+		return NULL;
+	if (file->f_op != &sysfs_file_operations)
+		return NULL;
+
+	attr_sd = file->f_path.dentry->d_fsdata;
+	kobj = attr_sd->s_parent->s_dir.kobj;
+
+	return kobj;
+}
 
 EXPORT_SYMBOL_GPL(sysfs_create_file);
 EXPORT_SYMBOL_GPL(sysfs_remove_file);
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index f0496b3..5954234 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -121,6 +121,8 @@ struct sysfs_dirent;
 
 #ifdef CONFIG_SYSFS
 
+struct kobject *sysfs_get_kobject(struct file *file);
+
 int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *),
 			    void *data, struct module *owner);
 





^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-05-19  5:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-19  1:48 [RFC][PATCH v2 08/11] sysfs: introduce new interface sysfs_get_kobject Lin Ming
2010-05-18 20:08 ` Greg KH
2010-05-19  2:55   ` Lin Ming
2010-05-19  3:35     ` Greg KH
2010-05-19  5:42       ` Lin Ming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox