USB: g_mass_storage: constant length buffers used
Using version of fsg_buffhd structure with buf field being an
array of characters with predefined size. Since mass storage
function does not define changing buffer size on run-time it is
not required for the field to be a pointer to void and allocating
space dynamically.
Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index e76c8ce..60bc696 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -47,6 +47,12 @@
* When FSG_NO_OTG is defined fsg_otg_desc won't be defined.
*/
+/*
+ * When FSG_BUFFHD_STATIC_BUFFER is defined when this file is included
+ * the fsg_buffhd structure's buf field will be an array of FSG_BUFLEN
+ * characters rather then a pointer to void.
+ */
+
#include <asm/unaligned.h>
@@ -290,7 +296,11 @@
};
struct fsg_buffhd {
+#ifdef FSG_BUFFHD_STATIC_BUFFER
+ char buf[FSG_BUFLEN];
+#else
void *buf;
+#endif
enum fsg_buffer_state state;
struct fsg_buffhd *next;