diff options
author | Jacob Keller | 2020-03-26 11:37:13 -0700 |
---|---|---|
committer | David S. Miller | 2020-03-26 19:39:26 -0700 |
commit | 7000108f27b1b421d388af0da0edc1d9cf13fd3c (patch) | |
tree | e2283eeececd884174542f5d5bbe123d813a7088 /net/core | |
parent | 47a39f6105d360abc8409f31fc36fac3c0925a52 (diff) |
devlink: extract snapshot id allocation to helper function
A future change is going to implement a new devlink command to request
a snapshot on demand. As part of this, the logic for handling the
snapshot ids will be refactored. To simplify the snapshot id allocation
function, move it to a separate function prefixed by `__`. This helper
function will assume the lock is held.
While no other callers will exist, it simplifies refactoring the logic
because there is no need to complicate the function with gotos to handle
unlocking on failure.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/devlink.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c index 696660b97f89..6f07fd7a67f2 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -3769,6 +3769,19 @@ out_free_msg: } /** + * __devlink_region_snapshot_id_get - get snapshot ID + * @devlink: devlink instance + * + * Returns a new snapshot id. Must be called while holding the + * devlink instance lock. + */ +static u32 __devlink_region_snapshot_id_get(struct devlink *devlink) +{ + lockdep_assert_held(&devlink->lock); + return ++devlink->snapshot_id; +} + +/** * __devlink_region_snapshot_create - create a new snapshot * This will add a new snapshot of a region. The snapshot * will be stored on the region struct and can be accessed @@ -7776,7 +7789,7 @@ u32 devlink_region_snapshot_id_get(struct devlink *devlink) u32 id; mutex_lock(&devlink->lock); - id = ++devlink->snapshot_id; + id = __devlink_region_snapshot_id_get(devlink); mutex_unlock(&devlink->lock); return id; |