Cleanup some unnecessary HAVE_HOTSWAP uses

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Mon, 8 Jun 2026 10:32:50 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 722e4f10ad8e03b1236fa58f910851894a5d07e4
Author: Aidan MacDonald <[email protected]>
Date:   Sat Jun 6 15:24:03 2026 +0100

    Cleanup some unnecessary HAVE_HOTSWAP uses
    
    Always define storage_removable() and storage_present() so
    that ifdefs are unnecessary. They were already defined as
    constant for the CONFIG_STORAGE_MULTI case, but not in the
    case of a single storage type.
    
    Change-Id: I13073b3a72b201b5b11167deb050e6f27139c61c

diff --git a/firmware/common/disk.c b/firmware/common/disk.c
index 855b18f4a0..4a660eb705 100644
--- a/firmware/common/disk.c
+++ b/firmware/common/disk.c
@@ -508,9 +508,7 @@ int disk_mount_all(void)
 
     for (int i = 0; i < NUM_DRIVES; i++)
     {
-    #ifdef HAVE_HOTSWAP
         if (storage_present(i))
-    #endif
             mounted += disk_mount(i);
     }
 
@@ -554,9 +552,7 @@ int disk_unmount_all(void)
 
     for (int i = 0; i < NUM_DRIVES; i++)
     {
-    #ifdef HAVE_HOTSWAP
         if (storage_present(i))
-    #endif
             unmounted += disk_unmount(i);
     }
 
diff --git a/firmware/export/storage.h b/firmware/export/storage.h
index 0c0a051085..85c1ed9434 100644
--- a/firmware/export/storage.h
+++ b/firmware/export/storage.h
@@ -317,9 +317,6 @@ void storage_get_info(int drive, struct storage_info *info);
 #ifdef HAVE_HOTSWAP
 bool storage_removable(int drive);
 bool storage_present(int drive);
-#else
-#define storage_removable(x) 0
-#define storage_present(x) 1
 #endif
 int storage_driver_type(int drive);
 
@@ -327,4 +324,10 @@ int storage_driver_type(int drive);
 
 int storage_read_sectors(IF_MD(int drive,) sector_t start, int count, void* buf);
 int storage_write_sectors(IF_MD(int drive,) sector_t start, int count, const void* buf);
+
+#ifndef HAVE_HOTSWAP
+# define storage_removable(x) 0
+# define storage_present(x) 1
 #endif
+
+#endif /* __STORAGE_H__ */
diff --git a/firmware/target/arm/imx233/debug-imx233.c b/firmware/target/arm/imx233/debug-imx233.c
index 26197a2bfe..186c3a4673 100644
--- a/firmware/target/arm/imx233/debug-imx233.c
+++ b/firmware/target/arm/imx233/debug-imx233.c
@@ -1264,14 +1264,14 @@ bool dbg_hw_info_sdmmc(void)
             else
                 continue;
             lcd_putsf(0, line++, "%s", info.slot_name);
-#ifdef HAVE_HOTSWAP
+
             bool removable = storage_removable(info.drive);
             bool present = storage_present(info.drive);
             if(removable)
                 lcd_putsf(0, line++, "  removable %spresent", present ? "" : "not ");
             if(!present)
                 continue;
-#endif
+
             lcd_putsf(0, line++, "  bus: %d  sbc: %d", info.bus_width, info.has_sbc);
             lcd_putsf(0, line++, "  hs: %s", info.hs_enabled ? "enabled" :
                 info.hs_capable ? "disabled" : "not capable");
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index ac004a13d0..7f9057f643 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -800,11 +800,8 @@ static void handle_scsi(struct command_block_wrapper* cbw)
     block_count=info.num_sectors;
 #endif
 
-#ifdef HAVE_HOTSWAP
-    if(storage_removable(lun) && !storage_present(lun)) {
+    if(storage_removable(lun) && !storage_present(lun))
         ejected[lun] = true;
-    }
-#endif
 
     if(ejected[lun])
         lun_present = false;
@@ -855,11 +852,9 @@ static void handle_scsi(struct command_block_wrapper* cbw)
             tb.lun_data->lun_list_length=htobe32(8*storage_num_drives());
             for(i=0;i<storage_num_drives();i++)
             {
-#ifdef HAVE_HOTSWAP
                 if(storage_removable(i))
                     tb.lun_data->luns[i][1]=1;
                 else
-#endif
                     tb.lun_data->luns[i][1]=0;
             }
             length = MIN(length, allocation_length);
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs