aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-03-04 05:00:26 -0500
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-03-04 06:52:33 -0500
commit4d283ee2517303afa54ad6cbd9342a2f748cf509 (patch)
tree20d97ac0b5528504fcea064382bd38d6f2432b8e /drivers/mtd/ubi
parent9d54c8a33eec78289b1b3f6e10874719c27ce0a7 (diff)
UBI: block: do not use term "attach"
We already use term attach/detach for UBI->MTD relations, let's not use this for UBI->ubiblock relations to avoid confusion. Just use 'create' and 'remove' instead. E.g., "create a R/O block device on top of a UBI volume". Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r--drivers/mtd/ubi/block.c39
-rw-r--r--drivers/mtd/ubi/cdev.c4
-rw-r--r--drivers/mtd/ubi/ubi.h14
3 files changed, 32 insertions, 25 deletions
diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index cea7d1cf9d04..6402e41e40b4 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -29,10 +29,10 @@
29 * 29 *
30 * LEB number = addressed byte / LEB size 30 * LEB number = addressed byte / LEB size
31 * 31 *
32 * This feature is compiled in the UBI core, and adds a new 'block' parameter 32 * This feature is compiled in the UBI core, and adds a 'block' parameter
33 * to allow early block device attaching. Runtime block attach/detach for UBI 33 * to allow early creation of block devices on top of UBI volumes. Runtime
34 * volumes is provided through two new UBI ioctls: UBI_IOCVOLATTBLK and 34 * block creation/removal for UBI volumes is provided through two UBI ioctls:
35 * UBI_IOCVOLDETBLK. 35 * UBI_IOCVOLATTBLK and UBI_IOCVOLDETBLK.
36 */ 36 */
37 37
38#include <linux/module.h> 38#include <linux/module.h>
@@ -374,7 +374,7 @@ static const struct block_device_operations ubiblock_ops = {
374 .getgeo = ubiblock_getgeo, 374 .getgeo = ubiblock_getgeo,
375}; 375};
376 376
377int ubiblock_add(struct ubi_volume_info *vi) 377int ubiblock_create(struct ubi_volume_info *vi)
378{ 378{
379 struct ubiblock *dev; 379 struct ubiblock *dev;
380 struct gendisk *gd; 380 struct gendisk *gd;
@@ -464,7 +464,7 @@ static void ubiblock_cleanup(struct ubiblock *dev)
464 put_disk(dev->gd); 464 put_disk(dev->gd);
465} 465}
466 466
467int ubiblock_del(struct ubi_volume_info *vi) 467int ubiblock_remove(struct ubi_volume_info *vi)
468{ 468{
469 struct ubiblock *dev; 469 struct ubiblock *dev;
470 470
@@ -503,7 +503,8 @@ static void ubiblock_resize(struct ubi_volume_info *vi)
503 503
504 /* 504 /*
505 * Need to lock the device list until we stop using the device, 505 * Need to lock the device list until we stop using the device,
506 * otherwise the device struct might get released in 'ubiblock_del()'. 506 * otherwise the device struct might get released in
507 * 'ubiblock_remove()'.
507 */ 508 */
508 mutex_lock(&devices_mutex); 509 mutex_lock(&devices_mutex);
509 dev = find_dev_nolock(vi->ubi_num, vi->vol_id); 510 dev = find_dev_nolock(vi->ubi_num, vi->vol_id);
@@ -528,12 +529,12 @@ static int ubiblock_notify(struct notifier_block *nb,
528 switch (notification_type) { 529 switch (notification_type) {
529 case UBI_VOLUME_ADDED: 530 case UBI_VOLUME_ADDED:
530 /* 531 /*
531 * We want to enforce explicit block device attaching for 532 * We want to enforce explicit block device creation for
532 * volumes, so when a volume is added we do nothing. 533 * volumes, so when a volume is added we do nothing.
533 */ 534 */
534 break; 535 break;
535 case UBI_VOLUME_REMOVED: 536 case UBI_VOLUME_REMOVED:
536 ubiblock_del(&nt->vi); 537 ubiblock_remove(&nt->vi);
537 break; 538 break;
538 case UBI_VOLUME_RESIZED: 539 case UBI_VOLUME_RESIZED:
539 ubiblock_resize(&nt->vi); 540 ubiblock_resize(&nt->vi);
@@ -561,7 +562,7 @@ open_volume_desc(const char *name, int ubi_num, int vol_id)
561 return ubi_open_volume(ubi_num, vol_id, UBI_READONLY); 562 return ubi_open_volume(ubi_num, vol_id, UBI_READONLY);
562} 563}
563 564
564static int __init ubiblock_attach_from_param(void) 565static int __init ubiblock_create_from_param(void)
565{ 566{
566 int i, ret; 567 int i, ret;
567 struct ubiblock_param *p; 568 struct ubiblock_param *p;
@@ -582,7 +583,7 @@ static int __init ubiblock_attach_from_param(void)
582 ubi_get_volume_info(desc, &vi); 583 ubi_get_volume_info(desc, &vi);
583 ubi_close_volume(desc); 584 ubi_close_volume(desc);
584 585
585 ret = ubiblock_add(&vi); 586 ret = ubiblock_create(&vi);
586 if (ret) { 587 if (ret) {
587 ubi_err("block: can't add '%s' volume, err=%d\n", 588 ubi_err("block: can't add '%s' volume, err=%d\n",
588 vi.name, ret); 589 vi.name, ret);
@@ -592,7 +593,7 @@ static int __init ubiblock_attach_from_param(void)
592 return ret; 593 return ret;
593} 594}
594 595
595static void ubiblock_detach_all(void) 596static void ubiblock_remove_all(void)
596{ 597{
597 struct ubiblock *next; 598 struct ubiblock *next;
598 struct ubiblock *dev; 599 struct ubiblock *dev;
@@ -618,13 +619,13 @@ int __init ubiblock_init(void)
618 return ubiblock_major; 619 return ubiblock_major;
619 620
620 /* Attach block devices from 'block=' module param */ 621 /* Attach block devices from 'block=' module param */
621 ret = ubiblock_attach_from_param(); 622 ret = ubiblock_create_from_param();
622 if (ret) 623 if (ret)
623 goto err_detach; 624 goto err_remove;
624 625
625 /* 626 /*
626 * Block devices needs to be attached to volumes explicitly 627 * Block devices are only created upon user requests, so we ignore
627 * upon user request. So we ignore existing volumes. 628 * existing volumes.
628 */ 629 */
629 ret = ubi_register_volume_notifier(&ubiblock_notifier, 1); 630 ret = ubi_register_volume_notifier(&ubiblock_notifier, 1);
630 if (ret) 631 if (ret)
@@ -633,14 +634,14 @@ int __init ubiblock_init(void)
633 634
634err_unreg: 635err_unreg:
635 unregister_blkdev(ubiblock_major, "ubiblock"); 636 unregister_blkdev(ubiblock_major, "ubiblock");
636err_detach: 637err_remove:
637 ubiblock_detach_all(); 638 ubiblock_remove_all();
638 return ret; 639 return ret;
639} 640}
640 641
641void __exit ubiblock_exit(void) 642void __exit ubiblock_exit(void)
642{ 643{
643 ubi_unregister_volume_notifier(&ubiblock_notifier); 644 ubi_unregister_volume_notifier(&ubiblock_notifier);
644 ubiblock_detach_all(); 645 ubiblock_remove_all();
645 unregister_blkdev(ubiblock_major, "ubiblock"); 646 unregister_blkdev(ubiblock_major, "ubiblock");
646} 647}
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 39d377489c29..11c847349642 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -567,7 +567,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
567 struct ubi_volume_info vi; 567 struct ubi_volume_info vi;
568 568
569 ubi_get_volume_info(desc, &vi); 569 ubi_get_volume_info(desc, &vi);
570 err = ubiblock_add(&vi); 570 err = ubiblock_create(&vi);
571 break; 571 break;
572 } 572 }
573 573
@@ -577,7 +577,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
577 struct ubi_volume_info vi; 577 struct ubi_volume_info vi;
578 578
579 ubi_get_volume_info(desc, &vi); 579 ubi_get_volume_info(desc, &vi);
580 err = ubiblock_del(&vi); 580 err = ubiblock_remove(&vi);
581 break; 581 break;
582 } 582 }
583 583
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index e76ff98440a4..2e588a9809c9 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -868,13 +868,19 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
868#ifdef CONFIG_MTD_UBI_BLOCK 868#ifdef CONFIG_MTD_UBI_BLOCK
869int ubiblock_init(void); 869int ubiblock_init(void);
870void ubiblock_exit(void); 870void ubiblock_exit(void);
871int ubiblock_add(struct ubi_volume_info *vi); 871int ubiblock_create(struct ubi_volume_info *vi);
872int ubiblock_del(struct ubi_volume_info *vi); 872int ubiblock_remove(struct ubi_volume_info *vi);
873#else 873#else
874static inline int ubiblock_init(void) { return 0; } 874static inline int ubiblock_init(void) { return 0; }
875static inline void ubiblock_exit(void) {} 875static inline void ubiblock_exit(void) {}
876static inline int ubiblock_add(struct ubi_volume_info *vi) { return -ENOTTY; } 876static inline int ubiblock_create(struct ubi_volume_info *vi)
877static inline int ubiblock_del(struct ubi_volume_info *vi) { return -ENOTTY; } 877{
878 return -ENOTTY;
879}
880static inline int ubiblock_remove(struct ubi_volume_info *vi)
881{
882 return -ENOTTY;
883}
878#endif 884#endif
879 885
880 886