thunderbolt: Make tb_switch_alloc() return ERR_PTR()
In order to detect possible connections to other domains we need to be able to find out why tb_switch_alloc() fails so make it return ERR_PTR() instead. This allows the caller to differentiate between errors such as -ENOMEM which comes from the kernel and for instance -EIO which comes from the hardware when trying to access the possible switch. Convert all the current call sites to handle this properly. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This commit is contained in:
@@ -148,7 +148,7 @@ static void tb_scan_port(struct tb_port *port)
|
||||
}
|
||||
sw = tb_switch_alloc(port->sw->tb, &port->sw->dev,
|
||||
tb_downstream_route(port));
|
||||
if (!sw)
|
||||
if (IS_ERR(sw))
|
||||
return;
|
||||
|
||||
if (tb_switch_configure(sw)) {
|
||||
@@ -533,8 +533,8 @@ static int tb_start(struct tb *tb)
|
||||
int ret;
|
||||
|
||||
tb->root_switch = tb_switch_alloc(tb, &tb->dev, 0);
|
||||
if (!tb->root_switch)
|
||||
return -ENOMEM;
|
||||
if (IS_ERR(tb->root_switch))
|
||||
return PTR_ERR(tb->root_switch);
|
||||
|
||||
/*
|
||||
* ICM firmware upgrade needs running firmware and in native
|
||||
|
Reference in New Issue
Block a user