4 * Copyright 2014 Google Inc.
6 * Released under the GPLv2 only.
10 #define __CONNECTION_H
12 #include <linux/list.h>
16 enum gb_connection_state {
17 GB_CONNECTION_STATE_INVALID = 0,
18 GB_CONNECTION_STATE_DISABLED = 1,
19 GB_CONNECTION_STATE_ENABLED = 2,
20 GB_CONNECTION_STATE_ERROR = 3,
21 GB_CONNECTION_STATE_DESTROYING = 4,
25 typedef int (*gb_connection_init_t)(struct gb_connection *);
26 typedef void (*gb_connection_exit_t)(struct gb_connection *);
28 struct gb_connection_handler {
29 gb_connection_init_t connection_init;
30 gb_connection_exit_t connection_exit;
33 struct gb_connection {
34 struct greybus_host_device *hd;
35 struct gb_interface *interface;
38 u16 interface_cport_id;
40 struct rb_node hd_node;
41 struct list_head interface_links;
44 enum gb_connection_state state;
46 struct list_head operations;
47 struct rb_root pending; /* awaiting reponse */
50 struct gb_connection_handler *handler;
54 #define to_gb_connection(d) container_of(d, struct gb_connection, dev)
56 struct gb_connection *gb_connection_create(struct gb_interface *interface,
57 u16 cport_id, u8 protocol_id);
58 void gb_connection_destroy(struct gb_connection *connection);
60 int gb_connection_init(struct gb_connection *connection);
61 void gb_connection_exit(struct gb_connection *connection);
63 struct gb_connection *gb_hd_connection_find(struct greybus_host_device *hd,
66 u16 gb_connection_operation_id(struct gb_connection *connection);
69 void gb_connection_err(struct gb_connection *connection, const char *fmt, ...);
71 #endif /* __CONNECTION_H */