Commit 1fe4085f authored by David S. Miller's avatar David S. Miller

Merge branch 'devlink-small-improvements'

Parav Pandit says:

====================
devlink small improvements

This short series improves the devlink code for lock commment,
simplifying checks and keeping the scope of mutex lock for necessary
fields.

Patch summary:
Patch-1 Keep the devlink_mutex for only for necessary changes.
Patch-2 Avoids duplicate check for reload flag
Patch-3 Adds missing comment for the scope of devlink instance lock
Patch-4 Constify devlink instance pointer
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 3fc364c0 eac5f8a9
......@@ -40,7 +40,9 @@ struct devlink {
struct xarray snapshot_ids;
struct device *dev;
possible_net_t _net;
struct mutex lock;
struct mutex lock; /* Serializes access to devlink instance specific objects such as
* port, sb, dpipe, resource, params, region, traps and more.
*/
u8 reload_failed:1,
reload_enabled:1,
registered:1;
......
......@@ -2921,7 +2921,7 @@ static void devlink_reload_netns_change(struct devlink *devlink,
DEVLINK_CMD_PARAM_NEW);
}
static bool devlink_reload_supported(struct devlink *devlink)
static bool devlink_reload_supported(const struct devlink *devlink)
{
return devlink->ops->reload_down && devlink->ops->reload_up;
}
......@@ -2967,7 +2967,7 @@ static int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info)
struct net *dest_net = NULL;
int err;
if (!devlink_reload_supported(devlink) || !devlink->reload_enabled)
if (!devlink_reload_supported(devlink))
return -EOPNOTSUPP;
err = devlink_resources_validate(devlink, NULL, info);
......@@ -7421,9 +7421,9 @@ EXPORT_SYMBOL_GPL(devlink_alloc);
*/
int devlink_register(struct devlink *devlink, struct device *dev)
{
mutex_lock(&devlink_mutex);
devlink->dev = dev;
devlink->registered = true;
mutex_lock(&devlink_mutex);
list_add_tail(&devlink->list, &devlink_list);
devlink_notify(devlink, DEVLINK_CMD_NEW);
mutex_unlock(&devlink_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment