33#include < Platform/RepRap.h>
44#include < ObjectModel/ObjectModel.h>
55
6- #if HAS_MASS_STORAGE
7-
8- // Check that the LFN configuration in FatFS is sufficient
9- static_assert (FF_MAX_LFN >= MaxFilenameLength, " FF_MAX_LFN too small" );
10-
11- #endif
126
137#if HAS_SBC_INTERFACE
148# include < SBC/SbcInterface.h>
@@ -18,9 +12,14 @@ static_assert(FF_MAX_LFN >= MaxFilenameLength, "FF_MAX_LFN too small");
1812# include < GCodes/GCodeBuffer/GCodeBuffer.h>
1913#endif
2014
15+ #if HAS_MASS_STORAGE
2116#include < Libraries/Fatfs/ff.h> // for type definitions
2217#include < Libraries/Fatfs/diskio.h>
2318
19+ // Check that the LFN configuration in FatFS is sufficient
20+ static_assert (FF_MAX_LFN >= MaxFilenameLength, " FF_MAX_LFN too small" );
21+ #endif
22+
2423#include " SdCardVolume.h"
2524
2625#if SUPPORT_USB_DRIVE
@@ -39,7 +38,6 @@ static_assert(FF_VOLUMES >= NumSdCards);
3938// No function in here should be called when the caller already owns the shared SPI mutex.
4039
4140#if HAS_MASS_STORAGE
42-
4341// Private data and methods
4442
4543# if SAME70
@@ -877,57 +875,51 @@ bool MassStorage::IsVolumeDetected(size_t slot) noexcept
877875// This may only be called to mount one volume at a time.
878876GCodeResult MassStorage::Mount (size_t slot, const StringRef& reply, bool reportSuccess) noexcept
879877{
880- if (slot >= GetNumVolumes ())
878+ if (slot >= GetNumVolumes ()
879+ #if HAS_MASS_STORAGE
880+ || !storageVolumes[slot]->IsUseable (reply)
881+ #endif
882+ )
881883 {
882884 reply.copy (" Volume slot out of range" );
883885 return GCodeResult::error;
884886 }
885887
886- if (!storageVolumes[slot]->IsUseable (reply))
887- {
888- return GCodeResult::error;
889- }
890-
891- GCodeResult res = GCodeResult::ok;
892-
893888# if HAS_MASS_STORAGE
894889 MutexLocker lock (fsMutex);
895- res = storageVolumes[slot]->Mount (reply, reportSuccess);
890+ return storageVolumes[slot]->Mount (reply, reportSuccess);
891+ #else
892+ return GCodeResult::ok;
896893#endif
897-
898- return res;
899894}
900895
901896// Unmount the volume on specified slot, returning true if done, false if needs to be called again.
902897// If an error occurs, return true with the error message in 'reply'.
903898GCodeResult MassStorage::Unmount (size_t slot, const StringRef& reply) noexcept
904899{
905- if (slot >= GetNumVolumes ())
900+ if (slot >= GetNumVolumes ()
901+ #if HAS_MASS_STORAGE
902+ || !storageVolumes[slot]->IsUseable (reply)
903+ #endif
904+ )
906905 {
907906 reply.copy (" Volume slot out of range" );
908907 return GCodeResult::error;
909908 }
910909
911- if (!storageVolumes[slot]->IsUseable (reply))
912- {
913- return GCodeResult::error;
914- }
915-
916- GCodeResult res = GCodeResult::ok;
917-
918910# if HAS_MASS_STORAGE
919911 MutexLocker lock (fsMutex);
920- res = storageVolumes[slot]->Unmount (reply);
912+ return storageVolumes[slot]->Unmount (reply);
913+ #else
914+ return GCodeResult::ok;
921915#endif
922-
923- return res;
924916}
925917
926918bool MassStorage::IsDriveMounted (size_t slot) noexcept
927919{
928- return slot < GetNumVolumes () && storageVolumes[slot]-> IsUseable ()
920+ return slot < GetNumVolumes ()
929921#if HAS_MASS_STORAGE
930- && storageVolumes[slot]->IsMounted ()
922+ && storageVolumes[slot]->IsUseable () && storageVolumes[slot]-> IsMounted ()
931923#endif
932924 ;
933925}
@@ -1038,7 +1030,7 @@ void MassStorage::RecordSimulationTime(const char *printingFilePath, uint32_t si
10381030// Get information about the volume and interface speed on the specified slot
10391031MassStorage::InfoResult MassStorage::GetVolumeInfo (size_t slot, SdCardReturnedInfo& returnedInfo) noexcept
10401032{
1041- if (slot >= GetNumVolumes () && storageVolumes[slot]->IsUseable ())
1033+ if (slot >= GetNumVolumes () || ! storageVolumes[slot]->IsUseable ())
10421034 {
10431035 return InfoResult::badSlot;
10441036 }
@@ -1066,7 +1058,6 @@ const ObjectModel * MassStorage::GetVolume(size_t slot) noexcept
10661058}
10671059# endif
10681060
1069- #endif
10701061
10711062// Functions called by FatFS to acquire/release mutual exclusion
10721063extern " C"
@@ -1124,4 +1115,7 @@ extern "C"
11241115 }
11251116}
11261117
1118+ #endif
1119+
1120+
11271121// End
0 commit comments