Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp116276ybm; Tue, 26 May 2020 12:10:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1i5Lq7rAGe1B3CvTsmllEz0HEVjmcd5FzC52q06dSFadCX2Z076JvWsdorZuJvcdk9MRb X-Received: by 2002:a50:8d42:: with SMTP id t2mr6286510edt.170.1590520248839; Tue, 26 May 2020 12:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590520248; cv=none; d=google.com; s=arc-20160816; b=dBlBYOptVjHW++FhVZKwOn45f4VcjgNo4qbXEgsvS6AhmoF+nonQ6LQB2qADLNacYb Bs+C7HGVY4dRqCNu1fbIdOxBmbfPp8x77PaYSEgtgbEKamiSutcV+HpRfrhkTtirVzDO xMNejPY8wl25eRZvFaSg2HpngqZx+y0g3bqGx6NjcivKvEmCvA+GmX/YVDjxlJA2TU06 AoEk3CVm5w2uCMp1R1tvD68SWv9qEVu1mLyjJ8w+/GSPwfQKnMVlz/4S4m0Wp0zmMMs5 4yi9EWFzKga6TxF1SwRESiPlc6KY8JvN09b8YuHLrnzYSTetXEjQ/hXt/oj1qCKhnHlN o3Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dsXhM5H2kIlvEkW0ZE3ac+cWOqmCX5dRWVuhol+QiuY=; b=bwJGiak1HLmvJuRTMsGsrjO0k21Y8EcKHogFgiwpH0pdnZwuNGmBhpUky1Oc1Vr6hz rPcks4r6M9MemVT5d2ZbqKYYvyzgxcAa9JHr2PwK073NuvK2Db+8cNwpH2EJClxqvnsd xLJlgdAlAPhSZe9zgBwKDBPKIMjlHbiNzP0+8ODkGQGuA4Ku/RiDUZajdY26/WW+ny6l i2AcV2es5QKPlVRYonjsQNsWe3ukO7mOo8iH9StQ0e5GsVqzfgOs+RTdYarHw8M1Tc2b hebCuGAGdD2++9OIHcUdB9T9i9QLXn/pQLhofFfXNj/+1gjKEKyfJFB1FVL+UntDFaP3 J8Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RlCrTlPP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o23si381909eds.570.2020.05.26.12.10.24; Tue, 26 May 2020 12:10:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RlCrTlPP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390699AbgEZTFf (ORCPT + 99 others); Tue, 26 May 2020 15:05:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:33438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391504AbgEZTF3 (ORCPT ); Tue, 26 May 2020 15:05:29 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4262A208A7; Tue, 26 May 2020 19:05:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590519928; bh=zL1ncFwqIrkyxwUfDGOmJpigKvrIf1byzCxY4Qi79oU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RlCrTlPP2F+cgpfEsHf75sRRccO36H5uYu8R4ZCgFogmJ7PvCrryf9tdw7fwPiweB TgKlppTaR95HhFfgTf3B0CvzjXnP4BCoGeQIIuOfVyiFHgj4tYrxoxKZQiefxgjapH kxad7qqVPUttyj2OLBUBG9jp7xOrxSPKUtq5fahE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mika Westerberg , Lukas Wunner , Sasha Levin Subject: [PATCH 4.19 55/81] thunderbolt: Drop duplicated get_switch_at_route() Date: Tue, 26 May 2020 20:53:30 +0200 Message-Id: <20200526183933.179031466@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526183923.108515292@linuxfoundation.org> References: <20200526183923.108515292@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mika Westerberg [ Upstream commit 8f965efd215a09c20b0b5e5bb4e20009a954472e ] tb_switch_find_by_route() does the same already so use it instead and remove duplicated get_switch_at_route(). Signed-off-by: Mika Westerberg Reviewed-by: Lukas Wunner Signed-off-by: Sasha Levin --- drivers/thunderbolt/icm.c | 12 ++++++++---- drivers/thunderbolt/switch.c | 18 ------------------ drivers/thunderbolt/tb.c | 9 ++++++--- drivers/thunderbolt/tb.h | 1 - 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c index 8490a1b6b615..2b83d8b02f81 100644 --- a/drivers/thunderbolt/icm.c +++ b/drivers/thunderbolt/icm.c @@ -801,9 +801,11 @@ icm_fr_xdomain_connected(struct tb *tb, const struct icm_pkg_header *hdr) * connected another host to the same port, remove the switch * first. */ - sw = get_switch_at_route(tb->root_switch, route); - if (sw) + sw = tb_switch_find_by_route(tb, route); + if (sw) { remove_switch(sw); + tb_switch_put(sw); + } sw = tb_switch_find_by_link_depth(tb, link, depth); if (!sw) { @@ -1146,9 +1148,11 @@ icm_tr_xdomain_connected(struct tb *tb, const struct icm_pkg_header *hdr) * connected another host to the same port, remove the switch * first. */ - sw = get_switch_at_route(tb->root_switch, route); - if (sw) + sw = tb_switch_find_by_route(tb, route); + if (sw) { remove_switch(sw); + tb_switch_put(sw); + } sw = tb_switch_find_by_route(tb, get_parent_route(route)); if (!sw) { diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index 42d90ceec279..010a50ac4881 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -664,24 +664,6 @@ int tb_switch_reset(struct tb *tb, u64 route) return res.err; } -struct tb_switch *get_switch_at_route(struct tb_switch *sw, u64 route) -{ - u8 next_port = route; /* - * Routes use a stride of 8 bits, - * eventhough a port index has 6 bits at most. - * */ - if (route == 0) - return sw; - if (next_port > sw->config.max_port_number) - return NULL; - if (tb_is_upstream_port(&sw->ports[next_port])) - return NULL; - if (!sw->ports[next_port].remote) - return NULL; - return get_switch_at_route(sw->ports[next_port].remote->sw, - route >> TB_ROUTE_SHIFT); -} - /** * tb_plug_events_active() - enable/disable plug events on a switch * diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index 1424581fd9af..146f261bf2c3 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -258,7 +258,7 @@ static void tb_handle_hotplug(struct work_struct *work) if (!tcm->hotplug_active) goto out; /* during init, suspend or shutdown */ - sw = get_switch_at_route(tb->root_switch, ev->route); + sw = tb_switch_find_by_route(tb, ev->route); if (!sw) { tb_warn(tb, "hotplug event from non existent switch %llx:%x (unplug: %d)\n", @@ -269,14 +269,14 @@ static void tb_handle_hotplug(struct work_struct *work) tb_warn(tb, "hotplug event from non existent port %llx:%x (unplug: %d)\n", ev->route, ev->port, ev->unplug); - goto out; + goto put_sw; } port = &sw->ports[ev->port]; if (tb_is_upstream_port(port)) { tb_warn(tb, "hotplug event for upstream port %llx:%x (unplug: %d)\n", ev->route, ev->port, ev->unplug); - goto out; + goto put_sw; } if (ev->unplug) { if (port->remote) { @@ -306,6 +306,9 @@ static void tb_handle_hotplug(struct work_struct *work) tb_activate_pcie_devices(tb); } } + +put_sw: + tb_switch_put(sw); out: mutex_unlock(&tb->lock); kfree(ev); diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index 7a0ee9836a8a..d927cf7b14d2 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -397,7 +397,6 @@ void tb_switch_suspend(struct tb_switch *sw); int tb_switch_resume(struct tb_switch *sw); int tb_switch_reset(struct tb *tb, u64 route); void tb_sw_set_unplugged(struct tb_switch *sw); -struct tb_switch *get_switch_at_route(struct tb_switch *sw, u64 route); struct tb_switch *tb_switch_find_by_link_depth(struct tb *tb, u8 link, u8 depth); struct tb_switch *tb_switch_find_by_uuid(struct tb *tb, const uuid_t *uuid); -- 2.25.1