Skip to content

Commit

Permalink
thunderbolt: Rework tb_tunnel_consumed_bandwidth()
Browse files Browse the repository at this point in the history
Rework to avoid the goto as it only makes it confusing. Move logging to
happen at the end so we can see all the tunnels this is being called.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
  • Loading branch information
Mika Westerberg committed Jan 3, 2025
1 parent 5ae3677 commit a70cd9c
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions drivers/thunderbolt/tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -2361,26 +2361,20 @@ int tb_tunnel_consumed_bandwidth(struct tb_tunnel *tunnel, int *consumed_up,
{
int up_bw = 0, down_bw = 0;

if (!tb_tunnel_is_active(tunnel))
goto out;

if (tunnel->consumed_bandwidth) {
if (tb_tunnel_is_active(tunnel) && tunnel->consumed_bandwidth) {
int ret;

ret = tunnel->consumed_bandwidth(tunnel, &up_bw, &down_bw);
if (ret)
return ret;

tb_tunnel_dbg(tunnel, "consumed bandwidth %d/%d Mb/s\n", up_bw,
down_bw);
}

out:
if (consumed_up)
*consumed_up = up_bw;
if (consumed_down)
*consumed_down = down_bw;

tb_tunnel_dbg(tunnel, "consumed bandwidth %d/%d Mb/s\n", up_bw, down_bw);
return 0;
}

Expand Down

0 comments on commit a70cd9c

Please sign in to comment.