Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kernfs: s/sysfs/kernfs/ in constants

kernfs has just been separated out from sysfs and we're already in
full conflict mode. Nothing can make the situation any worse. Let's
take the chance to name things properly.

This patch performs the following renames.

* s/SYSFS_DIR/KERNFS_DIR/
* s/SYSFS_KOBJ_ATTR/KERNFS_FILE/
* s/SYSFS_KOBJ_LINK/KERNFS_LINK/
* s/SYSFS_{TYPE_FLAGS}/KERNFS_{TYPE_FLAGS}/
* s/SYSFS_FLAG_{FLAG}/KERNFS_{FLAG}/
* s/sysfs_type()/kernfs_type()/
* s/SD_DEACTIVATED_BIAS/KN_DEACTIVATED_BIAS/

This patch is strictly rename only and doesn't introduce any
functional difference.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Tejun Heo and committed by
Greg Kroah-Hartman
df23fc39 c525aadd

+63 -63
+25 -25
fs/kernfs/dir.c
··· 78 78 struct rb_node **node = &kn->parent->dir.children.rb_node; 79 79 struct rb_node *parent = NULL; 80 80 81 - if (sysfs_type(kn) == SYSFS_DIR) 81 + if (kernfs_type(kn) == KERNFS_DIR) 82 82 kn->parent->dir.subdirs++; 83 83 84 84 while (*node) { ··· 113 113 */ 114 114 static void sysfs_unlink_sibling(struct kernfs_node *kn) 115 115 { 116 - if (sysfs_type(kn) == SYSFS_DIR) 116 + if (kernfs_type(kn) == KERNFS_DIR) 117 117 kn->parent->dir.subdirs--; 118 118 119 119 rb_erase(&kn->rb, &kn->parent->dir.children); ··· 137 137 if (!atomic_inc_unless_negative(&kn->active)) 138 138 return NULL; 139 139 140 - if (kn->flags & SYSFS_FLAG_LOCKDEP) 140 + if (kn->flags & KERNFS_LOCKDEP) 141 141 rwsem_acquire_read(&kn->dep_map, 0, 1, _RET_IP_); 142 142 return kn; 143 143 } ··· 156 156 if (unlikely(!kn)) 157 157 return; 158 158 159 - if (kn->flags & SYSFS_FLAG_LOCKDEP) 159 + if (kn->flags & KERNFS_LOCKDEP) 160 160 rwsem_release(&kn->dep_map, 1, _RET_IP_); 161 161 v = atomic_dec_return(&kn->active); 162 - if (likely(v != SD_DEACTIVATED_BIAS)) 162 + if (likely(v != KN_DEACTIVATED_BIAS)) 163 163 return; 164 164 165 165 /* ··· 180 180 DECLARE_COMPLETION_ONSTACK(wait); 181 181 int v; 182 182 183 - BUG_ON(!(kn->flags & SYSFS_FLAG_REMOVED)); 183 + BUG_ON(!(kn->flags & KERNFS_REMOVED)); 184 184 185 - if (!(sysfs_type(kn) & SYSFS_ACTIVE_REF)) 185 + if (!(kernfs_type(kn) & KERNFS_ACTIVE_REF)) 186 186 return; 187 187 188 188 kn->u.completion = (void *)&wait; ··· 191 191 /* atomic_add_return() is a mb(), put_active() will always see 192 192 * the updated kn->u.completion. 193 193 */ 194 - v = atomic_add_return(SD_DEACTIVATED_BIAS, &kn->active); 194 + v = atomic_add_return(KN_DEACTIVATED_BIAS, &kn->active); 195 195 196 - if (v != SD_DEACTIVATED_BIAS) { 196 + if (v != KN_DEACTIVATED_BIAS) { 197 197 lock_contended(&kn->dep_map, _RET_IP_); 198 198 wait_for_completion(&wait); 199 199 } ··· 235 235 */ 236 236 parent = kn->parent; 237 237 238 - WARN(!(kn->flags & SYSFS_FLAG_REMOVED), 238 + WARN(!(kn->flags & KERNFS_REMOVED), 239 239 "sysfs: free using entry: %s/%s\n", 240 240 parent ? parent->name : "", kn->name); 241 241 242 - if (sysfs_type(kn) == SYSFS_KOBJ_LINK) 242 + if (kernfs_type(kn) == KERNFS_LINK) 243 243 kernfs_put(kn->symlink.target_kn); 244 - if (sysfs_type(kn) & SYSFS_COPY_NAME) 244 + if (kernfs_type(kn) & KERNFS_COPY_NAME) 245 245 kfree(kn->name); 246 246 if (kn->iattr) { 247 247 if (kn->iattr->ia_secdata) ··· 268 268 static int sysfs_dentry_delete(const struct dentry *dentry) 269 269 { 270 270 struct kernfs_node *kn = dentry->d_fsdata; 271 - return !(kn && !(kn->flags & SYSFS_FLAG_REMOVED)); 271 + return !(kn && !(kn->flags & KERNFS_REMOVED)); 272 272 } 273 273 274 274 static int sysfs_dentry_revalidate(struct dentry *dentry, unsigned int flags) ··· 282 282 mutex_lock(&sysfs_mutex); 283 283 284 284 /* The sysfs dirent has been deleted */ 285 - if (kn->flags & SYSFS_FLAG_REMOVED) 285 + if (kn->flags & KERNFS_REMOVED) 286 286 goto out_bad; 287 287 288 288 /* The sysfs dirent has been moved? */ ··· 342 342 struct kernfs_node *kn; 343 343 int ret; 344 344 345 - if (type & SYSFS_COPY_NAME) { 345 + if (type & KERNFS_COPY_NAME) { 346 346 name = dup_name = kstrdup(name, GFP_KERNEL); 347 347 if (!name) 348 348 return NULL; ··· 362 362 363 363 kn->name = name; 364 364 kn->mode = mode; 365 - kn->flags = type | SYSFS_FLAG_REMOVED; 365 + kn->flags = type | KERNFS_REMOVED; 366 366 367 367 return kn; 368 368 ··· 427 427 return -EINVAL; 428 428 } 429 429 430 - if (sysfs_type(parent) != SYSFS_DIR) 430 + if (kernfs_type(parent) != KERNFS_DIR) 431 431 return -EINVAL; 432 432 433 433 kn->hash = sysfs_name_hash(kn->name, kn->ns); ··· 446 446 } 447 447 448 448 /* Mark the entry added into directory tree */ 449 - kn->flags &= ~SYSFS_FLAG_REMOVED; 449 + kn->flags &= ~KERNFS_REMOVED; 450 450 451 451 return 0; 452 452 } ··· 475 475 * Removal can be called multiple times on the same node. Only the 476 476 * first invocation is effective and puts the base ref. 477 477 */ 478 - if (kn->flags & SYSFS_FLAG_REMOVED) 478 + if (kn->flags & KERNFS_REMOVED) 479 479 return; 480 480 481 481 if (kn->parent) { ··· 489 489 } 490 490 } 491 491 492 - kn->flags |= SYSFS_FLAG_REMOVED; 492 + kn->flags |= KERNFS_REMOVED; 493 493 kn->u.removed_list = acxt->removed; 494 494 acxt->removed = kn; 495 495 } ··· 607 607 608 608 ida_init(&root->ino_ida); 609 609 610 - kn = sysfs_new_dirent(root, "", S_IFDIR | S_IRUGO | S_IXUGO, SYSFS_DIR); 610 + kn = sysfs_new_dirent(root, "", S_IFDIR | S_IRUGO | S_IXUGO, KERNFS_DIR); 611 611 if (!kn) { 612 612 ida_destroy(&root->ino_ida); 613 613 kfree(root); 614 614 return ERR_PTR(-ENOMEM); 615 615 } 616 616 617 - kn->flags &= ~SYSFS_FLAG_REMOVED; 617 + kn->flags &= ~KERNFS_REMOVED; 618 618 kn->priv = priv; 619 619 kn->dir.root = root; 620 620 ··· 654 654 int rc; 655 655 656 656 /* allocate */ 657 - kn = sysfs_new_dirent(kernfs_root(parent), name, mode, SYSFS_DIR); 657 + kn = sysfs_new_dirent(kernfs_root(parent), name, mode, KERNFS_DIR); 658 658 if (!kn) 659 659 return ERR_PTR(-ENOMEM); 660 660 ··· 732 732 733 733 last = pos; 734 734 735 - if (sysfs_type(pos) != SYSFS_DIR) 735 + if (kernfs_type(pos) != KERNFS_DIR) 736 736 break; 737 737 738 738 rbn = rb_first(&pos->dir.children); ··· 914 914 struct kernfs_node *parent, loff_t hash, struct kernfs_node *pos) 915 915 { 916 916 if (pos) { 917 - int valid = !(pos->flags & SYSFS_FLAG_REMOVED) && 917 + int valid = !(pos->flags & KERNFS_REMOVED) && 918 918 pos->parent == parent && hash == pos->hash; 919 919 kernfs_put(pos); 920 920 if (!valid)
+9 -9
fs/kernfs/file.c
··· 49 49 */ 50 50 static const struct kernfs_ops *kernfs_ops(struct kernfs_node *kn) 51 51 { 52 - if (kn->flags & SYSFS_FLAG_LOCKDEP) 52 + if (kn->flags & KERNFS_LOCKDEP) 53 53 lockdep_assert_held(kn); 54 54 return kn->attr.ops; 55 55 } ··· 189 189 { 190 190 struct kernfs_open_file *of = kernfs_of(file); 191 191 192 - if (of->kn->flags & SYSFS_FLAG_HAS_SEQ_SHOW) 192 + if (of->kn->flags & KERNFS_HAS_SEQ_SHOW) 193 193 return seq_read(file, user_buf, count, ppos); 194 194 else 195 195 return kernfs_file_direct_read(of, user_buf, count, ppos); ··· 428 428 * without grabbing @of->mutex by testing HAS_MMAP flag. See the 429 429 * comment in kernfs_file_open() for more details. 430 430 */ 431 - if (!(of->kn->flags & SYSFS_FLAG_HAS_MMAP)) 431 + if (!(of->kn->flags & KERNFS_HAS_MMAP)) 432 432 return -ENODEV; 433 433 434 434 mutex_lock(&of->mutex); ··· 668 668 struct kernfs_open_node *on; 669 669 struct kernfs_open_file *of; 670 670 671 - if (!(kn->flags & SYSFS_FLAG_HAS_MMAP)) 671 + if (!(kn->flags & KERNFS_HAS_MMAP)) 672 672 return; 673 673 674 674 spin_lock_irq(&kernfs_open_node_lock); ··· 738 738 739 739 spin_lock_irqsave(&kernfs_open_node_lock, flags); 740 740 741 - if (!WARN_ON(sysfs_type(kn) != SYSFS_KOBJ_ATTR)) { 741 + if (!WARN_ON(kernfs_type(kn) != KERNFS_FILE)) { 742 742 on = kn->attr.open; 743 743 if (on) { 744 744 atomic_inc(&on->event); ··· 785 785 int rc; 786 786 787 787 kn = sysfs_new_dirent(kernfs_root(parent), name, 788 - (mode & S_IALLUGO) | S_IFREG, SYSFS_KOBJ_ATTR); 788 + (mode & S_IALLUGO) | S_IFREG, KERNFS_FILE); 789 789 if (!kn) 790 790 return ERR_PTR(-ENOMEM); 791 791 ··· 797 797 #ifdef CONFIG_DEBUG_LOCK_ALLOC 798 798 if (key) { 799 799 lockdep_init_map(&kn->dep_map, "s_active", key, 0); 800 - kn->flags |= SYSFS_FLAG_LOCKDEP; 800 + kn->flags |= KERNFS_LOCKDEP; 801 801 } 802 802 #endif 803 803 ··· 807 807 * ref. Cache their existence in flags. 808 808 */ 809 809 if (ops->seq_show) 810 - kn->flags |= SYSFS_FLAG_HAS_SEQ_SHOW; 810 + kn->flags |= KERNFS_HAS_SEQ_SHOW; 811 811 if (ops->mmap) 812 - kn->flags |= SYSFS_FLAG_HAS_MMAP; 812 + kn->flags |= KERNFS_HAS_MMAP; 813 813 814 814 sysfs_addrm_start(&acxt); 815 815 rc = sysfs_add_one(&acxt, kn, parent);
+5 -5
fs/kernfs/inode.c
··· 269 269 attrs->ia_secdata_len); 270 270 } 271 271 272 - if (sysfs_type(kn) == SYSFS_DIR) 272 + if (kernfs_type(kn) == KERNFS_DIR) 273 273 set_nlink(inode, kn->dir.subdirs + 2); 274 274 } 275 275 ··· 299 299 sysfs_refresh_inode(kn, inode); 300 300 301 301 /* initialize inode according to type */ 302 - switch (sysfs_type(kn)) { 303 - case SYSFS_DIR: 302 + switch (kernfs_type(kn)) { 303 + case KERNFS_DIR: 304 304 inode->i_op = &sysfs_dir_inode_operations; 305 305 inode->i_fop = &sysfs_dir_operations; 306 306 break; 307 - case SYSFS_KOBJ_ATTR: 307 + case KERNFS_FILE: 308 308 inode->i_size = kn->attr.size; 309 309 inode->i_fop = &kernfs_file_operations; 310 310 break; 311 - case SYSFS_KOBJ_LINK: 311 + case KERNFS_LINK: 312 312 inode->i_op = &sysfs_symlink_inode_operations; 313 313 break; 314 314 default:
+2 -2
fs/kernfs/kernfs-internal.h
··· 26 26 struct simple_xattrs xattrs; 27 27 }; 28 28 29 - #define SD_DEACTIVATED_BIAS INT_MIN 29 + #define KN_DEACTIVATED_BIAS INT_MIN 30 30 31 - /* SYSFS_TYPE_MASK and types are defined in include/linux/kernfs.h */ 31 + /* KERNFS_TYPE_MASK and types are defined in include/linux/kernfs.h */ 32 32 33 33 /** 34 34 * kernfs_root - find out the kernfs_root a kernfs_node belongs to
+1 -1
fs/kernfs/symlink.c
··· 31 31 int error; 32 32 33 33 kn = sysfs_new_dirent(kernfs_root(parent), name, S_IFLNK|S_IRWXUGO, 34 - SYSFS_KOBJ_LINK); 34 + KERNFS_LINK); 35 35 if (!kn) 36 36 return ERR_PTR(-ENOMEM); 37 37
+1 -1
fs/sysfs/dir.c
··· 113 113 spin_unlock(&sysfs_symlink_target_lock); 114 114 115 115 if (kn) { 116 - WARN_ON_ONCE(sysfs_type(kn) != SYSFS_DIR); 116 + WARN_ON_ONCE(kernfs_type(kn) != KERNFS_DIR); 117 117 kernfs_remove(kn); 118 118 } 119 119 }
+1 -1
fs/sysfs/file.c
··· 29 29 { 30 30 struct kobject *kobj = kn->parent->priv; 31 31 32 - if (kn->flags & SYSFS_FLAG_LOCKDEP) 32 + if (kn->flags & KERNFS_LOCKDEP) 33 33 lockdep_assert_held(kn); 34 34 return kobj->ktype ? kobj->ktype->sysfs_ops : NULL; 35 35 }
+1 -1
fs/sysfs/symlink.c
··· 183 183 goto out; 184 184 185 185 result = -EINVAL; 186 - if (sysfs_type(kn) != SYSFS_KOBJ_LINK) 186 + if (kernfs_type(kn) != KERNFS_LINK) 187 187 goto out; 188 188 if (kn->symlink.target_kn->priv != targ) 189 189 goto out;
+18 -18
include/linux/kernfs.h
··· 28 28 struct kernfs_iattrs; 29 29 30 30 enum kernfs_node_type { 31 - SYSFS_DIR = 0x0001, 32 - SYSFS_KOBJ_ATTR = 0x0002, 33 - SYSFS_KOBJ_LINK = 0x0004, 31 + KERNFS_DIR = 0x0001, 32 + KERNFS_FILE = 0x0002, 33 + KERNFS_LINK = 0x0004, 34 34 }; 35 35 36 - #define SYSFS_TYPE_MASK 0x000f 37 - #define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK) 38 - #define SYSFS_ACTIVE_REF SYSFS_KOBJ_ATTR 39 - #define SYSFS_FLAG_MASK ~SYSFS_TYPE_MASK 36 + #define KERNFS_TYPE_MASK 0x000f 37 + #define KERNFS_COPY_NAME (KERNFS_DIR | KERNFS_LINK) 38 + #define KERNFS_ACTIVE_REF KERNFS_FILE 39 + #define KERNFS_FLAG_MASK ~KERNFS_TYPE_MASK 40 40 41 41 enum kernfs_node_flag { 42 - SYSFS_FLAG_REMOVED = 0x0010, 43 - SYSFS_FLAG_NS = 0x0020, 44 - SYSFS_FLAG_HAS_SEQ_SHOW = 0x0040, 45 - SYSFS_FLAG_HAS_MMAP = 0x0080, 46 - SYSFS_FLAG_LOCKDEP = 0x0100, 42 + KERNFS_REMOVED = 0x0010, 43 + KERNFS_NS = 0x0020, 44 + KERNFS_HAS_SEQ_SHOW = 0x0040, 45 + KERNFS_HAS_MMAP = 0x0080, 46 + KERNFS_LOCKDEP = 0x0100, 47 47 }; 48 48 49 49 /* type-specific structures for kernfs_node union members */ ··· 170 170 171 171 #ifdef CONFIG_SYSFS 172 172 173 - static inline enum kernfs_node_type sysfs_type(struct kernfs_node *kn) 173 + static inline enum kernfs_node_type kernfs_type(struct kernfs_node *kn) 174 174 { 175 - return kn->flags & SYSFS_TYPE_MASK; 175 + return kn->flags & KERNFS_TYPE_MASK; 176 176 } 177 177 178 178 /** ··· 185 185 */ 186 186 static inline void kernfs_enable_ns(struct kernfs_node *kn) 187 187 { 188 - WARN_ON_ONCE(sysfs_type(kn) != SYSFS_DIR); 188 + WARN_ON_ONCE(kernfs_type(kn) != KERNFS_DIR); 189 189 WARN_ON_ONCE(!RB_EMPTY_ROOT(&kn->dir.children)); 190 - kn->flags |= SYSFS_FLAG_NS; 190 + kn->flags |= KERNFS_NS; 191 191 } 192 192 193 193 /** ··· 198 198 */ 199 199 static inline bool kernfs_ns_enabled(struct kernfs_node *kn) 200 200 { 201 - return kn->flags & SYSFS_FLAG_NS; 201 + return kn->flags & KERNFS_NS; 202 202 } 203 203 204 204 struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent, ··· 238 238 239 239 #else /* CONFIG_SYSFS */ 240 240 241 - static inline enum kernfs_node_type sysfs_type(struct kernfs_node *kn) 241 + static inline enum kernfs_node_type kernfs_type(struct kernfs_node *kn) 242 242 { return 0; } /* whatever */ 243 243 244 244 static inline void kernfs_enable_ns(struct kernfs_node *kn) { }