lkml.org 
[lkml]   [2010]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[RFC][PATCH v2 08/11] sysfs: introduce new interface sysfs_get_kobject
From
Date
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);






\
 
 \ /
  Last update: 2010-05-18 19:51    [W:0.036 / U:1.980 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site