aboutsummaryrefslogtreecommitdiffstats
path: root/fs/kernfs/file.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-12-11 14:11:54 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-11 18:43:48 -0500
commitadc5e8b58f4886d45f79f4ff41a09001a76a6b12 (patch)
treee77d7c1cb4c7b9fcf236b329cb486750dbaef860 /fs/kernfs/file.c
parent324a56e16e44baecac3ca799fd216154145c14bf (diff)
kernfs: drop s_ prefix from kernfs_node members
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. s_ prefix for kernfs members is used inconsistently and a misnomer now. It's not like kernfs_node is used widely across the kernel making the ability to grep for the members particularly useful. Let's just drop the prefix. 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>
Diffstat (limited to 'fs/kernfs/file.c')
-rw-r--r--fs/kernfs/file.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 1bf07ded826a..5277021196a7 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -21,7 +21,7 @@
21 * There's one sysfs_open_file for each open file and one sysfs_open_dirent 21 * There's one sysfs_open_file for each open file and one sysfs_open_dirent
22 * for each kernfs_node with one or more open files. 22 * for each kernfs_node with one or more open files.
23 * 23 *
24 * kernfs_node->s_attr.open points to sysfs_open_dirent. s_attr.open is 24 * kernfs_node->attr.open points to sysfs_open_dirent. attr.open is
25 * protected by sysfs_open_dirent_lock. 25 * protected by sysfs_open_dirent_lock.
26 * 26 *
27 * filp->private_data points to seq_file whose ->private points to 27 * filp->private_data points to seq_file whose ->private points to
@@ -49,9 +49,9 @@ static struct sysfs_open_file *sysfs_of(struct file *file)
49 */ 49 */
50static const struct kernfs_ops *kernfs_ops(struct kernfs_node *kn) 50static const struct kernfs_ops *kernfs_ops(struct kernfs_node *kn)
51{ 51{
52 if (kn->s_flags & SYSFS_FLAG_LOCKDEP) 52 if (kn->flags & SYSFS_FLAG_LOCKDEP)
53 lockdep_assert_held(kn); 53 lockdep_assert_held(kn);
54 return kn->s_attr.ops; 54 return kn->attr.ops;
55} 55}
56 56
57static void *kernfs_seq_start(struct seq_file *sf, loff_t *ppos) 57static void *kernfs_seq_start(struct seq_file *sf, loff_t *ppos)
@@ -112,9 +112,9 @@ static int kernfs_seq_show(struct seq_file *sf, void *v)
112{ 112{
113 struct sysfs_open_file *of = sf->private; 113 struct sysfs_open_file *of = sf->private;
114 114
115 of->event = atomic_read(&of->kn->s_attr.open->event); 115 of->event = atomic_read(&of->kn->attr.open->event);
116 116
117 return of->kn->s_attr.ops->seq_show(sf, v); 117 return of->kn->attr.ops->seq_show(sf, v);
118} 118}
119 119
120static const struct seq_operations kernfs_seq_ops = { 120static const struct seq_operations kernfs_seq_ops = {
@@ -189,7 +189,7 @@ static ssize_t kernfs_file_read(struct file *file, char __user *user_buf,
189{ 189{
190 struct sysfs_open_file *of = sysfs_of(file); 190 struct sysfs_open_file *of = sysfs_of(file);
191 191
192 if (of->kn->s_flags & SYSFS_FLAG_HAS_SEQ_SHOW) 192 if (of->kn->flags & SYSFS_FLAG_HAS_SEQ_SHOW)
193 return seq_read(file, user_buf, count, ppos); 193 return seq_read(file, user_buf, count, ppos);
194 else 194 else
195 return kernfs_file_direct_read(of, user_buf, count, ppos); 195 return kernfs_file_direct_read(of, user_buf, count, ppos);
@@ -428,7 +428,7 @@ static int kernfs_file_mmap(struct file *file, struct vm_area_struct *vma)
428 * without grabbing @of->mutex by testing HAS_MMAP flag. See the 428 * without grabbing @of->mutex by testing HAS_MMAP flag. See the
429 * comment in kernfs_file_open() for more details. 429 * comment in kernfs_file_open() for more details.
430 */ 430 */
431 if (!(of->kn->s_flags & SYSFS_FLAG_HAS_MMAP)) 431 if (!(of->kn->flags & SYSFS_FLAG_HAS_MMAP))
432 return -ENODEV; 432 return -ENODEV;
433 433
434 mutex_lock(&of->mutex); 434 mutex_lock(&of->mutex);
@@ -477,8 +477,8 @@ out_unlock:
477 * @kn: target kernfs_node 477 * @kn: target kernfs_node
478 * @of: sysfs_open_file for this instance of open 478 * @of: sysfs_open_file for this instance of open
479 * 479 *
480 * If @kn->s_attr.open exists, increment its reference count; 480 * If @kn->attr.open exists, increment its reference count; otherwise,
481 * otherwise, create one. @of is chained to the files list. 481 * create one. @of is chained to the files list.
482 * 482 *
483 * LOCKING: 483 * LOCKING:
484 * Kernel thread context (may sleep). 484 * Kernel thread context (may sleep).
@@ -495,12 +495,12 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn,
495 mutex_lock(&sysfs_open_file_mutex); 495 mutex_lock(&sysfs_open_file_mutex);
496 spin_lock_irq(&sysfs_open_dirent_lock); 496 spin_lock_irq(&sysfs_open_dirent_lock);
497 497
498 if (!kn->s_attr.open && new_od) { 498 if (!kn->attr.open && new_od) {
499 kn->s_attr.open = new_od; 499 kn->attr.open = new_od;
500 new_od = NULL; 500 new_od = NULL;
501 } 501 }
502 502
503 od = kn->s_attr.open; 503 od = kn->attr.open;
504 if (od) { 504 if (od) {
505 atomic_inc(&od->refcnt); 505 atomic_inc(&od->refcnt);
506 list_add_tail(&of->list, &od->files); 506 list_add_tail(&of->list, &od->files);
@@ -531,7 +531,7 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn,
531 * @kn: target kernfs_nodet 531 * @kn: target kernfs_nodet
532 * @of: associated sysfs_open_file 532 * @of: associated sysfs_open_file
533 * 533 *
534 * Put @kn->s_attr.open and unlink @of from the files list. If 534 * Put @kn->attr.open and unlink @of from the files list. If
535 * reference count reaches zero, disassociate and free it. 535 * reference count reaches zero, disassociate and free it.
536 * 536 *
537 * LOCKING: 537 * LOCKING:
@@ -540,7 +540,7 @@ static int sysfs_get_open_dirent(struct kernfs_node *kn,
540static void sysfs_put_open_dirent(struct kernfs_node *kn, 540static void sysfs_put_open_dirent(struct kernfs_node *kn,
541 struct sysfs_open_file *of) 541 struct sysfs_open_file *of)
542{ 542{
543 struct sysfs_open_dirent *od = kn->s_attr.open; 543 struct sysfs_open_dirent *od = kn->attr.open;
544 unsigned long flags; 544 unsigned long flags;
545 545
546 mutex_lock(&sysfs_open_file_mutex); 546 mutex_lock(&sysfs_open_file_mutex);
@@ -550,7 +550,7 @@ static void sysfs_put_open_dirent(struct kernfs_node *kn,
550 list_del(&of->list); 550 list_del(&of->list);
551 551
552 if (atomic_dec_and_test(&od->refcnt)) 552 if (atomic_dec_and_test(&od->refcnt))
553 kn->s_attr.open = NULL; 553 kn->attr.open = NULL;
554 else 554 else
555 od = NULL; 555 od = NULL;
556 556
@@ -668,11 +668,11 @@ void sysfs_unmap_bin_file(struct kernfs_node *kn)
668 struct sysfs_open_dirent *od; 668 struct sysfs_open_dirent *od;
669 struct sysfs_open_file *of; 669 struct sysfs_open_file *of;
670 670
671 if (!(kn->s_flags & SYSFS_FLAG_HAS_MMAP)) 671 if (!(kn->flags & SYSFS_FLAG_HAS_MMAP))
672 return; 672 return;
673 673
674 spin_lock_irq(&sysfs_open_dirent_lock); 674 spin_lock_irq(&sysfs_open_dirent_lock);
675 od = kn->s_attr.open; 675 od = kn->attr.open;
676 if (od) 676 if (od)
677 atomic_inc(&od->refcnt); 677 atomic_inc(&od->refcnt);
678 spin_unlock_irq(&sysfs_open_dirent_lock); 678 spin_unlock_irq(&sysfs_open_dirent_lock);
@@ -706,7 +706,7 @@ static unsigned int kernfs_file_poll(struct file *filp, poll_table *wait)
706{ 706{
707 struct sysfs_open_file *of = sysfs_of(filp); 707 struct sysfs_open_file *of = sysfs_of(filp);
708 struct kernfs_node *kn = filp->f_path.dentry->d_fsdata; 708 struct kernfs_node *kn = filp->f_path.dentry->d_fsdata;
709 struct sysfs_open_dirent *od = kn->s_attr.open; 709 struct sysfs_open_dirent *od = kn->attr.open;
710 710
711 /* need parent for the kobj, grab both */ 711 /* need parent for the kobj, grab both */
712 if (!sysfs_get_active(kn)) 712 if (!sysfs_get_active(kn))
@@ -739,7 +739,7 @@ void kernfs_notify(struct kernfs_node *kn)
739 spin_lock_irqsave(&sysfs_open_dirent_lock, flags); 739 spin_lock_irqsave(&sysfs_open_dirent_lock, flags);
740 740
741 if (!WARN_ON(sysfs_type(kn) != SYSFS_KOBJ_ATTR)) { 741 if (!WARN_ON(sysfs_type(kn) != SYSFS_KOBJ_ATTR)) {
742 od = kn->s_attr.open; 742 od = kn->attr.open;
743 if (od) { 743 if (od) {
744 atomic_inc(&od->event); 744 atomic_inc(&od->event);
745 wake_up_interruptible(&od->poll); 745 wake_up_interruptible(&od->poll);
@@ -789,27 +789,27 @@ struct kernfs_node *kernfs_create_file_ns_key(struct kernfs_node *parent,
789 if (!kn) 789 if (!kn)
790 return ERR_PTR(-ENOMEM); 790 return ERR_PTR(-ENOMEM);
791 791
792 kn->s_attr.ops = ops; 792 kn->attr.ops = ops;
793 kn->s_attr.size = size; 793 kn->attr.size = size;
794 kn->s_ns = ns; 794 kn->ns = ns;
795 kn->priv = priv; 795 kn->priv = priv;
796 796
797#ifdef CONFIG_DEBUG_LOCK_ALLOC 797#ifdef CONFIG_DEBUG_LOCK_ALLOC
798 if (key) { 798 if (key) {
799 lockdep_init_map(&kn->dep_map, "s_active", key, 0); 799 lockdep_init_map(&kn->dep_map, "s_active", key, 0);
800 kn->s_flags |= SYSFS_FLAG_LOCKDEP; 800 kn->flags |= SYSFS_FLAG_LOCKDEP;
801 } 801 }
802#endif 802#endif
803 803
804 /* 804 /*
805 * kn->s_attr.ops is accesible only while holding active ref. We 805 * kn->attr.ops is accesible only while holding active ref. We
806 * need to know whether some ops are implemented outside active 806 * need to know whether some ops are implemented outside active
807 * ref. Cache their existence in flags. 807 * ref. Cache their existence in flags.
808 */ 808 */
809 if (ops->seq_show) 809 if (ops->seq_show)
810 kn->s_flags |= SYSFS_FLAG_HAS_SEQ_SHOW; 810 kn->flags |= SYSFS_FLAG_HAS_SEQ_SHOW;
811 if (ops->mmap) 811 if (ops->mmap)
812 kn->s_flags |= SYSFS_FLAG_HAS_MMAP; 812 kn->flags |= SYSFS_FLAG_HAS_MMAP;
813 813
814 sysfs_addrm_start(&acxt); 814 sysfs_addrm_start(&acxt);
815 rc = sysfs_add_one(&acxt, kn, parent); 815 rc = sysfs_add_one(&acxt, kn, parent);