From c4d0e856047f2689278ffea63a562c4f22a35ee3 Mon Sep 17 00:00:00 2001 From: Mateusz Zalega Date: Mon, 28 Apr 2014 21:13:28 +0200 Subject: USB: gadget: added a saner gadget downloader registration API Preprocessor definitions and hardcoded implementation selection in g_dnl core were replaced by a linker list made of (usb_function_name, bind_callback) pairs. Signed-off-by: Mateusz Zalega Acked-by: Lukasz Majewski Acked-by: Marek Vasut --- include/dfu.h | 7 ------- include/g_dnl.h | 23 +++++++++++++++++++++++ include/thor.h | 8 -------- include/usb_mass_storage.h | 8 -------- 4 files changed, 23 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/dfu.h b/include/dfu.h index dcd3215d06..240916854a 100644 --- a/include/dfu.h +++ b/include/dfu.h @@ -168,12 +168,5 @@ static inline int dfu_fill_entity_ram(struct dfu_entity *dfu, char *s) } #endif -#ifdef CONFIG_DFU_FUNCTION int dfu_add(struct usb_configuration *c); -#else -int dfu_add(struct usb_configuration *c) -{ - return 0; -} -#endif #endif /* __DFU_ENTITY_H_ */ diff --git a/include/g_dnl.h b/include/g_dnl.h index f4e8d1089e..1b1b35e0e1 100644 --- a/include/g_dnl.h +++ b/include/g_dnl.h @@ -10,6 +10,29 @@ #include #include +#include +#include + +/* + * @usb_fname: unescaped USB function name + * @callback_ptr: bind callback, one per function name + */ +#define DECLARE_GADGET_BIND_CALLBACK(usb_fname, callback_ptr) \ + ll_entry_declare(struct g_dnl_bind_callback, \ + __usb_function_name_##usb_fname, \ + g_dnl_bind_callbacks) = { \ + .usb_function_name = #usb_fname, \ + .fptr = callback_ptr \ + } + +typedef int (*g_dnl_bind_callback_f)(struct usb_configuration *); + +/* used in Gadget downloader callback linker list */ +struct g_dnl_bind_callback { + const char *usb_function_name; + g_dnl_bind_callback_f fptr; +}; + int g_dnl_bind_fixup(struct usb_device_descriptor *, const char *); int g_dnl_board_usb_cable_connected(void); int g_dnl_register(const char *s); diff --git a/include/thor.h b/include/thor.h index afeade4564..5051be714b 100644 --- a/include/thor.h +++ b/include/thor.h @@ -15,13 +15,5 @@ int thor_handle(void); int thor_init(void); - -#ifdef CONFIG_THOR_FUNCTION int thor_add(struct usb_configuration *c); -#else -int thor_add(struct usb_configuration *c) -{ - return 0; -} -#endif #endif /* __THOR_H_ */ diff --git a/include/usb_mass_storage.h b/include/usb_mass_storage.h index 058dcf1174..ed460644c1 100644 --- a/include/usb_mass_storage.h +++ b/include/usb_mass_storage.h @@ -40,13 +40,5 @@ int fsg_init(struct ums *); void fsg_cleanup(void); struct ums *ums_init(unsigned int); int fsg_main_thread(void *); - -#ifdef CONFIG_USB_GADGET_MASS_STORAGE int fsg_add(struct usb_configuration *c); -#else -int fsg_add(struct usb_configuration *c) -{ - return 0; -} -#endif #endif /* __USB_MASS_STORAGE_H__ */ -- cgit v1.2.1