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"
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".
10 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
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(-)
17 --- a/drivers/mtd/ubi/block.c
18 +++ b/drivers/mtd/ubi/block.c
21 * LEB number = addressed byte / LEB size
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
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.
33 #include <linux/module.h>
34 @@ -374,7 +374,7 @@ static const struct block_device_operati
35 .getgeo = ubiblock_getgeo,
38 -int ubiblock_add(struct ubi_volume_info *vi)
39 +int ubiblock_create(struct ubi_volume_info *vi)
43 @@ -464,7 +464,7 @@ static void ubiblock_cleanup(struct ubib
47 -int ubiblock_del(struct ubi_volume_info *vi)
48 +int ubiblock_remove(struct ubi_volume_info *vi)
52 @@ -503,7 +503,8 @@ static void ubiblock_resize(struct ubi_v
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()'.
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:
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.
71 case UBI_VOLUME_REMOVED:
72 - ubiblock_del(&nt->vi);
73 + ubiblock_remove(&nt->vi);
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);
81 -static int __init ubiblock_attach_from_param(void)
82 +static int __init ubiblock_create_from_param(void)
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);
90 - ret = ubiblock_add(&vi);
91 + ret = ubiblock_create(&vi);
93 ubi_err("block: can't add '%s' volume, err=%d\n",
95 @@ -592,7 +593,7 @@ static int __init ubiblock_attach_from_p
99 -static void ubiblock_detach_all(void)
100 +static void ubiblock_remove_all(void)
102 struct ubiblock *next;
103 struct ubiblock *dev;
104 @@ -618,13 +619,13 @@ int __init ubiblock_init(void)
105 return ubiblock_major;
107 /* Attach block devices from 'block=' module param */
108 - ret = ubiblock_attach_from_param();
109 + ret = ubiblock_create_from_param();
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.
120 ret = ubi_register_volume_notifier(&ubiblock_notifier, 1);
122 @@ -633,14 +634,14 @@ int __init ubiblock_init(void)
125 unregister_blkdev(ubiblock_major, "ubiblock");
127 - ubiblock_detach_all();
129 + ubiblock_remove_all();
133 void __exit ubiblock_exit(void)
135 ubi_unregister_volume_notifier(&ubiblock_notifier);
136 - ubiblock_detach_all();
137 + ubiblock_remove_all();
138 unregister_blkdev(ubiblock_major, "ubiblock");
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;
145 ubi_get_volume_info(desc, &vi);
146 - err = ubiblock_add(&vi);
147 + err = ubiblock_create(&vi);
151 @@ -577,7 +577,7 @@ static long vol_cdev_ioctl(struct file *
152 struct ubi_volume_info vi;
154 ubi_get_volume_info(desc, &vi);
155 - err = ubiblock_del(&vi);
156 + err = ubiblock_remove(&vi);
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);
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)
179 +static inline int ubiblock_remove(struct ubi_volume_info *vi)