Commit dec6a613 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Mika Westerberg

thunderbolt: 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().

Note that the upper limit of ida_simple_get() is exclusive, but the one of
ida_alloc_range()/ida_alloc_max() is inclusive. So a -1 has been added
when needed.
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
parent e8f1297b
...@@ -321,7 +321,7 @@ static void tb_domain_release(struct device *dev) ...@@ -321,7 +321,7 @@ static void tb_domain_release(struct device *dev)
tb_ctl_free(tb->ctl); tb_ctl_free(tb->ctl);
destroy_workqueue(tb->wq); destroy_workqueue(tb->wq);
ida_simple_remove(&tb_domain_ida, tb->index); ida_free(&tb_domain_ida, tb->index);
mutex_destroy(&tb->lock); mutex_destroy(&tb->lock);
kfree(tb); kfree(tb);
} }
...@@ -389,7 +389,7 @@ struct tb *tb_domain_alloc(struct tb_nhi *nhi, int timeout_msec, size_t privsize ...@@ -389,7 +389,7 @@ struct tb *tb_domain_alloc(struct tb_nhi *nhi, int timeout_msec, size_t privsize
tb->nhi = nhi; tb->nhi = nhi;
mutex_init(&tb->lock); mutex_init(&tb->lock);
tb->index = ida_simple_get(&tb_domain_ida, 0, 0, GFP_KERNEL); tb->index = ida_alloc(&tb_domain_ida, GFP_KERNEL);
if (tb->index < 0) if (tb->index < 0)
goto err_free; goto err_free;
...@@ -413,7 +413,7 @@ struct tb *tb_domain_alloc(struct tb_nhi *nhi, int timeout_msec, size_t privsize ...@@ -413,7 +413,7 @@ struct tb *tb_domain_alloc(struct tb_nhi *nhi, int timeout_msec, size_t privsize
err_destroy_wq: err_destroy_wq:
destroy_workqueue(tb->wq); destroy_workqueue(tb->wq);
err_remove_ida: err_remove_ida:
ida_simple_remove(&tb_domain_ida, tb->index); ida_free(&tb_domain_ida, tb->index);
err_free: err_free:
kfree(tb); kfree(tb);
......
...@@ -465,7 +465,7 @@ static int ring_request_msix(struct tb_ring *ring, bool no_suspend) ...@@ -465,7 +465,7 @@ static int ring_request_msix(struct tb_ring *ring, bool no_suspend)
if (!nhi->pdev->msix_enabled) if (!nhi->pdev->msix_enabled)
return 0; return 0;
ret = ida_simple_get(&nhi->msix_ida, 0, MSIX_MAX_VECS, GFP_KERNEL); ret = ida_alloc_max(&nhi->msix_ida, MSIX_MAX_VECS - 1, GFP_KERNEL);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -485,7 +485,7 @@ static int ring_request_msix(struct tb_ring *ring, bool no_suspend) ...@@ -485,7 +485,7 @@ static int ring_request_msix(struct tb_ring *ring, bool no_suspend)
return 0; return 0;
err_ida_remove: err_ida_remove:
ida_simple_remove(&nhi->msix_ida, ring->vector); ida_free(&nhi->msix_ida, ring->vector);
return ret; return ret;
} }
...@@ -496,7 +496,7 @@ static void ring_release_msix(struct tb_ring *ring) ...@@ -496,7 +496,7 @@ static void ring_release_msix(struct tb_ring *ring)
return; return;
free_irq(ring->irq, ring); free_irq(ring->irq, ring);
ida_simple_remove(&ring->nhi->msix_ida, ring->vector); ida_free(&ring->nhi->msix_ida, ring->vector);
ring->vector = 0; ring->vector = 0;
ring->irq = 0; ring->irq = 0;
} }
......
...@@ -330,7 +330,7 @@ struct tb_nvm *tb_nvm_alloc(struct device *dev) ...@@ -330,7 +330,7 @@ struct tb_nvm *tb_nvm_alloc(struct device *dev)
if (!nvm) if (!nvm)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ret = ida_simple_get(&nvm_ida, 0, 0, GFP_KERNEL); ret = ida_alloc(&nvm_ida, GFP_KERNEL);
if (ret < 0) { if (ret < 0) {
kfree(nvm); kfree(nvm);
return ERR_PTR(ret); return ERR_PTR(ret);
...@@ -528,7 +528,7 @@ void tb_nvm_free(struct tb_nvm *nvm) ...@@ -528,7 +528,7 @@ void tb_nvm_free(struct tb_nvm *nvm)
nvmem_unregister(nvm->non_active); nvmem_unregister(nvm->non_active);
nvmem_unregister(nvm->active); nvmem_unregister(nvm->active);
vfree(nvm->buf); vfree(nvm->buf);
ida_simple_remove(&nvm_ida, nvm->id); ida_free(&nvm_ida, nvm->id);
} }
kfree(nvm); kfree(nvm);
} }
......
...@@ -778,7 +778,7 @@ static int tb_port_alloc_hopid(struct tb_port *port, bool in, int min_hopid, ...@@ -778,7 +778,7 @@ static int tb_port_alloc_hopid(struct tb_port *port, bool in, int min_hopid,
if (max_hopid < 0 || max_hopid > port_max_hopid) if (max_hopid < 0 || max_hopid > port_max_hopid)
max_hopid = port_max_hopid; max_hopid = port_max_hopid;
return ida_simple_get(ida, min_hopid, max_hopid + 1, GFP_KERNEL); return ida_alloc_range(ida, min_hopid, max_hopid, GFP_KERNEL);
} }
/** /**
...@@ -816,7 +816,7 @@ int tb_port_alloc_out_hopid(struct tb_port *port, int min_hopid, int max_hopid) ...@@ -816,7 +816,7 @@ int tb_port_alloc_out_hopid(struct tb_port *port, int min_hopid, int max_hopid)
*/ */
void tb_port_release_in_hopid(struct tb_port *port, int hopid) void tb_port_release_in_hopid(struct tb_port *port, int hopid)
{ {
ida_simple_remove(&port->in_hopids, hopid); ida_free(&port->in_hopids, hopid);
} }
/** /**
...@@ -826,7 +826,7 @@ void tb_port_release_in_hopid(struct tb_port *port, int hopid) ...@@ -826,7 +826,7 @@ void tb_port_release_in_hopid(struct tb_port *port, int hopid)
*/ */
void tb_port_release_out_hopid(struct tb_port *port, int hopid) void tb_port_release_out_hopid(struct tb_port *port, int hopid)
{ {
ida_simple_remove(&port->out_hopids, hopid); ida_free(&port->out_hopids, hopid);
} }
static inline bool tb_switch_is_reachable(const struct tb_switch *parent, static inline bool tb_switch_is_reachable(const struct tb_switch *parent,
......
...@@ -997,7 +997,7 @@ static void tb_service_release(struct device *dev) ...@@ -997,7 +997,7 @@ static void tb_service_release(struct device *dev)
struct tb_xdomain *xd = tb_service_parent(svc); struct tb_xdomain *xd = tb_service_parent(svc);
tb_service_debugfs_remove(svc); tb_service_debugfs_remove(svc);
ida_simple_remove(&xd->service_ids, svc->id); ida_free(&xd->service_ids, svc->id);
kfree(svc->key); kfree(svc->key);
kfree(svc); kfree(svc);
} }
...@@ -1099,7 +1099,7 @@ static void enumerate_services(struct tb_xdomain *xd) ...@@ -1099,7 +1099,7 @@ static void enumerate_services(struct tb_xdomain *xd)
break; break;
} }
id = ida_simple_get(&xd->service_ids, 0, 0, GFP_KERNEL); id = ida_alloc(&xd->service_ids, GFP_KERNEL);
if (id < 0) { if (id < 0) {
kfree(svc->key); kfree(svc->key);
kfree(svc); kfree(svc);
......
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