e93446184d8c0f7f033c06ed248589509ef20006
[openwrt/staging/luka.git] / target / linux / generic / patches-3.14 / 041-UBI-block-do-not-use-term-attach.patch
1 From 4d283ee2517303afa54ad6cbd9342a2f748cf509 Mon Sep 17 00:00:00 2001
2 From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
3 Date: Tue, 4 Mar 2014 12:00:26 +0200
4 Subject: [PATCH] UBI: block: do not use term "attach"
5
6 We already use term attach/detach for UBI->MTD relations, let's not use this
7 for UBI->ubiblock relations to avoid confusion. Just use 'create' and 'remove'
8 instead. E.g., "create a R/O block device on top of a UBI volume".
9
10 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
11 ---
12 drivers/mtd/ubi/block.c | 39 ++++++++++++++++++++-------------------
13 drivers/mtd/ubi/cdev.c | 4 ++--
14 drivers/mtd/ubi/ubi.h | 14 ++++++++++----
15 3 files changed, 32 insertions(+), 25 deletions(-)
16
17 --- a/drivers/mtd/ubi/block.c
18 +++ b/drivers/mtd/ubi/block.c
19 @@ -29,10 +29,10 @@
20 *
21 * LEB number = addressed byte / LEB size
22 *
23 - * This feature is compiled in the UBI core, and adds a new 'block' parameter
24 - * to allow early block device attaching. Runtime block attach/detach for UBI
25 - * volumes is provided through two new UBI ioctls: UBI_IOCVOLATTBLK and
26 - * UBI_IOCVOLDETBLK.
27 + * This feature is compiled in the UBI core, and adds a 'block' parameter
28 + * to allow early creation of block devices on top of UBI volumes. Runtime
29 + * block creation/removal for UBI volumes is provided through two UBI ioctls:
30 + * UBI_IOCVOLATTBLK and UBI_IOCVOLDETBLK.
31 */
32
33 #include <linux/module.h>
34 @@ -374,7 +374,7 @@ static const struct block_device_operati
35 .getgeo = ubiblock_getgeo,
36 };
37
38 -int ubiblock_add(struct ubi_volume_info *vi)
39 +int ubiblock_create(struct ubi_volume_info *vi)
40 {
41 struct ubiblock *dev;
42 struct gendisk *gd;
43 @@ -464,7 +464,7 @@ static void ubiblock_cleanup(struct ubib
44 put_disk(dev->gd);
45 }
46
47 -int ubiblock_del(struct ubi_volume_info *vi)
48 +int ubiblock_remove(struct ubi_volume_info *vi)
49 {
50 struct ubiblock *dev;
51
52 @@ -503,7 +503,8 @@ static void ubiblock_resize(struct ubi_v
53
54 /*
55 * Need to lock the device list until we stop using the device,
56 - * otherwise the device struct might get released in 'ubiblock_del()'.
57 + * otherwise the device struct might get released in
58 + * 'ubiblock_remove()'.
59 */
60 mutex_lock(&devices_mutex);
61 dev = find_dev_nolock(vi->ubi_num, vi->vol_id);
62 @@ -528,12 +529,12 @@ static int ubiblock_notify(struct notifi
63 switch (notification_type) {
64 case UBI_VOLUME_ADDED:
65 /*
66 - * We want to enforce explicit block device attaching for
67 + * We want to enforce explicit block device creation for
68 * volumes, so when a volume is added we do nothing.
69 */
70 break;
71 case UBI_VOLUME_REMOVED:
72 - ubiblock_del(&nt->vi);
73 + ubiblock_remove(&nt->vi);
74 break;
75 case UBI_VOLUME_RESIZED:
76 ubiblock_resize(&nt->vi);
77 @@ -561,7 +562,7 @@ open_volume_desc(const char *name, int u
78 return ubi_open_volume(ubi_num, vol_id, UBI_READONLY);
79 }
80
81 -static int __init ubiblock_attach_from_param(void)
82 +static int __init ubiblock_create_from_param(void)
83 {
84 int i, ret;
85 struct ubiblock_param *p;
86 @@ -582,7 +583,7 @@ static int __init ubiblock_attach_from_p
87 ubi_get_volume_info(desc, &vi);
88 ubi_close_volume(desc);
89
90 - ret = ubiblock_add(&vi);
91 + ret = ubiblock_create(&vi);
92 if (ret) {
93 ubi_err("block: can't add '%s' volume, err=%d\n",
94 vi.name, ret);
95 @@ -592,7 +593,7 @@ static int __init ubiblock_attach_from_p
96 return ret;
97 }
98
99 -static void ubiblock_detach_all(void)
100 +static void ubiblock_remove_all(void)
101 {
102 struct ubiblock *next;
103 struct ubiblock *dev;
104 @@ -618,13 +619,13 @@ int __init ubiblock_init(void)
105 return ubiblock_major;
106
107 /* Attach block devices from 'block=' module param */
108 - ret = ubiblock_attach_from_param();
109 + ret = ubiblock_create_from_param();
110 if (ret)
111 - goto err_detach;
112 + goto err_remove;
113
114 /*
115 - * Block devices needs to be attached to volumes explicitly
116 - * upon user request. So we ignore existing volumes.
117 + * Block devices are only created upon user requests, so we ignore
118 + * existing volumes.
119 */
120 ret = ubi_register_volume_notifier(&ubiblock_notifier, 1);
121 if (ret)
122 @@ -633,14 +634,14 @@ int __init ubiblock_init(void)
123
124 err_unreg:
125 unregister_blkdev(ubiblock_major, "ubiblock");
126 -err_detach:
127 - ubiblock_detach_all();
128 +err_remove:
129 + ubiblock_remove_all();
130 return ret;
131 }
132
133 void __exit ubiblock_exit(void)
134 {
135 ubi_unregister_volume_notifier(&ubiblock_notifier);
136 - ubiblock_detach_all();
137 + ubiblock_remove_all();
138 unregister_blkdev(ubiblock_major, "ubiblock");
139 }
140 --- a/drivers/mtd/ubi/cdev.c
141 +++ b/drivers/mtd/ubi/cdev.c
142 @@ -567,7 +567,7 @@ static long vol_cdev_ioctl(struct file *
143 struct ubi_volume_info vi;
144
145 ubi_get_volume_info(desc, &vi);
146 - err = ubiblock_add(&vi);
147 + err = ubiblock_create(&vi);
148 break;
149 }
150
151 @@ -577,7 +577,7 @@ static long vol_cdev_ioctl(struct file *
152 struct ubi_volume_info vi;
153
154 ubi_get_volume_info(desc, &vi);
155 - err = ubiblock_del(&vi);
156 + err = ubiblock_remove(&vi);
157 break;
158 }
159
160 --- a/drivers/mtd/ubi/ubi.h
161 +++ b/drivers/mtd/ubi/ubi.h
162 @@ -868,13 +868,19 @@ int ubi_scan_fastmap(struct ubi_device *
163 #ifdef CONFIG_MTD_UBI_BLOCK
164 int ubiblock_init(void);
165 void ubiblock_exit(void);
166 -int ubiblock_add(struct ubi_volume_info *vi);
167 -int ubiblock_del(struct ubi_volume_info *vi);
168 +int ubiblock_create(struct ubi_volume_info *vi);
169 +int ubiblock_remove(struct ubi_volume_info *vi);
170 #else
171 static inline int ubiblock_init(void) { return 0; }
172 static inline void ubiblock_exit(void) {}
173 -static inline int ubiblock_add(struct ubi_volume_info *vi) { return -ENOTTY; }
174 -static inline int ubiblock_del(struct ubi_volume_info *vi) { return -ENOTTY; }
175 +static inline int ubiblock_create(struct ubi_volume_info *vi)
176 +{
177 + return -ENOTTY;
178 +}
179 +static inline int ubiblock_remove(struct ubi_volume_info *vi)
180 +{
181 + return -ENOTTY;
182 +}
183 #endif
184
185