diff options
author | Jiri Pirko <jiri@nvidia.com> | 2022-09-29 09:28:57 +0200 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-09-30 18:17:16 -0700 |
commit | 081adcfe930e4b01a55eaa329b2e453a442f35a9 (patch) | |
tree | 6ccbdc692a2a064b8d89a6d483035c690040a3e0 /net | |
parent | 3fcb698d9c773d1e0ce5eb4374273457eb4c8338 (diff) | |
download | linux-081adcfe930e4b01a55eaa329b2e453a442f35a9.tar.bz2 |
net: devlink: introduce a flag to indicate devlink port being registered
Instead of relying on devlink pointer not being initialized, introduce
an extra flag to indicate if devlink port is registered. This is needed
as later on devlink pointer is going to be initialized even in case
devlink port is not registered yet.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/devlink.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c index f5bfbdb0301e..17529e6b2bbf 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -372,9 +372,9 @@ static struct devlink *devlink_get_from_attrs(struct net *net, } #define ASSERT_DEVLINK_PORT_REGISTERED(devlink_port) \ - WARN_ON_ONCE(!(devlink_port)->devlink) + WARN_ON_ONCE(!(devlink_port)->registered) #define ASSERT_DEVLINK_PORT_NOT_REGISTERED(devlink_port) \ - WARN_ON_ONCE((devlink_port)->devlink) + WARN_ON_ONCE((devlink_port)->registered) static struct devlink_port *devlink_port_get_by_index(struct devlink *devlink, unsigned int port_index) @@ -9876,6 +9876,7 @@ int devl_port_register(struct devlink *devlink, ASSERT_DEVLINK_PORT_NOT_REGISTERED(devlink_port); + devlink_port->registered = true; devlink_port->devlink = devlink; devlink_port->index = port_index; spin_lock_init(&devlink_port->type_lock); @@ -9934,6 +9935,7 @@ void devl_port_unregister(struct devlink_port *devlink_port) WARN_ON(!list_empty(&devlink_port->reporter_list)); WARN_ON(!list_empty(&devlink_port->region_list)); mutex_destroy(&devlink_port->reporters_lock); + devlink_port->registered = false; } EXPORT_SYMBOL_GPL(devl_port_unregister); |