kernel/3.6: remove yaffs support
[openwrt.git] / target / linux / generic / patches-3.9 / 502-yaffs-Switch-from-semaphores-to-mutexes.patch
1 From c0c289363e84c53b5872f7c0c5069045096dca07 Mon Sep 17 00:00:00 2001
2 From: Charles Manning <cdhmanning@gmail.com>
3 Date: Wed, 3 Nov 2010 16:01:12 +1300
4 Subject: [PATCH] yaffs: Switch from semaphores to mutexes
5
6 commit 73c54aa8c1de3f61a4c211cd47431293a6092f18 upstream.
7
8 Mutex is faster and init_MUTEX has been deprecated, so we'll just switch
9 to mutexes.
10
11 Signed-off-by: Charles Manning <cdhmanning@gmail.com>
12 ---
13  yaffs_linux.h     |    2 +-
14  yaffs_vfs.c       |   24 ++++++++++++------------
15  yaffs_vfs_multi.c |   26 +++++++++++++-------------
16  3 files changed, 26 insertions(+), 26 deletions(-)
17
18 --- a/fs/yaffs2/yaffs_linux.h
19 +++ b/fs/yaffs2/yaffs_linux.h
20 @@ -25,7 +25,7 @@ struct yaffs_LinuxContext {
21         struct super_block * superBlock;
22         struct task_struct *bgThread; /* Background thread for this device */
23         int bgRunning;
24 -        struct semaphore grossLock;     /* Gross locking semaphore */
25 +       struct mutex grossLock; /* Gross locking mutex*/
26         __u8 *spareBuffer;      /* For mtdif2 use. Don't know the size of the buffer
27                                  * at compile time so we have to allocate it.
28                                  */
29 --- a/fs/yaffs2/yaffs_vfs_glue.c
30 +++ b/fs/yaffs2/yaffs_vfs_glue.c
31 @@ -515,14 +515,14 @@ static unsigned yaffs_gc_control_callbac
32  static void yaffs_gross_lock(yaffs_dev_t *dev)
33  {
34         T(YAFFS_TRACE_LOCK, (TSTR("yaffs locking %p\n"), current));
35 -       down(&(yaffs_dev_to_lc(dev)->grossLock));
36 +       mutex_lock(&(yaffs_dev_to_lc(dev)->grossLock));
37         T(YAFFS_TRACE_LOCK, (TSTR("yaffs locked %p\n"), current));
38  }
39  
40  static void yaffs_gross_unlock(yaffs_dev_t *dev)
41  {
42         T(YAFFS_TRACE_LOCK, (TSTR("yaffs unlocking %p\n"), current));
43 -       up(&(yaffs_dev_to_lc(dev)->grossLock));
44 +       mutex_unlock(&(yaffs_dev_to_lc(dev)->grossLock));
45  }
46  
47  #ifdef YAFFS_COMPILE_EXPORTFS
48 @@ -2542,7 +2542,7 @@ static void yaffs_read_inode(struct inod
49  #endif
50  
51  static YLIST_HEAD(yaffs_context_list);
52 -struct semaphore yaffs_context_lock;
53 +struct mutex yaffs_context_lock;
54  
55  static void yaffs_put_super(struct super_block *sb)
56  {
57 @@ -2568,9 +2568,9 @@ static void yaffs_put_super(struct super
58  
59         yaffs_gross_unlock(dev);
60  
61 -       down(&yaffs_context_lock);
62 +       mutex_lock(&yaffs_context_lock);
63         ylist_del_init(&(yaffs_dev_to_lc(dev)->contextList));
64 -       up(&yaffs_context_lock);
65 +       mutex_unlock(&yaffs_context_lock);
66  
67         if (yaffs_dev_to_lc(dev)->spareBuffer) {
68                 YFREE(yaffs_dev_to_lc(dev)->spareBuffer);
69 @@ -3016,7 +3016,7 @@ static struct super_block *yaffs_interna
70         param->skip_checkpt_rd = options.skip_checkpoint_read;
71         param->skip_checkpt_wr = options.skip_checkpoint_write;
72  
73 -       down(&yaffs_context_lock);
74 +       mutex_lock(&yaffs_context_lock);
75         /* Get a mount id */
76         found = 0;
77         for(mount_id=0; ! found; mount_id++){
78 @@ -3030,13 +3030,13 @@ static struct super_block *yaffs_interna
79         context->mount_id = mount_id;
80  
81         ylist_add_tail(&(yaffs_dev_to_lc(dev)->contextList), &yaffs_context_list);
82 -       up(&yaffs_context_lock);
83 +       mutex_unlock(&yaffs_context_lock);
84  
85          /* Directory search handling...*/
86          YINIT_LIST_HEAD(&(yaffs_dev_to_lc(dev)->searchContexts));
87          param->remove_obj_fn = yaffs_remove_obj_callback;
88  
89 -       init_MUTEX(&(yaffs_dev_to_lc(dev)->grossLock));
90 +       mutex_init(&(yaffs_dev_to_lc(dev)->grossLock));
91  
92         yaffs_gross_lock(dev);
93  
94 @@ -3268,7 +3268,7 @@ static int yaffs_proc_read(char *page,
95         else {
96                 step-=2;
97                 
98 -               down(&yaffs_context_lock);
99 +               mutex_lock(&yaffs_context_lock);
100  
101                 /* Locate and print the Nth entry.  Order N-squared but N is small. */
102                 ylist_for_each(item, &yaffs_context_list) {
103 @@ -3287,7 +3287,7 @@ static int yaffs_proc_read(char *page,
104                         
105                         break;
106                 }
107 -               up(&yaffs_context_lock);
108 +               mutex_unlock(&yaffs_context_lock);
109         }
110  
111         return buf - page < count ? buf - page : count;
112 @@ -3301,7 +3301,7 @@ static int yaffs_stats_proc_read(char *p
113         char *buf = page;
114         int n = 0;
115  
116 -       down(&yaffs_context_lock);
117 +       mutex_lock(&yaffs_context_lock);
118  
119         /* Locate and print the Nth entry.  Order N-squared but N is small. */
120         ylist_for_each(item, &yaffs_context_list) {
121 @@ -3317,7 +3317,7 @@ static int yaffs_stats_proc_read(char *p
122                                 dev->bg_gcs, dev->oldest_dirty_gc_count,
123                                 dev->n_obj, dev->n_tnodes);
124         }
125 -       up(&yaffs_context_lock);
126 +       mutex_unlock(&yaffs_context_lock);
127  
128  
129         return buf - page < count ? buf - page : count;
130 @@ -3494,7 +3494,7 @@ static int __init init_yaffs_fs(void)
131  
132  
133  
134 -       init_MUTEX(&yaffs_context_lock);
135 +       mutex_init(&yaffs_context_lock);
136  
137         /* Install the proc_fs entries */
138         my_proc_entry = create_proc_entry("yaffs",