Skip to content

Commit

Permalink
AP_Filesystem: littlefs: drop singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
tpwrules authored and peterbarker committed Feb 17, 2025
1 parent ca3c2c7 commit ec7ece3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 34 deletions.
24 changes: 0 additions & 24 deletions libraries/AP_Filesystem/AP_Filesystem_FlashMemory_LittleFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ static int lfs_flags_from_flags(int flags);

const extern AP_HAL::HAL& hal;

AP_Filesystem_FlashMemory_LittleFS* AP_Filesystem_FlashMemory_LittleFS::singleton;

AP_Filesystem_FlashMemory_LittleFS::AP_Filesystem_FlashMemory_LittleFS()
{
if (singleton) {
AP_HAL::panic("Too many AP_Filesystem_FlashMemory_LittleFS instances");
}
singleton = this;
}

int AP_Filesystem_FlashMemory_LittleFS::open(const char *pathname, int flags, bool allow_absolute_path)
{
FS_CHECK_ALLOWED(-1);
Expand Down Expand Up @@ -1260,18 +1250,4 @@ static int lfs_flags_from_flags(int flags)
return outflags;
}

// get_singleton for access from logging layer
AP_Filesystem_FlashMemory_LittleFS *AP_Filesystem_FlashMemory_LittleFS::get_singleton(void)
{
return singleton;
}

namespace AP
{
AP_Filesystem_FlashMemory_LittleFS &littlefs()
{
return *AP_Filesystem_FlashMemory_LittleFS::get_singleton();
}
}

#endif // AP_FILESYSTEM_LITTLEFS_ENABLED
10 changes: 0 additions & 10 deletions libraries/AP_Filesystem/AP_Filesystem_FlashMemory_LittleFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
class AP_Filesystem_FlashMemory_LittleFS : public AP_Filesystem_Backend
{
public:
AP_Filesystem_FlashMemory_LittleFS();
// functions that closely match the equivalent posix calls
int open(const char *fname, int flags, bool allow_absolute_paths = false) override;
int close(int fd) override;
Expand Down Expand Up @@ -63,9 +62,6 @@ class AP_Filesystem_FlashMemory_LittleFS : public AP_Filesystem_Backend
int _flashmem_erase(lfs_block_t block);
int _flashmem_sync();

// get_singleton for scripting
static AP_Filesystem_FlashMemory_LittleFS *get_singleton(void);

private:
// Semaphore to protect against concurrent accesses to fs
HAL_Semaphore fs_sem;
Expand Down Expand Up @@ -108,8 +104,6 @@ class AP_Filesystem_FlashMemory_LittleFS : public AP_Filesystem_Backend
bool use_32bit_address;
FormatStatus format_status;

static AP_Filesystem_FlashMemory_LittleFS* singleton;

int allocate_fd();
int free_fd(int fd);
void free_all_fds();
Expand All @@ -130,8 +124,4 @@ class AP_Filesystem_FlashMemory_LittleFS : public AP_Filesystem_Backend
void mark_dead();
};

namespace AP {
AP_Filesystem_FlashMemory_LittleFS &littlefs();
};

#endif // #if AP_FILESYSTEM_LITTLEFS_ENABLED

0 comments on commit ec7ece3

Please sign in to comment.