static void
gb_connection_svc_connection_destroy(struct gb_connection *connection)
{
- if (connection->hd_cport_id == GB_SVC_CPORT_ID)
+ if (connection->protocol->flags & GB_PROTOCOL_SKIP_SVC_CONNECTION)
return;
if (connection->hd->driver->connection_destroy)
int cport_id = connection->intf_cport_id;
int ret;
- /*
- * Inform Interface about In-active CPorts. We don't need to do this
- * operation for control cport.
- */
- if ((cport_id == GB_CONTROL_CPORT_ID) ||
- (connection->hd_cport_id == GB_SVC_CPORT_ID))
+ /* Inform Interface about inactive CPorts */
+ if (connection->protocol->flags & GB_PROTOCOL_SKIP_CONTROL_DISCONNECTED)
return;
control = connection->bundle->intf->control;
{
int cport_id = connection->intf_cport_id;
struct greybus_host_device *hd = connection->hd;
+ struct gb_protocol *protocol = connection->protocol;
int ret;
/*
* Request the SVC to create a connection from AP's cport to interface's
* cport.
*/
- if (connection->hd_cport_id != GB_SVC_CPORT_ID) {
+ if (!(protocol->flags & GB_PROTOCOL_SKIP_SVC_CONNECTION)) {
ret = gb_svc_connection_create(hd->svc,
hd->endo->ap_intf_id, connection->hd_cport_id,
connection->bundle->intf->interface_id,
if (hd->driver->connection_create)
hd->driver->connection_create(connection);
}
-
- /*
- * Inform Interface about Active CPorts. We don't need to do this
- * operation for control cport.
- */
- if (cport_id != GB_CONTROL_CPORT_ID &&
- connection->hd_cport_id != GB_SVC_CPORT_ID) {
+ /* Inform Interface about active CPorts */
+ if (!(protocol->flags & GB_PROTOCOL_SKIP_CONTROL_CONNECTED)) {
struct gb_control *control = connection->bundle->intf->control;
ret = gb_control_connected_operation(control, cport_id);
* Request protocol version supported by the module. We don't need to do
* this for SVC as that is initiated by the SVC.
*/
- if (connection->hd_cport_id != GB_SVC_CPORT_ID) {
+ if (!(protocol->flags & GB_PROTOCOL_SKIP_VERSION)) {
ret = gb_protocol_get_version(connection);
if (ret) {
dev_err(&connection->dev,
}
}
- ret = connection->protocol->connection_init(connection);
+ ret = protocol->connection_init(connection);
if (!ret)
return 0;
* active device, so bring up the connection at the same time.
*/
if ((!connection->bundle &&
- connection->hd_cport_id == GB_SVC_CPORT_ID) ||
+ protocol->flags & GB_PROTOCOL_NO_BUNDLE) ||
connection->bundle->intf->device_id != GB_DEVICE_ID_BAD) {
ret = gb_connection_init(connection);
if (ret) {
struct gb_connection;
struct gb_operation;
+/* Possible flags for protocol drivers */
+#define GB_PROTOCOL_SKIP_CONTROL_CONNECTED BIT(0) /* Don't sent connected requests */
+#define GB_PROTOCOL_SKIP_CONTROL_DISCONNECTED BIT(1) /* Don't sent disconnected requests */
+#define GB_PROTOCOL_NO_BUNDLE BIT(2) /* Protocol May have a bundle-less connection */
+#define GB_PROTOCOL_SKIP_VERSION BIT(3) /* Don't send get_version() requests */
+#define GB_PROTOCOL_SKIP_SVC_CONNECTION BIT(4) /* Don't send SVC connection requests */
+
typedef int (*gb_connection_init_t)(struct gb_connection *);
typedef void (*gb_connection_exit_t)(struct gb_connection *);
typedef int (*gb_request_recv_t)(u8, struct gb_operation *);
u8 major;
u8 minor;
u8 count;
+ unsigned long flags;
struct list_head links; /* global list */
.connection_init = gb_svc_connection_init,
.connection_exit = gb_svc_connection_exit,
.request_recv = gb_svc_request_recv,
+ .flags = GB_PROTOCOL_SKIP_CONTROL_CONNECTED |
+ GB_PROTOCOL_SKIP_CONTROL_DISCONNECTED |
+ GB_PROTOCOL_NO_BUNDLE |
+ GB_PROTOCOL_SKIP_VERSION |
+ GB_PROTOCOL_SKIP_SVC_CONNECTION,
};
gb_builtin_protocol_driver(svc_protocol);