thunderbolt: Add tb_switch_get()
authorMika Westerberg <mika.westerberg@linux.intel.com>
Wed, 4 Oct 2017 12:19:20 +0000 (15:19 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Fri, 9 Mar 2018 09:54:10 +0000 (12:54 +0300)
Sometimes there is need for increasing reference count of a switch as
well. This also follows what we have for xdomains.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
drivers/thunderbolt/tb.h

index 895c57a0a090b4f1ab958bf8caf1f46f3e78ad63..c7bd77e9c2c32c0a8393047f727e6554b90386be 100644 (file)
@@ -387,6 +387,13 @@ 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);
 
+static inline struct tb_switch *tb_switch_get(struct tb_switch *sw)
+{
+       if (sw)
+               get_device(&sw->dev);
+       return sw;
+}
+
 static inline void tb_switch_put(struct tb_switch *sw)
 {
        put_device(&sw->dev);