forked from Minki/linux
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>
This commit is contained in:
parent
3fcb698d9c
commit
081adcfe93
@ -129,7 +129,8 @@ struct devlink_port {
|
||||
void *type_dev;
|
||||
struct devlink_port_attrs attrs;
|
||||
u8 attrs_set:1,
|
||||
switch_port:1;
|
||||
switch_port:1,
|
||||
registered:1;
|
||||
struct delayed_work type_warn_dw;
|
||||
struct list_head reporter_list;
|
||||
struct mutex reporters_lock; /* Protects reporter_list */
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user