summaryrefslogtreecommitdiff
path: root/net/devlink/devl_internal.h
diff options
context:
space:
mode:
authorJiri Pirko <jiri@nvidia.com>2026-03-12 11:04:04 +0100
committerJakub Kicinski <kuba@kernel.org>2026-03-14 13:08:49 -0700
commita4c6d53e5fd61829f707b7a723dd2937ed67c803 (patch)
treecb8800f34361550c64f4694ff31f54c9fb66cffd /net/devlink/devl_internal.h
parent104733e1303efcec97c9a581adabbc03c6679006 (diff)
devlink: allow devlink instance allocation without a backing device
Allow devlink_alloc_ns() to be called with dev=NULL to support device-less devlink instances. When dev is NULL, the instance is identified over netlink using "devlink_index" as bus_name and the decimal index value as dev_name. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Link: https://patch.msgid.link/20260312100407.551173-11-jiri@resnulli.us Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/devlink/devl_internal.h')
-rw-r--r--net/devlink/devl_internal.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h
index cb2ffef1ac2d..7dfb7cdd2d23 100644
--- a/net/devlink/devl_internal.h
+++ b/net/devlink/devl_internal.h
@@ -49,6 +49,7 @@ struct devlink {
struct xarray snapshot_ids;
struct devlink_dev_stats stats;
struct device *dev;
+ const char *dev_name_index;
const struct device_driver *dev_driver;
possible_net_t _net;
/* Serializes access to devlink instance specific objects such as
@@ -119,7 +120,7 @@ static inline bool devl_is_registered(struct devlink *devlink)
static inline void devl_dev_lock(struct devlink *devlink, bool dev_lock)
{
- if (dev_lock)
+ if (dev_lock && devlink->dev)
device_lock(devlink->dev);
devl_lock(devlink);
}
@@ -127,7 +128,7 @@ static inline void devl_dev_lock(struct devlink *devlink, bool dev_lock)
static inline void devl_dev_unlock(struct devlink *devlink, bool dev_lock)
{
devl_unlock(devlink);
- if (dev_lock)
+ if (dev_lock && devlink->dev)
device_unlock(devlink->dev);
}