From 81a54b5e1986d02da33c59133556ce9fe2032049 Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Tue, 6 Jun 2017 15:25:09 +0300 Subject: thunderbolt: Let the connection manager handle all notifications Currently the control channel (ctl.c) handles the one supported notification (PLUG_EVENT) and sends back ACK accordingly. However, we are going to add support for the internal connection manager (ICM) that needs to handle a different notifications. So instead of dealing everything in the control channel, we change the callback to take an arbitrary thunderbolt packet and convert the native connection manager to handle the event itself. In addition we only push replies we know of to the response FIFO. Everything else is treated as notification (or request) and is expected to be dealt by the connection manager implementation. Signed-off-by: Mika Westerberg Reviewed-by: Yehezkel Bernat Reviewed-by: Michael Jamet Reviewed-by: Andy Shevchenko Signed-off-by: Andreas Noever Signed-off-by: Greg Kroah-Hartman --- drivers/thunderbolt/domain.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'drivers/thunderbolt/domain.c') diff --git a/drivers/thunderbolt/domain.c b/drivers/thunderbolt/domain.c index 3302f4c59638..54bc15f9bf6b 100644 --- a/drivers/thunderbolt/domain.c +++ b/drivers/thunderbolt/domain.c @@ -95,6 +95,19 @@ err_free: return NULL; } +static void tb_domain_event_cb(void *data, enum tb_cfg_pkg_type type, + const void *buf, size_t size) +{ + struct tb *tb = data; + + if (!tb->cm_ops->handle_event) { + tb_warn(tb, "domain does not have event handler\n"); + return; + } + + tb->cm_ops->handle_event(tb, type, buf, size); +} + /** * tb_domain_add() - Add domain to the system * @tb: Domain to add @@ -115,7 +128,7 @@ int tb_domain_add(struct tb *tb) mutex_lock(&tb->lock); - tb->ctl = tb_ctl_alloc(tb->nhi, tb->cm_ops->hotplug, tb); + tb->ctl = tb_ctl_alloc(tb->nhi, tb_domain_event_cb, tb); if (!tb->ctl) { ret = -ENOMEM; goto err_unlock; -- cgit v1.2.3