diff options
author | Ezequiel Garcia <elezegarcia@gmail.com> | 2012-11-28 07:18:30 -0500 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-12-10 06:38:59 -0500 |
commit | eab737722ed6a5638f6251e83f0d293c2ffe549f (patch) | |
tree | ccac47deaa15cf48608352e73ded2dcf387c2737 /drivers/mtd/ubi/debug.c | |
parent | 64575574f26d7969713ede9bde750c979da4037e (diff) |
UBI: embed ubi_debug_info field in ubi_device struct
ubi_debug_info struct was dynamically allocated which
is always suboptimal, for it tends to fragment memory
and make the code error-prone.
Fix this by embedding it in ubi_device struct.
Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/ubi/debug.c')
-rw-r--r-- | drivers/mtd/ubi/debug.c | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index 26908a59506b..63cb1d7236ce 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c | |||
@@ -217,32 +217,6 @@ void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req) | |||
217 | pr_err("\t1st 16 characters of name: %s\n", nm); | 217 | pr_err("\t1st 16 characters of name: %s\n", nm); |
218 | } | 218 | } |
219 | 219 | ||
220 | /** | ||
221 | * ubi_debugging_init_dev - initialize debugging for an UBI device. | ||
222 | * @ubi: UBI device description object | ||
223 | * | ||
224 | * This function initializes debugging-related data for UBI device @ubi. | ||
225 | * Returns zero in case of success and a negative error code in case of | ||
226 | * failure. | ||
227 | */ | ||
228 | int ubi_debugging_init_dev(struct ubi_device *ubi) | ||
229 | { | ||
230 | ubi->dbg = kzalloc(sizeof(struct ubi_debug_info), GFP_KERNEL); | ||
231 | if (!ubi->dbg) | ||
232 | return -ENOMEM; | ||
233 | |||
234 | return 0; | ||
235 | } | ||
236 | |||
237 | /** | ||
238 | * ubi_debugging_exit_dev - free debugging data for an UBI device. | ||
239 | * @ubi: UBI device description object | ||
240 | */ | ||
241 | void ubi_debugging_exit_dev(struct ubi_device *ubi) | ||
242 | { | ||
243 | kfree(ubi->dbg); | ||
244 | } | ||
245 | |||
246 | /* | 220 | /* |
247 | * Root directory for UBI stuff in debugfs. Contains sub-directories which | 221 | * Root directory for UBI stuff in debugfs. Contains sub-directories which |
248 | * contain the stuff specific to particular UBI devices. | 222 | * contain the stuff specific to particular UBI devices. |
@@ -295,7 +269,7 @@ static ssize_t dfs_file_read(struct file *file, char __user *user_buf, | |||
295 | ubi = ubi_get_device(ubi_num); | 269 | ubi = ubi_get_device(ubi_num); |
296 | if (!ubi) | 270 | if (!ubi) |
297 | return -ENODEV; | 271 | return -ENODEV; |
298 | d = ubi->dbg; | 272 | d = &ubi->dbg; |
299 | 273 | ||
300 | if (dent == d->dfs_chk_gen) | 274 | if (dent == d->dfs_chk_gen) |
301 | val = d->chk_gen; | 275 | val = d->chk_gen; |
@@ -341,7 +315,7 @@ static ssize_t dfs_file_write(struct file *file, const char __user *user_buf, | |||
341 | ubi = ubi_get_device(ubi_num); | 315 | ubi = ubi_get_device(ubi_num); |
342 | if (!ubi) | 316 | if (!ubi) |
343 | return -ENODEV; | 317 | return -ENODEV; |
344 | d = ubi->dbg; | 318 | d = &ubi->dbg; |
345 | 319 | ||
346 | buf_size = min_t(size_t, count, (sizeof(buf) - 1)); | 320 | buf_size = min_t(size_t, count, (sizeof(buf) - 1)); |
347 | if (copy_from_user(buf, user_buf, buf_size)) { | 321 | if (copy_from_user(buf, user_buf, buf_size)) { |
@@ -398,7 +372,7 @@ int ubi_debugfs_init_dev(struct ubi_device *ubi) | |||
398 | unsigned long ubi_num = ubi->ubi_num; | 372 | unsigned long ubi_num = ubi->ubi_num; |
399 | const char *fname; | 373 | const char *fname; |
400 | struct dentry *dent; | 374 | struct dentry *dent; |
401 | struct ubi_debug_info *d = ubi->dbg; | 375 | struct ubi_debug_info *d = &ubi->dbg; |
402 | 376 | ||
403 | if (!IS_ENABLED(CONFIG_DEBUG_FS)) | 377 | if (!IS_ENABLED(CONFIG_DEBUG_FS)) |
404 | return 0; | 378 | return 0; |
@@ -471,5 +445,5 @@ out: | |||
471 | void ubi_debugfs_exit_dev(struct ubi_device *ubi) | 445 | void ubi_debugfs_exit_dev(struct ubi_device *ubi) |
472 | { | 446 | { |
473 | if (IS_ENABLED(CONFIG_DEBUG_FS)) | 447 | if (IS_ENABLED(CONFIG_DEBUG_FS)) |
474 | debugfs_remove_recursive(ubi->dbg->dfs_dir); | 448 | debugfs_remove_recursive(ubi->dbg.dfs_dir); |
475 | } | 449 | } |