[PATCH 5/7] usb-storage,uas: do not convert device_info for 64-bit platforms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch optimizes the previous one for 64-bit platforms, where
unsigned long is 64-bit, so we do not need to convert quirk flags
to 32-bit index.

Signed-off-by: Milan Broz <gmazyland@xxxxxxxxx>
---
 drivers/usb/storage/Makefile  | 3 +++
 drivers/usb/storage/mkflags.c | 9 +++++++++
 drivers/usb/storage/usb-ids.h | 4 ++++
 3 files changed, 16 insertions(+)

diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
index 612678f108d0..62ebaa76ef95 100644
--- a/drivers/usb/storage/Makefile
+++ b/drivers/usb/storage/Makefile
@@ -57,6 +57,9 @@ $(obj)/usual-tables.o: $(obj)/usb-ids.c
 $(obj)/uas.o: $(obj)/usb-ids-uas.c
 clean-files		:= usb-ids.c usb-ids-uas.c
 HOSTCFLAGS_mkflags.o	:= -I $(srctree)/include/
+ifdef CONFIG_64BIT
+HOSTCFLAGS_mkflags.o	+= -D CONFIG_64BIT
+endif
 hostprogs		+= mkflags
 
 quiet_cmd_mkflag_storage = FLAGS   $@
diff --git a/drivers/usb/storage/mkflags.c b/drivers/usb/storage/mkflags.c
index 2514ffef0154..08c37d2e52d6 100644
--- a/drivers/usb/storage/mkflags.c
+++ b/drivers/usb/storage/mkflags.c
@@ -89,11 +89,15 @@ static struct svals vals[] = {
 
 static unsigned long get_device_info(uint64_t flags, unsigned int idx)
 {
+#ifndef CONFIG_64BIT
 	if (flags < HI32)
 		return (unsigned long)flags;
 
 	/* Use index that will be processed in usb_stor_di2flags */
 	return HI32 + idx;
+#else
+	return flags;
+#endif
 }
 
 static void print_class(uint8_t bDeviceSubClass, uint8_t bDeviceProtocol)
@@ -123,6 +127,10 @@ static void print_type(unsigned int type)
 
 static void print_usb_flags(const char *type)
 {
+#ifdef CONFIG_64BIT
+	printf("const u64 usb_%s_di_to_u64[] = {};\n", type);
+	printf("const unsigned long usb_%s_di_idx_size = 0;\n\n", type);
+#else
 	int i, count;
 
 	printf("const u64 usb_%s_di_to_u64[] = {\n", type);
@@ -134,6 +142,7 @@ static void print_usb_flags(const char *type)
 	}
 	printf("};\n\n");
 	printf("const unsigned long usb_%s_di_idx_size = %i;\n\n", type, count);
+#endif
 }
 
 static void print_usb_storage(void)
diff --git a/drivers/usb/storage/usb-ids.h b/drivers/usb/storage/usb-ids.h
index 8bfd84e07f96..4abe1a6d3a66 100644
--- a/drivers/usb/storage/usb-ids.h
+++ b/drivers/usb/storage/usb-ids.h
@@ -15,6 +15,9 @@ extern const u64 usb_uas_di_to_u64[];
 static u64 usb_stor_di2flags(const u64 *di_to_u64,
 		unsigned long idx_size, unsigned long idx)
 {
+#if IS_ENABLED(CONFIG_64BIT)
+	return idx;
+#else
 	u64 flags = 0;
 
 	if (idx < (1UL << 31))
@@ -28,6 +31,7 @@ static u64 usb_stor_di2flags(const u64 *di_to_u64,
 		WARN_ONCE(true, "usb_stor_di_to_u64 table not updated");
 
 	return flags;
+#endif
 }
 
 #endif
-- 
2.42.0





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux