]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
devlink: push common code to __pr_out_port_handle_start_tb()
authorJiri Pirko <jiri@nvidia.com>
Mon, 5 Dec 2022 12:21:57 +0000 (13:21 +0100)
committerDavid Ahern <dsahern@kernel.org>
Thu, 8 Dec 2022 17:47:44 +0000 (10:47 -0700)
There is a common code in pr_out_port_handle_start() and
pr_out_port_handle_start_arr(). As the next patch is going to extend it
even more, push the code into common helper.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
devlink/devlink.c

index af5f140392ba37382ef36c7ab58750b721c80f8a..93d83a079febaf87de6ca8b576075da4633d6ba9 100644 (file)
@@ -2764,7 +2764,8 @@ static void __pr_out_port_handle_start(struct dl *dl, const char *bus_name,
        }
 }
 
-static void pr_out_port_handle_start(struct dl *dl, struct nlattr **tb, bool try_nice)
+static void __pr_out_port_handle_start_tb(struct dl *dl, struct nlattr **tb,
+                                         bool try_nice, bool array)
 {
        const char *bus_name;
        const char *dev_name;
@@ -2773,19 +2774,17 @@ static void pr_out_port_handle_start(struct dl *dl, struct nlattr **tb, bool try
        bus_name = mnl_attr_get_str(tb[DEVLINK_ATTR_BUS_NAME]);
        dev_name = mnl_attr_get_str(tb[DEVLINK_ATTR_DEV_NAME]);
        port_index = mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_INDEX]);
-       __pr_out_port_handle_start(dl, bus_name, dev_name, port_index, try_nice, false);
+       __pr_out_port_handle_start(dl, bus_name, dev_name, port_index, try_nice, array);
 }
 
-static void pr_out_port_handle_start_arr(struct dl *dl, struct nlattr **tb, bool try_nice)
+static void pr_out_port_handle_start(struct dl *dl, struct nlattr **tb, bool try_nice)
 {
-       const char *bus_name;
-       const char *dev_name;
-       uint32_t port_index;
+       __pr_out_port_handle_start_tb(dl, tb, try_nice, false);
+}
 
-       bus_name = mnl_attr_get_str(tb[DEVLINK_ATTR_BUS_NAME]);
-       dev_name = mnl_attr_get_str(tb[DEVLINK_ATTR_DEV_NAME]);
-       port_index = mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_INDEX]);
-       __pr_out_port_handle_start(dl, bus_name, dev_name, port_index, try_nice, true);
+static void pr_out_port_handle_start_arr(struct dl *dl, struct nlattr **tb, bool try_nice)
+{
+       __pr_out_port_handle_start_tb(dl, tb, try_nice, true);
 }
 
 static void pr_out_port_handle_end(struct dl *dl)