blob: 61e94357db3ad5ebaceb17cb988c944a38715802 [file] [log] [blame]
Alex Elderc68adb22014-10-01 21:54:14 -05001/*
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"
Alex Elderc68adb22014-10-01 21:54:14 -050015
16struct gb_connection {
Alex Elderc68adb22014-10-01 21:54:14 -050017 struct greybus_host_device *hd;
Alex Eldercd345072014-10-02 12:30:05 -050018 struct gb_interface *interface;
19 u16 hd_cport_id;
20 u16 interface_cport_id;
Alex Elderc68adb22014-10-01 21:54:14 -050021
Alex Eldercd345072014-10-02 12:30:05 -050022 struct list_head hd_links;
23 struct list_head interface_links;
Alex Elderad1c4492014-10-02 12:30:06 -050024 enum greybus_protocol protocol;
Alex Eldere88afa52014-10-01 21:54:15 -050025
26 struct list_head operations;
27 atomic_t op_cycle;
Alex Elder8a306722014-10-03 15:05:21 -050028
29 void *private;
Alex Elderc68adb22014-10-01 21:54:14 -050030};
31
Alex Eldercd345072014-10-02 12:30:05 -050032struct gb_connection *gb_connection_create(struct gb_interface *interface,
Alex Elderad1c4492014-10-02 12:30:06 -050033 u16 cport_id, enum greybus_protocol protocol);
Alex Elderb05890d2014-10-02 12:30:01 -050034void gb_connection_destroy(struct gb_connection *connection);
Alex Elderc68adb22014-10-01 21:54:14 -050035
Alex Eldere88afa52014-10-01 21:54:15 -050036u16 gb_connection_op_id(struct gb_connection *connection);
37
Alex Eldereeeed422014-10-03 15:05:22 -050038__printf(2, 3)
39void gb_connection_err(struct gb_connection *connection, const char *fmt, ...);
40
Alex Elderc68adb22014-10-01 21:54:14 -050041#endif /* __CONNECTION_H */