sysfs: add sysfs_dirent->s_name
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / sysfs / sysfs.h
index d976b0005549e9deb720352298550dfed644a839..d34b008537d50bbad874cf963a962c2b182c24fd 100644 (file)
@@ -1,3 +1,17 @@
+struct sysfs_dirent {
+       atomic_t                s_count;
+       struct sysfs_dirent     * s_parent;
+       struct list_head        s_sibling;
+       struct list_head        s_children;
+       const char              * s_name;
+       void                    * s_element;
+       int                     s_type;
+       umode_t                 s_mode;
+       ino_t                   s_ino;
+       struct dentry           * s_dentry;
+       struct iattr            * s_iattr;
+       atomic_t                s_event;
+};
 
 extern struct vfsmount * sysfs_mount;
 extern struct kmem_cache *sysfs_dir_cachep;
@@ -6,9 +20,13 @@ extern void sysfs_delete_inode(struct inode *inode);
 extern struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent *);
 extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *));
 
+extern void release_sysfs_dirent(struct sysfs_dirent * sd);
 extern int sysfs_dirent_exist(struct sysfs_dirent *, const unsigned char *);
-extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *,
-                               umode_t, int);
+extern struct sysfs_dirent *sysfs_new_dirent(const char *name, void *element,
+                                            umode_t mode, int type);
+extern void sysfs_attach_dirent(struct sysfs_dirent *sd,
+                               struct sysfs_dirent *parent_sd,
+                               struct dentry *dentry);
 
 extern int sysfs_add_file(struct dentry *, const struct attribute *, int);
 extern int sysfs_hash_and_remove(struct dentry * dir, const char * name);
@@ -17,10 +35,10 @@ extern struct sysfs_dirent *sysfs_find(struct sysfs_dirent *dir, const char * na
 extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **);
 extern void sysfs_remove_subdir(struct dentry *);
 
-extern const unsigned char * sysfs_get_name(struct sysfs_dirent *sd);
 extern void sysfs_drop_dentry(struct sysfs_dirent *sd, struct dentry *parent);
 extern int sysfs_setattr(struct dentry *dentry, struct iattr *iattr);
 
+extern spinlock_t sysfs_lock;
 extern struct rw_semaphore sysfs_rename_sem;
 extern struct super_block * sysfs_sb;
 extern const struct file_operations sysfs_dir_operations;
@@ -30,7 +48,6 @@ extern const struct inode_operations sysfs_dir_inode_operations;
 extern const struct inode_operations sysfs_symlink_inode_operations;
 
 struct sysfs_symlink {
-       char * link_name;
        struct kobject * target_kobj;
 };
 
@@ -86,18 +103,6 @@ static inline struct kobject *sysfs_get_kobject(struct dentry *dentry)
        return kobj;
 }
 
-static inline void release_sysfs_dirent(struct sysfs_dirent * sd)
-{
-       if (sd->s_type & SYSFS_KOBJ_LINK) {
-               struct sysfs_symlink * sl = sd->s_element;
-               kfree(sl->link_name);
-               kobject_put(sl->target_kobj);
-               kfree(sl);
-       }
-       kfree(sd->s_iattr);
-       kmem_cache_free(sysfs_dir_cachep, sd);
-}
-
 static inline struct sysfs_dirent * sysfs_get(struct sysfs_dirent * sd)
 {
        if (sd) {
@@ -109,7 +114,7 @@ static inline struct sysfs_dirent * sysfs_get(struct sysfs_dirent * sd)
 
 static inline void sysfs_put(struct sysfs_dirent * sd)
 {
-       if (atomic_dec_and_test(&sd->s_count))
+       if (sd && atomic_dec_and_test(&sd->s_count))
                release_sysfs_dirent(sd);
 }