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,
24 struct gb_connection {
25 struct greybus_host_device *hd;
26 struct gb_interface *interface;
29 u16 interface_cport_id;
31 struct list_head hd_links;
32 struct list_head interface_links;
34 struct gb_protocol *protocol;
36 enum gb_connection_state state;
39 struct list_head operations;
40 struct list_head pending; /* awaiting reponse */
44 #define to_gb_connection(d) container_of(d, struct gb_connection, dev)
46 struct gb_connection *gb_connection_create(struct gb_interface *interface,
47 u16 cport_id, u8 protocol_id);
48 void gb_connection_destroy(struct gb_connection *connection);
50 int gb_connection_init(struct gb_connection *connection);
51 void gb_connection_exit(struct gb_connection *connection);
53 struct gb_connection *gb_hd_connection_find(struct greybus_host_device *hd,
56 void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id,
57 u8 *data, size_t length);
59 void gb_connection_err(struct gb_connection *connection, const char *fmt, ...);
61 #endif /* __CONNECTION_H */