bcbb92c6b2eb5c795e9cd300aa6a1454be4078f2
[openwrt/openwrt.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 diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
18 index cea7d1c..6402e41 100644
19 --- a/drivers/mtd/ubi/block.c
20 +++ b/drivers/mtd/ubi/block.c
21 @@ -29,10 +29,10 @@
22 *
23 * LEB number = addressed byte / LEB size
24 *
25 - * This feature is compiled in the UBI core, and adds a new 'block' parameter
26 - * to allow early block device attaching. Runtime block attach/detach for UBI
27 - * volumes is provided through two new UBI ioctls: UBI_IOCVOLATTBLK and
28 - * UBI_IOCVOLDETBLK.
29 + * This feature is compiled in the UBI core, and adds a 'block' parameter
30 + * to allow early creation of block devices on top of UBI volumes. Runtime
31 + * block creation/removal for UBI volumes is provided through two UBI ioctls:
32 + * UBI_IOCVOLATTBLK and UBI_IOCVOLDETBLK.
33 */
34
35 #include <linux/module.h>
36 @@ -374,7 +374,7 @@ static const struct block_device_operations ubiblock_ops = {
37 .getgeo = ubiblock_getgeo,
38 };
39
40 -int ubiblock_add(struct ubi_volume_info *vi)
41 +int ubiblock_create(struct ubi_volume_info *vi)
42 {
43 struct ubiblock *dev;
44 struct gendisk *gd;
45 @@ -464,7 +464,7 @@ static void ubiblock_cleanup(struct ubiblock *dev)
46 put_disk(dev->gd);
47 }
48
49 -int ubiblock_del(struct ubi_volume_info *vi)
50 +int ubiblock_remove(struct ubi_volume_info *vi)
51 {
52 struct ubiblock *dev;
53
54 @@ -503,7 +503,8 @@ static void ubiblock_resize(struct ubi_volume_info *vi)
55
56 /*
57 * Need to lock the device list until we stop using the device,
58 - * otherwise the device struct might get released in 'ubiblock_del()'.
59 + * otherwise the device struct might get released in
60 + * 'ubiblock_remove()'.
61 */
62 mutex_lock(&devices_mutex);
63 dev = find_dev_nolock(vi->ubi_num, vi->vol_id);
64 @@ -528,12 +529,12 @@ static int ubiblock_notify(struct notifier_block *nb,
65 switch (notification_type) {
66 case UBI_VOLUME_ADDED:
67 /*
68 - * We want to enforce explicit block device attaching for
69 + * We want to enforce explicit block device creation for
70 * volumes, so when a volume is added we do nothing.
71 */
72 break;
73 case UBI_VOLUME_REMOVED:
74 - ubiblock_del(&nt->vi);
75 + ubiblock_remove(&nt->vi);
76 break;
77 case UBI_VOLUME_RESIZED:
78 ubiblock_resize(&nt->vi);
79 @@ -561,7 +562,7 @@ open_volume_desc(const char *name, int ubi_num, int vol_id)
80 return ubi_open_volume(ubi_num, vol_id, UBI_READONLY);
81 }
82
83 -static int __init ubiblock_attach_from_param(void)
84 +static int __init ubiblock_create_from_param(void)
85 {
86 int i, ret;
87 struct ubiblock_param *p;
88 @@ -582,7 +583,7 @@ static int __init ubiblock_attach_from_param(void)
89 ubi_get_volume_info(desc, &vi);
90 ubi_close_volume(desc);
91
92 - ret = ubiblock_add(&vi);
93 + ret = ubiblock_create(&vi);
94 if (ret) {
95 ubi_err("block: can't add '%s' volume, err=%d\n",
96 vi.name, ret);
97 @@ -592,7 +593,7 @@ static int __init ubiblock_attach_from_param(void)
98 return ret;
99 }
100
101 -static void ubiblock_detach_all(void)
102 +static void ubiblock_remove_all(void)
103 {
104 struct ubiblock *next;
105 struct ubiblock *dev;
106 @@ -618,13 +619,13 @@ int __init ubiblock_init(void)
107 return ubiblock_major;
108
109 /* Attach block devices from 'block=' module param */
110 - ret = ubiblock_attach_from_param();
111 + ret = ubiblock_create_from_param();
112 if (ret)
113 - goto err_detach;
114 + goto err_remove;
115
116 /*
117 - * Block devices needs to be attached to volumes explicitly
118 - * upon user request. So we ignore existing volumes.
119 + * Block devices are only created upon user requests, so we ignore
120 + * existing volumes.
121 */
122 ret = ubi_register_volume_notifier(&ubiblock_notifier, 1);
123 if (ret)
124 @@ -633,14 +634,14 @@ int __init ubiblock_init(void)
125
126 err_unreg:
127 unregister_blkdev(ubiblock_major, "ubiblock");
128 -err_detach:
129 - ubiblock_detach_all();
130 +err_remove:
131 + ubiblock_remove_all();
132 return ret;
133 }
134
135 void __exit ubiblock_exit(void)
136 {
137 ubi_unregister_volume_notifier(&ubiblock_notifier);
138 - ubiblock_detach_all();
139 + ubiblock_remove_all();
140 unregister_blkdev(ubiblock_major, "ubiblock");
141 }
142 diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
143 index 39d3774..11c8473 100644
144 --- a/drivers/mtd/ubi/cdev.c
145 +++ b/drivers/mtd/ubi/cdev.c
146 @@ -567,7 +567,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
147 struct ubi_volume_info vi;
148
149 ubi_get_volume_info(desc, &vi);
150 - err = ubiblock_add(&vi);
151 + err = ubiblock_create(&vi);
152 break;
153 }
154
155 @@ -577,7 +577,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
156 struct ubi_volume_info vi;
157
158 ubi_get_volume_info(desc, &vi);
159 - err = ubiblock_del(&vi);
160 + err = ubiblock_remove(&vi);
161 break;
162 }
163
164 diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
165 index e76ff98..2e588a9 100644
166 --- a/drivers/mtd/ubi/ubi.h
167 +++ b/drivers/mtd/ubi/ubi.h
168 @@ -868,13 +868,19 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
169 #ifdef CONFIG_MTD_UBI_BLOCK
170 int ubiblock_init(void);
171 void ubiblock_exit(void);
172 -int ubiblock_add(struct ubi_volume_info *vi);
173 -int ubiblock_del(struct ubi_volume_info *vi);
174 +int ubiblock_create(struct ubi_volume_info *vi);
175 +int ubiblock_remove(struct ubi_volume_info *vi);
176 #else
177 static inline int ubiblock_init(void) { return 0; }
178 static inline void ubiblock_exit(void) {}
179 -static inline int ubiblock_add(struct ubi_volume_info *vi) { return -ENOTTY; }
180 -static inline int ubiblock_del(struct ubi_volume_info *vi) { return -ENOTTY; }
181 +static inline int ubiblock_create(struct ubi_volume_info *vi)
182 +{
183 + return -ENOTTY;
184 +}
185 +static inline int ubiblock_remove(struct ubi_volume_info *vi)
186 +{
187 + return -ENOTTY;
188 +}
189 #endif
190
191
192 --
193 1.9.2
194