diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-17 10:37:26 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-26 12:15:17 -0500 |
commit | e73f4459d969bb266f03dd4cbe21bdba8cb2732c (patch) | |
tree | 5af7655da65f2c33f6ea4efdfaa8b0e0670d6aea /drivers/mtd/ubi/eba.c | |
parent | 9f961b57568960a150cc9781c52824c9093a0514 (diff) |
UBI: add UBI devices reference counting
This is one more step on the way to "removable" UBI devices. It
adds reference counting for UBI devices. Every time a volume on
this device is opened - the device's refcount is increased. It
is also increased if someone is reading any sysfs file of this
UBI device or of one of its volumes.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/eba.c')
-rw-r--r-- | drivers/mtd/ubi/eba.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index c94f475758de..85297cde4ac5 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c | |||
@@ -339,6 +339,7 @@ int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol, | |||
339 | { | 339 | { |
340 | int err, pnum, vol_id = vol->vol_id; | 340 | int err, pnum, vol_id = vol->vol_id; |
341 | 341 | ||
342 | ubi_assert(ubi->ref_count > 0); | ||
342 | ubi_assert(vol->ref_count > 0); | 343 | ubi_assert(vol->ref_count > 0); |
343 | 344 | ||
344 | if (ubi->ro_mode) | 345 | if (ubi->ro_mode) |
@@ -389,6 +390,7 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, | |||
389 | struct ubi_vid_hdr *vid_hdr; | 390 | struct ubi_vid_hdr *vid_hdr; |
390 | uint32_t uninitialized_var(crc); | 391 | uint32_t uninitialized_var(crc); |
391 | 392 | ||
393 | ubi_assert(ubi->ref_count > 0); | ||
392 | ubi_assert(vol->ref_count > 0); | 394 | ubi_assert(vol->ref_count > 0); |
393 | 395 | ||
394 | err = leb_read_lock(ubi, vol_id, lnum); | 396 | err = leb_read_lock(ubi, vol_id, lnum); |
@@ -614,6 +616,7 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, | |||
614 | int err, pnum, tries = 0, vol_id = vol->vol_id; | 616 | int err, pnum, tries = 0, vol_id = vol->vol_id; |
615 | struct ubi_vid_hdr *vid_hdr; | 617 | struct ubi_vid_hdr *vid_hdr; |
616 | 618 | ||
619 | ubi_assert(ubi->ref_count > 0); | ||
617 | ubi_assert(vol->ref_count > 0); | 620 | ubi_assert(vol->ref_count > 0); |
618 | 621 | ||
619 | if (ubi->ro_mode) | 622 | if (ubi->ro_mode) |
@@ -749,6 +752,7 @@ int ubi_eba_write_leb_st(struct ubi_device *ubi, struct ubi_volume *vol, | |||
749 | struct ubi_vid_hdr *vid_hdr; | 752 | struct ubi_vid_hdr *vid_hdr; |
750 | uint32_t crc; | 753 | uint32_t crc; |
751 | 754 | ||
755 | ubi_assert(ubi->ref_count > 0); | ||
752 | ubi_assert(vol->ref_count > 0); | 756 | ubi_assert(vol->ref_count > 0); |
753 | 757 | ||
754 | if (ubi->ro_mode) | 758 | if (ubi->ro_mode) |
@@ -865,6 +869,7 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, | |||
865 | struct ubi_vid_hdr *vid_hdr; | 869 | struct ubi_vid_hdr *vid_hdr; |
866 | uint32_t crc; | 870 | uint32_t crc; |
867 | 871 | ||
872 | ubi_assert(ubi->ref_count > 0); | ||
868 | ubi_assert(vol->ref_count > 0); | 873 | ubi_assert(vol->ref_count > 0); |
869 | 874 | ||
870 | if (ubi->ro_mode) | 875 | if (ubi->ro_mode) |