2 * Greybus protocol handling
4 * Copyright 2014 Google Inc.
5 * Copyright 2014 Linaro Ltd.
7 * Released under the GPLv2 only.
16 typedef int (*gb_connection_init_t)(struct gb_connection *);
17 typedef void (*gb_connection_exit_t)(struct gb_connection *);
18 typedef int (*gb_request_recv_t)(u8, struct gb_operation *);
21 * Protocols having the same id but different major and/or minor
22 * version numbers are treated as distinct protocols. If it makes
23 * sense someday we could group protocols having the same id.
31 struct list_head links; /* global list */
33 gb_connection_init_t connection_init;
34 gb_connection_exit_t connection_exit;
35 gb_request_recv_t request_recv;
40 int __gb_protocol_register(struct gb_protocol *protocol, struct module *module);
41 void gb_protocol_deregister(struct gb_protocol *protocol);
43 #define gb_protocol_register(protocol) \
44 __gb_protocol_register(protocol, THIS_MODULE)
46 struct gb_protocol *gb_protocol_get(u8 id, u8 major, u8 minor);
47 int gb_protocol_get_version(struct gb_connection *connection);
49 void gb_protocol_put(struct gb_protocol *protocol);
51 /* __protocol: Pointer to struct gb_protocol */
52 #define gb_protocol_driver(__protocol) \
53 static int __init protocol_init(void) \
55 return gb_protocol_register(__protocol); \
57 module_init(protocol_init); \
58 static void __exit protocol_exit(void) \
60 gb_protocol_deregister(__protocol); \
62 module_exit(protocol_exit)
64 /* __protocol: string matching name of struct gb_protocol */
65 #define gb_builtin_protocol_driver(__protocol) \
66 int __init gb_##__protocol##_init(void) \
68 return gb_protocol_register(&__protocol); \
70 void gb_##__protocol##_exit(void) \
72 gb_protocol_deregister(&__protocol); \
75 #endif /* __PROTOCOL_H */