Commit 3a10173f authored by Jiri Pirko's avatar Jiri Pirko Committed by Jakub Kicinski

devlink: remove linecard reference counting

As long as the linecard life time is protected by devlink instance
lock, the reference counting is no longer needed. Remove it.
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 5cc9049c
...@@ -193,7 +193,6 @@ struct devlink_linecard; ...@@ -193,7 +193,6 @@ struct devlink_linecard;
struct devlink_linecard * struct devlink_linecard *
devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info); devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info);
void devlink_linecard_put(struct devlink_linecard *linecard);
/* Rates */ /* Rates */
extern const struct devlink_gen_cmd devl_gen_rate_get; extern const struct devlink_gen_cmd devl_gen_rate_get;
......
...@@ -37,7 +37,6 @@ struct devlink_linecard { ...@@ -37,7 +37,6 @@ struct devlink_linecard {
struct list_head list; struct list_head list;
struct devlink *devlink; struct devlink *devlink;
unsigned int index; unsigned int index;
refcount_t refcount;
const struct devlink_linecard_ops *ops; const struct devlink_linecard_ops *ops;
void *priv; void *priv;
enum devlink_linecard_state state; enum devlink_linecard_state state;
...@@ -285,7 +284,6 @@ devlink_linecard_get_from_attrs(struct devlink *devlink, struct nlattr **attrs) ...@@ -285,7 +284,6 @@ devlink_linecard_get_from_attrs(struct devlink *devlink, struct nlattr **attrs)
linecard = devlink_linecard_get_by_index(devlink, linecard_index); linecard = devlink_linecard_get_by_index(devlink, linecard_index);
if (!linecard) if (!linecard)
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
refcount_inc(&linecard->refcount);
return linecard; return linecard;
} }
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -297,14 +295,6 @@ devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info) ...@@ -297,14 +295,6 @@ devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info)
return devlink_linecard_get_from_attrs(devlink, info->attrs); return devlink_linecard_get_from_attrs(devlink, info->attrs);
} }
void devlink_linecard_put(struct devlink_linecard *linecard)
{
if (refcount_dec_and_test(&linecard->refcount)) {
mutex_destroy(&linecard->state_lock);
kfree(linecard);
}
}
struct devlink_sb { struct devlink_sb {
struct list_head list; struct list_head list;
unsigned int index; unsigned int index;
...@@ -10265,7 +10255,6 @@ devl_linecard_create(struct devlink *devlink, unsigned int linecard_index, ...@@ -10265,7 +10255,6 @@ devl_linecard_create(struct devlink *devlink, unsigned int linecard_index,
} }
list_add_tail(&linecard->list, &devlink->linecard_list); list_add_tail(&linecard->list, &devlink->linecard_list);
refcount_set(&linecard->refcount, 1);
devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW);
return linecard; return linecard;
} }
...@@ -10281,7 +10270,8 @@ void devl_linecard_destroy(struct devlink_linecard *linecard) ...@@ -10281,7 +10270,8 @@ void devl_linecard_destroy(struct devlink_linecard *linecard)
devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_DEL); devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_DEL);
list_del(&linecard->list); list_del(&linecard->list);
devlink_linecard_types_fini(linecard); devlink_linecard_types_fini(linecard);
devlink_linecard_put(linecard); mutex_destroy(&linecard->state_lock);
kfree(linecard);
} }
EXPORT_SYMBOL_GPL(devl_linecard_destroy); EXPORT_SYMBOL_GPL(devl_linecard_destroy);
......
...@@ -170,14 +170,9 @@ static int devlink_nl_pre_doit(const struct genl_split_ops *ops, ...@@ -170,14 +170,9 @@ static int devlink_nl_pre_doit(const struct genl_split_ops *ops,
static void devlink_nl_post_doit(const struct genl_split_ops *ops, static void devlink_nl_post_doit(const struct genl_split_ops *ops,
struct sk_buff *skb, struct genl_info *info) struct sk_buff *skb, struct genl_info *info)
{ {
struct devlink_linecard *linecard;
struct devlink *devlink; struct devlink *devlink;
devlink = info->user_ptr[0]; devlink = info->user_ptr[0];
if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_LINECARD) {
linecard = info->user_ptr[1];
devlink_linecard_put(linecard);
}
devl_unlock(devlink); devl_unlock(devlink);
devlink_put(devlink); devlink_put(devlink);
} }
......
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