From a8c85d30af86a7431d85dee02d133d60dd386406 Mon Sep 17 00:00:00 2001 From: Simon Hughes Date: Tue, 14 Mar 2017 17:45:48 +0000 Subject: [PATCH] Fixing SDBlockDevice::size() and SPIFBlockDevice::size() to implement BlockDevice::size() const change. --- features/filesystem/sd/SDBlockDevice.cpp | 9 +++++---- features/filesystem/sd/SDBlockDevice.h | 2 +- features/filesystem/spif/SPIFBlockDevice.cpp | 2 +- features/filesystem/spif/SPIFBlockDevice.h | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/features/filesystem/sd/SDBlockDevice.cpp b/features/filesystem/sd/SDBlockDevice.cpp index a027c3008c..f7cf01e60e 100644 --- a/features/filesystem/sd/SDBlockDevice.cpp +++ b/features/filesystem/sd/SDBlockDevice.cpp @@ -341,11 +341,12 @@ bd_size_t SDBlockDevice::get_erase_size() const return 512; } -bd_size_t SDBlockDevice::size() +bd_size_t SDBlockDevice::size() const { - _lock.lock(); - bd_size_t sectors = _sectors; - _lock.unlock(); + bd_size_t sectors = 0; + if(_is_initialized) { + sectors = _sectors; + } return 512*sectors; } diff --git a/features/filesystem/sd/SDBlockDevice.h b/features/filesystem/sd/SDBlockDevice.h index 51afd64036..9d93e6c873 100644 --- a/features/filesystem/sd/SDBlockDevice.h +++ b/features/filesystem/sd/SDBlockDevice.h @@ -119,7 +119,7 @@ public: * * @return Size of the underlying device in bytes */ - virtual bd_size_t size(); + virtual bd_size_t size() const; /** Enable or disable debugging * diff --git a/features/filesystem/spif/SPIFBlockDevice.cpp b/features/filesystem/spif/SPIFBlockDevice.cpp index ec7da8f8c5..bbccdf06ec 100644 --- a/features/filesystem/spif/SPIFBlockDevice.cpp +++ b/features/filesystem/spif/SPIFBlockDevice.cpp @@ -342,7 +342,7 @@ bd_size_t SPIFBlockDevice::get_erase_size() const return SPIF_SE_SIZE; } -bd_size_t SPIFBlockDevice::size() +bd_size_t SPIFBlockDevice::size() const { return _size; } diff --git a/features/filesystem/spif/SPIFBlockDevice.h b/features/filesystem/spif/SPIFBlockDevice.h index 9b20294b35..8926f69762 100644 --- a/features/filesystem/spif/SPIFBlockDevice.h +++ b/features/filesystem/spif/SPIFBlockDevice.h @@ -130,7 +130,7 @@ public: * * @return Size of the underlying device in bytes */ - virtual bd_size_t size(); + virtual bd_size_t size() const; private: // Master side hardware