Commit 363096a2 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by David S. Miller

nfp: flower: Remove usage of the deprecated ida_simple_xx() API

ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().

This is less verbose.

Note that the upper bound of ida_alloc_range() is inclusive while the one
of ida_simple_get() was exclusive.
So NFP_FL_LAG_GROUP_MAX has been decreased by 1. It now better watch the
comment stating that "1 to 31 are valid".

The only other user of NFP_FL_LAG_GROUP_MAX has been updated accordingly in
nfp_fl_lag_put_unprocessed().
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 948f97f9
...@@ -76,7 +76,7 @@ struct nfp_fl_lag_group { ...@@ -76,7 +76,7 @@ struct nfp_fl_lag_group {
/* Use this ID with zero members to ack a batch config */ /* Use this ID with zero members to ack a batch config */
#define NFP_FL_LAG_SYNC_ID 0 #define NFP_FL_LAG_SYNC_ID 0
#define NFP_FL_LAG_GROUP_MIN 1 /* ID 0 reserved */ #define NFP_FL_LAG_GROUP_MIN 1 /* ID 0 reserved */
#define NFP_FL_LAG_GROUP_MAX 32 /* IDs 1 to 31 are valid */ #define NFP_FL_LAG_GROUP_MAX 31 /* IDs 1 to 31 are valid */
/* wait for more config */ /* wait for more config */
#define NFP_FL_LAG_DELAY (msecs_to_jiffies(2)) #define NFP_FL_LAG_DELAY (msecs_to_jiffies(2))
...@@ -111,8 +111,8 @@ nfp_fl_lag_group_create(struct nfp_fl_lag *lag, struct net_device *master) ...@@ -111,8 +111,8 @@ nfp_fl_lag_group_create(struct nfp_fl_lag *lag, struct net_device *master)
priv = container_of(lag, struct nfp_flower_priv, nfp_lag); priv = container_of(lag, struct nfp_flower_priv, nfp_lag);
id = ida_simple_get(&lag->ida_handle, NFP_FL_LAG_GROUP_MIN, id = ida_alloc_range(&lag->ida_handle, NFP_FL_LAG_GROUP_MIN,
NFP_FL_LAG_GROUP_MAX, GFP_KERNEL); NFP_FL_LAG_GROUP_MAX, GFP_KERNEL);
if (id < 0) { if (id < 0) {
nfp_flower_cmsg_warn(priv->app, nfp_flower_cmsg_warn(priv->app,
"No more bonding groups available\n"); "No more bonding groups available\n");
...@@ -121,7 +121,7 @@ nfp_fl_lag_group_create(struct nfp_fl_lag *lag, struct net_device *master) ...@@ -121,7 +121,7 @@ nfp_fl_lag_group_create(struct nfp_fl_lag *lag, struct net_device *master)
group = kmalloc(sizeof(*group), GFP_KERNEL); group = kmalloc(sizeof(*group), GFP_KERNEL);
if (!group) { if (!group) {
ida_simple_remove(&lag->ida_handle, id); ida_free(&lag->ida_handle, id);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
...@@ -328,8 +328,7 @@ static void nfp_fl_lag_do_work(struct work_struct *work) ...@@ -328,8 +328,7 @@ static void nfp_fl_lag_do_work(struct work_struct *work)
} }
if (entry->to_destroy) { if (entry->to_destroy) {
ida_simple_remove(&lag->ida_handle, ida_free(&lag->ida_handle, entry->group_id);
entry->group_id);
list_del(&entry->list); list_del(&entry->list);
kfree(entry); kfree(entry);
} }
...@@ -415,7 +414,7 @@ nfp_fl_lag_put_unprocessed(struct nfp_fl_lag *lag, struct sk_buff *skb) ...@@ -415,7 +414,7 @@ nfp_fl_lag_put_unprocessed(struct nfp_fl_lag *lag, struct sk_buff *skb)
struct nfp_flower_cmsg_lag_config *cmsg_payload; struct nfp_flower_cmsg_lag_config *cmsg_payload;
cmsg_payload = nfp_flower_cmsg_get_data(skb); cmsg_payload = nfp_flower_cmsg_get_data(skb);
if (be32_to_cpu(cmsg_payload->group_id) >= NFP_FL_LAG_GROUP_MAX) if (be32_to_cpu(cmsg_payload->group_id) > NFP_FL_LAG_GROUP_MAX)
return -EINVAL; return -EINVAL;
/* Drop cmsg retrans if storage limit is exceeded to prevent /* Drop cmsg retrans if storage limit is exceeded to prevent
......
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