greybus: connection: remove broken protocol-version handling
[cascardo/linux.git] / drivers / staging / greybus / connection.h
1 /*
2  * Greybus connections
3  *
4  * Copyright 2014 Google Inc.
5  * Copyright 2014 Linaro Ltd.
6  *
7  * Released under the GPLv2 only.
8  */
9
10 #ifndef __CONNECTION_H
11 #define __CONNECTION_H
12
13 #include <linux/list.h>
14 #include <linux/kfifo.h>
15
16 enum gb_connection_state {
17         GB_CONNECTION_STATE_INVALID     = 0,
18         GB_CONNECTION_STATE_DISABLED    = 1,
19         GB_CONNECTION_STATE_ENABLED_TX  = 2,
20         GB_CONNECTION_STATE_ENABLED     = 3,
21 };
22
23 struct gb_operation;
24
25 typedef int (*gb_request_handler_t)(struct gb_operation *);
26
27 struct gb_connection {
28         struct gb_host_device           *hd;
29         struct gb_interface             *intf;
30         struct gb_bundle                *bundle;
31         struct kref                     kref;
32         u16                             hd_cport_id;
33         u16                             intf_cport_id;
34
35         struct list_head                hd_links;
36         struct list_head                bundle_links;
37
38         gb_request_handler_t            handler;
39
40         struct gb_protocol              *protocol;
41         u8                              protocol_id;
42         u8                              module_major;
43         u8                              module_minor;
44
45         struct mutex                    mutex;
46         spinlock_t                      lock;
47         enum gb_connection_state        state;
48         struct list_head                operations;
49
50         char                            name[16];
51         struct workqueue_struct         *wq;
52
53         atomic_t                        op_cycle;
54
55         void                            *private;
56 };
57
58 struct gb_connection *gb_connection_create_static(struct gb_host_device *hd,
59                                 u16 hd_cport_id, u8 protocol_id);
60 struct gb_connection *gb_connection_create_dynamic(struct gb_interface *intf,
61                                 struct gb_bundle *bundle, u16 cport_id,
62                                 u8 protocol_id);
63 void gb_connection_destroy(struct gb_connection *connection);
64
65 static inline bool gb_connection_is_static(struct gb_connection *connection)
66 {
67         return !connection->intf;
68 }
69
70 int gb_connection_enable(struct gb_connection *connection,
71                                         gb_request_handler_t handler);
72 static inline int gb_connection_enable_tx(struct gb_connection *connection)
73 {
74         return gb_connection_enable(connection, NULL);
75 }
76 void gb_connection_disable_rx(struct gb_connection *connection);
77 void gb_connection_disable(struct gb_connection *connection);
78
79 void greybus_data_rcvd(struct gb_host_device *hd, u16 cport_id,
80                         u8 *data, size_t length);
81
82 void gb_connection_latency_tag_enable(struct gb_connection *connection);
83 void gb_connection_latency_tag_disable(struct gb_connection *connection);
84
85 #endif /* __CONNECTION_H */