diff options
author | Joe Perches <joe@perches.com> | 2013-04-19 13:59:35 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2013-08-05 15:47:17 -0400 |
commit | a1c06609b37c304c58f6d1d3b8e987edaf3391f3 (patch) | |
tree | 7417c13bd7da0def1a262cb028501d3a2f42638c /drivers/mtd/devices/block2mtd.c | |
parent | 4b6ff7afe8ca356ac51e98a7e01997cc17669254 (diff) |
mtd: Convert logging messages
Use a more current logging style.
Convert homegrown ERROR/INFO macros to pr_<level>.
Convert homegrown parse_err macros to pr_err and
expand hidden flow control.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/devices/block2mtd.c')
-rw-r--r-- | drivers/mtd/devices/block2mtd.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index e081bfeaaf7d..5cb4c04726b2 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c | |||
@@ -6,6 +6,9 @@ | |||
6 | * | 6 | * |
7 | * Licence: GPL | 7 | * Licence: GPL |
8 | */ | 8 | */ |
9 | |||
10 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
11 | |||
9 | #include <linux/module.h> | 12 | #include <linux/module.h> |
10 | #include <linux/fs.h> | 13 | #include <linux/fs.h> |
11 | #include <linux/blkdev.h> | 14 | #include <linux/blkdev.h> |
@@ -18,10 +21,6 @@ | |||
18 | #include <linux/mount.h> | 21 | #include <linux/mount.h> |
19 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
20 | 23 | ||
21 | #define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args) | ||
22 | #define INFO(fmt, args...) printk(KERN_INFO "block2mtd: " fmt "\n" , ## args) | ||
23 | |||
24 | |||
25 | /* Info for the block device */ | 24 | /* Info for the block device */ |
26 | struct block2mtd_dev { | 25 | struct block2mtd_dev { |
27 | struct list_head list; | 26 | struct list_head list; |
@@ -84,7 +83,7 @@ static int block2mtd_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
84 | err = _block2mtd_erase(dev, from, len); | 83 | err = _block2mtd_erase(dev, from, len); |
85 | mutex_unlock(&dev->write_mutex); | 84 | mutex_unlock(&dev->write_mutex); |
86 | if (err) { | 85 | if (err) { |
87 | ERROR("erase failed err = %d", err); | 86 | pr_err("erase failed err = %d\n", err); |
88 | instr->state = MTD_ERASE_FAILED; | 87 | instr->state = MTD_ERASE_FAILED; |
89 | } else | 88 | } else |
90 | instr->state = MTD_ERASE_DONE; | 89 | instr->state = MTD_ERASE_DONE; |
@@ -239,13 +238,13 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) | |||
239 | #endif | 238 | #endif |
240 | 239 | ||
241 | if (IS_ERR(bdev)) { | 240 | if (IS_ERR(bdev)) { |
242 | ERROR("error: cannot open device %s", devname); | 241 | pr_err("error: cannot open device %s\n", devname); |
243 | goto devinit_err; | 242 | goto devinit_err; |
244 | } | 243 | } |
245 | dev->blkdev = bdev; | 244 | dev->blkdev = bdev; |
246 | 245 | ||
247 | if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) { | 246 | if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) { |
248 | ERROR("attempting to use an MTD device as a block device"); | 247 | pr_err("attempting to use an MTD device as a block device\n"); |
249 | goto devinit_err; | 248 | goto devinit_err; |
250 | } | 249 | } |
251 | 250 | ||
@@ -277,9 +276,10 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) | |||
277 | goto devinit_err; | 276 | goto devinit_err; |
278 | } | 277 | } |
279 | list_add(&dev->list, &blkmtd_device_list); | 278 | list_add(&dev->list, &blkmtd_device_list); |
280 | INFO("mtd%d: [%s] erase_size = %dKiB [%d]", dev->mtd.index, | 279 | pr_info("mtd%d: [%s] erase_size = %dKiB [%d]\n", |
281 | dev->mtd.name + strlen("block2mtd: "), | 280 | dev->mtd.index, |
282 | dev->mtd.erasesize >> 10, dev->mtd.erasesize); | 281 | dev->mtd.name + strlen("block2mtd: "), |
282 | dev->mtd.erasesize >> 10, dev->mtd.erasesize); | ||
283 | return dev; | 283 | return dev; |
284 | 284 | ||
285 | devinit_err: | 285 | devinit_err: |
@@ -339,17 +339,11 @@ static inline void kill_final_newline(char *str) | |||
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | #define parse_err(fmt, args...) do { \ | ||
343 | ERROR(fmt, ## args); \ | ||
344 | return 0; \ | ||
345 | } while (0) | ||
346 | |||
347 | #ifndef MODULE | 342 | #ifndef MODULE |
348 | static int block2mtd_init_called = 0; | 343 | static int block2mtd_init_called = 0; |
349 | static char block2mtd_paramline[80 + 12]; /* 80 for device, 12 for erase size */ | 344 | static char block2mtd_paramline[80 + 12]; /* 80 for device, 12 for erase size */ |
350 | #endif | 345 | #endif |
351 | 346 | ||
352 | |||
353 | static int block2mtd_setup2(const char *val) | 347 | static int block2mtd_setup2(const char *val) |
354 | { | 348 | { |
355 | char buf[80 + 12]; /* 80 for device, 12 for erase size */ | 349 | char buf[80 + 12]; /* 80 for device, 12 for erase size */ |
@@ -359,8 +353,10 @@ static int block2mtd_setup2(const char *val) | |||
359 | size_t erase_size = PAGE_SIZE; | 353 | size_t erase_size = PAGE_SIZE; |
360 | int i, ret; | 354 | int i, ret; |
361 | 355 | ||
362 | if (strnlen(val, sizeof(buf)) >= sizeof(buf)) | 356 | if (strnlen(val, sizeof(buf)) >= sizeof(buf)) { |
363 | parse_err("parameter too long"); | 357 | pr_err("parameter too long\n"); |
358 | return 0; | ||
359 | } | ||
364 | 360 | ||
365 | strcpy(str, val); | 361 | strcpy(str, val); |
366 | kill_final_newline(str); | 362 | kill_final_newline(str); |
@@ -368,20 +364,27 @@ static int block2mtd_setup2(const char *val) | |||
368 | for (i = 0; i < 2; i++) | 364 | for (i = 0; i < 2; i++) |
369 | token[i] = strsep(&str, ","); | 365 | token[i] = strsep(&str, ","); |
370 | 366 | ||
371 | if (str) | 367 | if (str) { |
372 | parse_err("too many arguments"); | 368 | pr_err("too many arguments\n"); |
369 | return 0; | ||
370 | } | ||
373 | 371 | ||
374 | if (!token[0]) | 372 | if (!token[0]) { |
375 | parse_err("no argument"); | 373 | pr_err("no argument\n"); |
374 | return 0; | ||
375 | } | ||
376 | 376 | ||
377 | name = token[0]; | 377 | name = token[0]; |
378 | if (strlen(name) + 1 > 80) | 378 | if (strlen(name) + 1 > 80) { |
379 | parse_err("device name too long"); | 379 | pr_err("device name too long\n"); |
380 | return 0; | ||
381 | } | ||
380 | 382 | ||
381 | if (token[1]) { | 383 | if (token[1]) { |
382 | ret = parse_num(&erase_size, token[1]); | 384 | ret = parse_num(&erase_size, token[1]); |
383 | if (ret) { | 385 | if (ret) { |
384 | parse_err("illegal erase size"); | 386 | pr_err("illegal erase size\n"); |
387 | return 0; | ||
385 | } | 388 | } |
386 | } | 389 | } |
387 | 390 | ||
@@ -444,8 +447,9 @@ static void block2mtd_exit(void) | |||
444 | struct block2mtd_dev *dev = list_entry(pos, typeof(*dev), list); | 447 | struct block2mtd_dev *dev = list_entry(pos, typeof(*dev), list); |
445 | block2mtd_sync(&dev->mtd); | 448 | block2mtd_sync(&dev->mtd); |
446 | mtd_device_unregister(&dev->mtd); | 449 | mtd_device_unregister(&dev->mtd); |
447 | INFO("mtd%d: [%s] removed", dev->mtd.index, | 450 | pr_info("mtd%d: [%s] removed\n", |
448 | dev->mtd.name + strlen("block2mtd: ")); | 451 | dev->mtd.index, |
452 | dev->mtd.name + strlen("block2mtd: ")); | ||
449 | list_del(&dev->list); | 453 | list_del(&dev->list); |
450 | block2mtd_free_device(dev); | 454 | block2mtd_free_device(dev); |
451 | } | 455 | } |