greybus: kill off the last of gbuf.c
[cascardo/linux.git] / drivers / staging / greybus / connection.h
1 /*
2  * Greybus connections
3  *
4  * Copyright 2014 Google Inc.
5  *
6  * Released under the GPLv2 only.
7  */
8
9 #ifndef __CONNECTION_H
10 #define __CONNECTION_H
11
12 #include <linux/list.h>
13
14 #include "greybus.h"
15
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,
22 };
23
24 struct gb_connection {
25         struct greybus_host_device      *hd;
26         struct gb_interface             *interface;
27         struct device                   dev;
28         u16                             hd_cport_id;
29         u16                             interface_cport_id;
30
31         struct list_head                hd_links;
32         struct list_head                interface_links;
33
34         struct gb_protocol              *protocol;
35
36         enum gb_connection_state        state;
37
38         u16                             op_cycle;
39         struct list_head                operations;
40         struct list_head                pending;        /* awaiting reponse */
41
42         void                            *private;
43 };
44 #define to_gb_connection(d) container_of(d, struct gb_connection, dev)
45
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);
49
50 int gb_connection_init(struct gb_connection *connection);
51 void gb_connection_exit(struct gb_connection *connection);
52
53 struct gb_connection *gb_hd_connection_find(struct greybus_host_device *hd,
54                                 u16 cport_id);
55
56 void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id,
57                         u8 *data, size_t length);
58 __printf(2, 3)
59 void gb_connection_err(struct gb_connection *connection, const char *fmt, ...);
60
61 #endif /* __CONNECTION_H */