Commit 3bd29138 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Greg Kroah-Hartman

greybus: 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>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
Link: https://lore.kernel.org/r/26425379d3eb9ba1b9af44468576ee20c77eb248.1705226208.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 664c89c5
...@@ -513,16 +513,16 @@ static int es2_cport_allocate(struct gb_host_device *hd, int cport_id, ...@@ -513,16 +513,16 @@ static int es2_cport_allocate(struct gb_host_device *hd, int cport_id,
if (cport_id < 0) { if (cport_id < 0) {
ida_start = 0; ida_start = 0;
ida_end = hd->num_cports; ida_end = hd->num_cports - 1;
} else if (cport_id < hd->num_cports) { } else if (cport_id < hd->num_cports) {
ida_start = cport_id; ida_start = cport_id;
ida_end = cport_id + 1; ida_end = cport_id;
} else { } else {
dev_err(&hd->dev, "cport %d not available\n", cport_id); dev_err(&hd->dev, "cport %d not available\n", cport_id);
return -EINVAL; return -EINVAL;
} }
return ida_simple_get(id_map, ida_start, ida_end, GFP_KERNEL); return ida_alloc_range(id_map, ida_start, ida_end, GFP_KERNEL);
} }
static void es2_cport_release(struct gb_host_device *hd, u16 cport_id) static void es2_cport_release(struct gb_host_device *hd, u16 cport_id)
...@@ -535,7 +535,7 @@ static void es2_cport_release(struct gb_host_device *hd, u16 cport_id) ...@@ -535,7 +535,7 @@ static void es2_cport_release(struct gb_host_device *hd, u16 cport_id)
return; return;
} }
ida_simple_remove(&hd->cport_id_map, cport_id); ida_free(&hd->cport_id_map, cport_id);
} }
static int cport_enable(struct gb_host_device *hd, u16 cport_id, static int cport_enable(struct gb_host_device *hd, u16 cport_id,
......
...@@ -50,7 +50,7 @@ int gb_hd_cport_reserve(struct gb_host_device *hd, u16 cport_id) ...@@ -50,7 +50,7 @@ int gb_hd_cport_reserve(struct gb_host_device *hd, u16 cport_id)
struct ida *id_map = &hd->cport_id_map; struct ida *id_map = &hd->cport_id_map;
int ret; int ret;
ret = ida_simple_get(id_map, cport_id, cport_id + 1, GFP_KERNEL); ret = ida_alloc_range(id_map, cport_id, cport_id, GFP_KERNEL);
if (ret < 0) { if (ret < 0) {
dev_err(&hd->dev, "failed to reserve cport %u\n", cport_id); dev_err(&hd->dev, "failed to reserve cport %u\n", cport_id);
return ret; return ret;
...@@ -64,7 +64,7 @@ void gb_hd_cport_release_reserved(struct gb_host_device *hd, u16 cport_id) ...@@ -64,7 +64,7 @@ void gb_hd_cport_release_reserved(struct gb_host_device *hd, u16 cport_id)
{ {
struct ida *id_map = &hd->cport_id_map; struct ida *id_map = &hd->cport_id_map;
ida_simple_remove(id_map, cport_id); ida_free(id_map, cport_id);
} }
EXPORT_SYMBOL_GPL(gb_hd_cport_release_reserved); EXPORT_SYMBOL_GPL(gb_hd_cport_release_reserved);
...@@ -80,16 +80,16 @@ int gb_hd_cport_allocate(struct gb_host_device *hd, int cport_id, ...@@ -80,16 +80,16 @@ int gb_hd_cport_allocate(struct gb_host_device *hd, int cport_id,
if (cport_id < 0) { if (cport_id < 0) {
ida_start = 0; ida_start = 0;
ida_end = hd->num_cports; ida_end = hd->num_cports - 1;
} else if (cport_id < hd->num_cports) { } else if (cport_id < hd->num_cports) {
ida_start = cport_id; ida_start = cport_id;
ida_end = cport_id + 1; ida_end = cport_id;
} else { } else {
dev_err(&hd->dev, "cport %d not available\n", cport_id); dev_err(&hd->dev, "cport %d not available\n", cport_id);
return -EINVAL; return -EINVAL;
} }
return ida_simple_get(id_map, ida_start, ida_end, GFP_KERNEL); return ida_alloc_range(id_map, ida_start, ida_end, GFP_KERNEL);
} }
/* Locking: Caller guarantees serialisation */ /* Locking: Caller guarantees serialisation */
...@@ -100,7 +100,7 @@ void gb_hd_cport_release(struct gb_host_device *hd, u16 cport_id) ...@@ -100,7 +100,7 @@ void gb_hd_cport_release(struct gb_host_device *hd, u16 cport_id)
return; return;
} }
ida_simple_remove(&hd->cport_id_map, cport_id); ida_free(&hd->cport_id_map, cport_id);
} }
static void gb_hd_release(struct device *dev) static void gb_hd_release(struct device *dev)
...@@ -111,7 +111,7 @@ static void gb_hd_release(struct device *dev) ...@@ -111,7 +111,7 @@ static void gb_hd_release(struct device *dev)
if (hd->svc) if (hd->svc)
gb_svc_put(hd->svc); gb_svc_put(hd->svc);
ida_simple_remove(&gb_hd_bus_id_map, hd->bus_id); ida_free(&gb_hd_bus_id_map, hd->bus_id);
ida_destroy(&hd->cport_id_map); ida_destroy(&hd->cport_id_map);
kfree(hd); kfree(hd);
} }
...@@ -162,7 +162,7 @@ struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver, ...@@ -162,7 +162,7 @@ struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver,
if (!hd) if (!hd)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ret = ida_simple_get(&gb_hd_bus_id_map, 1, 0, GFP_KERNEL); ret = ida_alloc_min(&gb_hd_bus_id_map, 1, GFP_KERNEL);
if (ret < 0) { if (ret < 0) {
kfree(hd); kfree(hd);
return ERR_PTR(ret); return ERR_PTR(ret);
......
...@@ -131,9 +131,8 @@ static int gb_interface_route_create(struct gb_interface *intf) ...@@ -131,9 +131,8 @@ static int gb_interface_route_create(struct gb_interface *intf)
int ret; int ret;
/* Allocate an interface device id. */ /* Allocate an interface device id. */
ret = ida_simple_get(&svc->device_id_map, ret = ida_alloc_range(&svc->device_id_map, GB_SVC_DEVICE_ID_MIN,
GB_SVC_DEVICE_ID_MIN, GB_SVC_DEVICE_ID_MAX + 1, GB_SVC_DEVICE_ID_MAX, GFP_KERNEL);
GFP_KERNEL);
if (ret < 0) { if (ret < 0) {
dev_err(&intf->dev, "failed to allocate device id: %d\n", ret); dev_err(&intf->dev, "failed to allocate device id: %d\n", ret);
return ret; return ret;
...@@ -165,7 +164,7 @@ static int gb_interface_route_create(struct gb_interface *intf) ...@@ -165,7 +164,7 @@ static int gb_interface_route_create(struct gb_interface *intf)
* XXX anymore. * XXX anymore.
*/ */
err_ida_remove: err_ida_remove:
ida_simple_remove(&svc->device_id_map, device_id); ida_free(&svc->device_id_map, device_id);
return ret; return ret;
} }
...@@ -178,7 +177,7 @@ static void gb_interface_route_destroy(struct gb_interface *intf) ...@@ -178,7 +177,7 @@ static void gb_interface_route_destroy(struct gb_interface *intf)
return; return;
gb_svc_route_destroy(svc, svc->ap_intf_id, intf->interface_id); gb_svc_route_destroy(svc, svc->ap_intf_id, intf->interface_id);
ida_simple_remove(&svc->device_id_map, intf->device_id); ida_free(&svc->device_id_map, intf->device_id);
intf->device_id = GB_INTERFACE_DEVICE_ID_BAD; intf->device_id = GB_INTERFACE_DEVICE_ID_BAD;
} }
......
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