[PATCH] USB, Mass Storage, composite, gadget: Fix build failure andmemset of a struct
From: Jesper Juhl
Date: Fri Jan 28 2011 - 20:25:48 EST
Trying to compile drivers/usb/gadget/f_mass_storage.o currently fails and
spews a ton of warnings :
CC drivers/usb/gadget/f_mass_storage.o
drivers/usb/gadget/f_mass_storage.c:436:22: error: field ʽfunctionʼ has incomplete type
drivers/usb/gadget/f_mass_storage.c: In function ʽfsg_from_funcʼ:
drivers/usb/gadget/f_mass_storage.c:466:9: warning: type defaults to ʽintʼ in declaration of ʽ__mptrʼ
drivers/usb/gadget/f_mass_storage.c:466:9: warning: initialization from incompatible pointer type
drivers/usb/gadget/f_mass_storage.c: At top level:
drivers/usb/gadget/f_mass_storage.c:2743:15: warning: ʽstruct usb_composite_devʼ declared inside parameter list
drivers/usb/gadget/f_mass_storage.c:2743:15: warning: its scope is only this definition or declaration, which is probably not what you want
drivers/usb/gadget/f_mass_storage.c: In function ʽfsg_common_initʼ:
drivers/usb/gadget/f_mass_storage.c:2745:34: error: dereferencing pointer to incomplete type
drivers/usb/gadget/f_mass_storage.c:2775:23: error: dereferencing pointer to incomplete type
drivers/usb/gadget/f_mass_storage.c:2779:3: error: implicit declaration of function ʽusb_string_idʼ
drivers/usb/gadget/f_mass_storage.c: At top level:
drivers/usb/gadget/f_mass_storage.c:2984:60: warning: ʽstruct usb_configurationʼ declared inside parameter list
drivers/usb/gadget/f_mass_storage.c:3003:57: warning: ʽstruct usb_configurationʼ declared inside parameter list
drivers/usb/gadget/f_mass_storage.c: In function ʽfsg_bindʼ:
drivers/usb/gadget/f_mass_storage.c:3006:31: error: dereferencing pointer to incomplete type
drivers/usb/gadget/f_mass_storage.c:3013:2: error: implicit declaration of function ʽusb_interface_idʼ
drivers/usb/gadget/f_mass_storage.c:3033:3: error: dereferencing pointer to incomplete type
drivers/usb/gadget/f_mass_storage.c:3034:6: error: dereferencing pointer to incomplete type
drivers/usb/gadget/f_mass_storage.c:3043:4: error: dereferencing pointer to incomplete type
drivers/usb/gadget/f_mass_storage.c:3044:7: error: dereferencing pointer to incomplete type
drivers/usb/gadget/f_mass_storage.c:3045:26: error: dereferencing pointer to incomplete type
drivers/usb/gadget/f_mass_storage.c: At top level:
drivers/usb/gadget/f_mass_storage.c:3067:14: warning: ʽstruct usb_configurationʼ declared inside parameter list
drivers/usb/gadget/f_mass_storage.c:3067:14: warning: ʽstruct usb_composite_devʼ declared inside parameter list
drivers/usb/gadget/f_mass_storage.c: In function ʽfsg_bind_configʼ:
drivers/usb/gadget/f_mass_storage.c:3093:2: error: implicit declaration of function ʽusb_add_functionʼ
drivers/usb/gadget/f_mass_storage.c: At top level:
drivers/usb/gadget/f_mass_storage.c:3103:9: warning: ʽstruct usb_configurationʼ declared inside parameter list
drivers/usb/gadget/f_mass_storage.c:3103:9: warning: ʽstruct usb_composite_devʼ declared inside parameter list
drivers/usb/gadget/f_mass_storage.c: In function ʽfsg_addʼ:
drivers/usb/gadget/f_mass_storage.c:3105:2: warning: passing argument 1 of ʽfsg_bind_configʼ from incompatible pointer type
drivers/usb/gadget/f_mass_storage.c:3065:12: note: expected ʽstruct usb_composite_dev *ʼ but argument is of type ʽstruct usb_composite_dev *ʼ
drivers/usb/gadget/f_mass_storage.c:3105:2: warning: passing argument 2 of ʽfsg_bind_configʼ from incompatible pointer type
drivers/usb/gadget/f_mass_storage.c:3065:12: note: expected ʽstruct usb_configuration *ʼ but argument is of type ʽstruct usb_configuration *ʼ
drivers/usb/gadget/f_mass_storage.c: At top level:
drivers/usb/gadget/f_mass_storage.c:3190:23: warning: ʽstruct usb_composite_devʼ declared inside parameter list
drivers/usb/gadget/f_mass_storage.c:3195:23: warning: ʽstruct usb_composite_devʼ declared inside parameter list
drivers/usb/gadget/f_mass_storage.c:3193:1: error: conflicting types for ʽfsg_common_from_paramsʼ
drivers/usb/gadget/f_mass_storage.c:3188:1: note: previous declaration of ʽfsg_common_from_paramsʼ was here
drivers/usb/gadget/f_mass_storage.c: In function ʽfsg_common_from_paramsʼ:
drivers/usb/gadget/f_mass_storage.c:3199:2: warning: passing argument 2 of ʽfsg_common_initʼ from incompatible pointer type
drivers/usb/gadget/f_mass_storage.c:2741:27: note: expected ʽstruct usb_composite_dev *ʼ but argument is of type ʽstruct usb_composite_dev *ʼ
make[1]: *** [drivers/usb/gadget/f_mass_storage.o] Error 1
make: *** [drivers/usb/gadget/f_mass_storage.o] Error 2
This is due to the missing include of linux/usb/composite.h - this patch
adds the missing include.
In addition there's also a problem in fsg_common_init() where we memset
'common', but we use the size of a pointer to 'struct fsg_common' as the
size argument to memset(), not the actual size of the struct. This patch
fixes the sizeof so we zero the entire struct as intended.
Signed-off-by: Jesper Juhl <jj@xxxxxxxxxxxxx>
---
f_mass_storage.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
compile tested only.
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index b5dbb23..6d8e533 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -293,6 +293,7 @@
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
+#include <linux/usb/composite.h>
#include "gadget_chips.h"
@@ -2763,7 +2764,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
return ERR_PTR(-ENOMEM);
common->free_storage_on_release = 1;
} else {
- memset(common, 0, sizeof common);
+ memset(common, 0, sizeof *common);
common->free_storage_on_release = 0;
}
--
Jesper Juhl <jj@xxxxxxxxxxxxx> http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.