greybus: connection: remove unused invalid state
[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 #define GB_CONNECTION_FLAG_CSD          BIT(0)
17 #define GB_CONNECTION_FLAG_NO_FLOWCTRL  BIT(1)
18 #define GB_CONNECTION_FLAG_OFFLOADED    BIT(2)
19 #define GB_CONNECTION_FLAG_CDSI1        BIT(3)
20 #define GB_CONNECTION_FLAG_CONTROL      BIT(4)
21
22 enum gb_connection_state {
23         GB_CONNECTION_STATE_DISABLED    = 0,
24         GB_CONNECTION_STATE_ENABLED_TX  = 1,
25         GB_CONNECTION_STATE_ENABLED     = 2,
26 };
27
28 struct gb_operation;
29
30 typedef int (*gb_request_handler_t)(struct gb_operation *);
31
32 struct gb_connection {
33         struct gb_host_device           *hd;
34         struct gb_interface             *intf;
35         struct gb_bundle                *bundle;
36         struct kref                     kref;
37         u16                             hd_cport_id;
38         u16                             intf_cport_id;
39
40         struct list_head                hd_links;
41         struct list_head                bundle_links;
42
43         gb_request_handler_t            handler;
44         unsigned long                   flags;
45
46         u8                              module_major;
47         u8                              module_minor;
48
49         struct mutex                    mutex;
50         spinlock_t                      lock;
51         enum gb_connection_state        state;
52         struct list_head                operations;
53
54         char                            name[16];
55         struct workqueue_struct         *wq;
56
57         atomic_t                        op_cycle;
58
59         void                            *private;
60 };
61
62 struct gb_connection *gb_connection_create_static(struct gb_host_device *hd,
63                                 u16 hd_cport_id, gb_request_handler_t handler);
64 struct gb_connection *gb_connection_create_control(struct gb_interface *intf);
65 struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
66                                 u16 cport_id, gb_request_handler_t handler);
67 struct gb_connection *gb_connection_create_flags(struct gb_bundle *bundle,
68                                 u16 cport_id, gb_request_handler_t handler,
69                                 unsigned long flags);
70 struct gb_connection *gb_connection_create_offloaded(struct gb_bundle *bundle,
71                                 u16 cport_id, unsigned long flags);
72 void gb_connection_destroy(struct gb_connection *connection);
73
74 static inline bool gb_connection_is_static(struct gb_connection *connection)
75 {
76         return !connection->intf;
77 }
78
79 int gb_connection_enable(struct gb_connection *connection);
80 int gb_connection_enable_tx(struct gb_connection *connection);
81 void gb_connection_disable_rx(struct gb_connection *connection);
82 void gb_connection_disable(struct gb_connection *connection);
83 void gb_connection_disable_forced(struct gb_connection *connection);
84
85 void greybus_data_rcvd(struct gb_host_device *hd, u16 cport_id,
86                         u8 *data, size_t length);
87
88 void gb_connection_latency_tag_enable(struct gb_connection *connection);
89 void gb_connection_latency_tag_disable(struct gb_connection *connection);
90
91 static inline bool gb_connection_e2efc_enabled(struct gb_connection *connection)
92 {
93         return !(connection->flags & GB_CONNECTION_FLAG_CSD);
94 }
95
96 static inline bool
97 gb_connection_flow_control_disabled(struct gb_connection *connection)
98 {
99         return connection->flags & GB_CONNECTION_FLAG_NO_FLOWCTRL;
100 }
101
102 static inline bool gb_connection_is_offloaded(struct gb_connection *connection)
103 {
104         return connection->flags & GB_CONNECTION_FLAG_OFFLOADED;
105 }
106
107 static inline bool gb_connection_is_control(struct gb_connection *connection)
108 {
109         return connection->flags & GB_CONNECTION_FLAG_CONTROL;
110 }
111
112 static inline void *gb_connection_get_data(struct gb_connection *connection)
113 {
114         return connection->private;
115 }
116
117 static inline void gb_connection_set_data(struct gb_connection *connection,
118                                           void *data)
119 {
120         connection->private = data;
121 }
122
123 #endif /* __CONNECTION_H */