Commit cb033188 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: connection: add connection-flag interface

Add interface for associating a flag bitmask with a connection when
creating it.
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 8fd9466b
...@@ -119,6 +119,7 @@ static void gb_connection_init_name(struct gb_connection *connection) ...@@ -119,6 +119,7 @@ static void gb_connection_init_name(struct gb_connection *connection)
* @bundle: remote-interface bundle (may be NULL) * @bundle: remote-interface bundle (may be NULL)
* @cport_id: remote-interface cport id, or 0 for static connections * @cport_id: remote-interface cport id, or 0 for static connections
* @handler: request handler (may be NULL) * @handler: request handler (may be NULL)
* @flags: connection flags
* *
* Create a Greybus connection, representing the bidirectional link * Create a Greybus connection, representing the bidirectional link
* between a CPort on a (local) Greybus host device and a CPort on * between a CPort on a (local) Greybus host device and a CPort on
...@@ -137,7 +138,8 @@ static struct gb_connection * ...@@ -137,7 +138,8 @@ static struct gb_connection *
_gb_connection_create(struct gb_host_device *hd, int hd_cport_id, _gb_connection_create(struct gb_host_device *hd, int hd_cport_id,
struct gb_interface *intf, struct gb_interface *intf,
struct gb_bundle *bundle, int cport_id, struct gb_bundle *bundle, int cport_id,
gb_request_handler_t handler) gb_request_handler_t handler,
unsigned long flags)
{ {
struct gb_connection *connection; struct gb_connection *connection;
struct ida *id_map = &hd->cport_id_map; struct ida *id_map = &hd->cport_id_map;
...@@ -180,6 +182,7 @@ _gb_connection_create(struct gb_host_device *hd, int hd_cport_id, ...@@ -180,6 +182,7 @@ _gb_connection_create(struct gb_host_device *hd, int hd_cport_id,
connection->intf = intf; connection->intf = intf;
connection->bundle = bundle; connection->bundle = bundle;
connection->handler = handler; connection->handler = handler;
connection->flags = flags;
connection->state = GB_CONNECTION_STATE_DISABLED; connection->state = GB_CONNECTION_STATE_DISABLED;
atomic_set(&connection->op_cycle, 0); atomic_set(&connection->op_cycle, 0);
...@@ -226,13 +229,14 @@ struct gb_connection * ...@@ -226,13 +229,14 @@ struct gb_connection *
gb_connection_create_static(struct gb_host_device *hd, u16 hd_cport_id, gb_connection_create_static(struct gb_host_device *hd, u16 hd_cport_id,
gb_request_handler_t handler) gb_request_handler_t handler)
{ {
return _gb_connection_create(hd, hd_cport_id, NULL, NULL, 0, handler); return _gb_connection_create(hd, hd_cport_id, NULL, NULL, 0, handler,
0);
} }
struct gb_connection * struct gb_connection *
gb_connection_create_control(struct gb_interface *intf) gb_connection_create_control(struct gb_interface *intf)
{ {
return _gb_connection_create(intf->hd, -1, intf, NULL, 0, NULL); return _gb_connection_create(intf->hd, -1, intf, NULL, 0, NULL, 0);
} }
struct gb_connection * struct gb_connection *
...@@ -242,10 +246,22 @@ gb_connection_create(struct gb_bundle *bundle, u16 cport_id, ...@@ -242,10 +246,22 @@ gb_connection_create(struct gb_bundle *bundle, u16 cport_id,
struct gb_interface *intf = bundle->intf; struct gb_interface *intf = bundle->intf;
return _gb_connection_create(intf->hd, -1, intf, bundle, cport_id, return _gb_connection_create(intf->hd, -1, intf, bundle, cport_id,
handler); handler, 0);
} }
EXPORT_SYMBOL_GPL(gb_connection_create); EXPORT_SYMBOL_GPL(gb_connection_create);
struct gb_connection *
gb_connection_create_flags(struct gb_bundle *bundle, u16 cport_id,
gb_request_handler_t handler,
unsigned long flags)
{
struct gb_interface *intf = bundle->intf;
return _gb_connection_create(intf->hd, -1, intf, bundle, cport_id,
handler, flags);
}
EXPORT_SYMBOL_GPL(gb_connection_create_flags);
static int gb_connection_hd_cport_enable(struct gb_connection *connection) static int gb_connection_hd_cport_enable(struct gb_connection *connection)
{ {
struct gb_host_device *hd = connection->hd; struct gb_host_device *hd = connection->hd;
......
...@@ -36,6 +36,7 @@ struct gb_connection { ...@@ -36,6 +36,7 @@ struct gb_connection {
struct list_head bundle_links; struct list_head bundle_links;
gb_request_handler_t handler; gb_request_handler_t handler;
unsigned long flags;
struct gb_protocol *protocol; struct gb_protocol *protocol;
u8 module_major; u8 module_major;
...@@ -59,6 +60,9 @@ struct gb_connection *gb_connection_create_static(struct gb_host_device *hd, ...@@ -59,6 +60,9 @@ struct gb_connection *gb_connection_create_static(struct gb_host_device *hd,
struct gb_connection *gb_connection_create_control(struct gb_interface *intf); struct gb_connection *gb_connection_create_control(struct gb_interface *intf);
struct gb_connection *gb_connection_create(struct gb_bundle *bundle, struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
u16 cport_id, gb_request_handler_t handler); u16 cport_id, gb_request_handler_t handler);
struct gb_connection * gb_connection_create_flags(struct gb_bundle *bundle,
u16 cport_id, gb_request_handler_t handler,
unsigned long flags);
void gb_connection_destroy(struct gb_connection *connection); void gb_connection_destroy(struct gb_connection *connection);
static inline bool gb_connection_is_static(struct gb_connection *connection) static inline bool gb_connection_is_static(struct gb_connection *connection)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment