Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Alex Elder <elder@linaro.org>
Link: https://lore.kernel.org/r/26425379d3eb9ba1b9af44468576ee20c77eb248.1705226208.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Christophe JAILLET and committed by
Greg Kroah-Hartman
3bd29138 664c89c5

+16 -17
+4 -4
drivers/greybus/es2.c
··· 513 513 514 514 if (cport_id < 0) { 515 515 ida_start = 0; 516 - ida_end = hd->num_cports; 516 + ida_end = hd->num_cports - 1; 517 517 } else if (cport_id < hd->num_cports) { 518 518 ida_start = cport_id; 519 - ida_end = cport_id + 1; 519 + ida_end = cport_id; 520 520 } else { 521 521 dev_err(&hd->dev, "cport %d not available\n", cport_id); 522 522 return -EINVAL; 523 523 } 524 524 525 - return ida_simple_get(id_map, ida_start, ida_end, GFP_KERNEL); 525 + return ida_alloc_range(id_map, ida_start, ida_end, GFP_KERNEL); 526 526 } 527 527 528 528 static void es2_cport_release(struct gb_host_device *hd, u16 cport_id) ··· 535 535 return; 536 536 } 537 537 538 - ida_simple_remove(&hd->cport_id_map, cport_id); 538 + ida_free(&hd->cport_id_map, cport_id); 539 539 } 540 540 541 541 static int cport_enable(struct gb_host_device *hd, u16 cport_id,
+8 -8
drivers/greybus/hd.c
··· 50 50 struct ida *id_map = &hd->cport_id_map; 51 51 int ret; 52 52 53 - ret = ida_simple_get(id_map, cport_id, cport_id + 1, GFP_KERNEL); 53 + ret = ida_alloc_range(id_map, cport_id, cport_id, GFP_KERNEL); 54 54 if (ret < 0) { 55 55 dev_err(&hd->dev, "failed to reserve cport %u\n", cport_id); 56 56 return ret; ··· 64 64 { 65 65 struct ida *id_map = &hd->cport_id_map; 66 66 67 - ida_simple_remove(id_map, cport_id); 67 + ida_free(id_map, cport_id); 68 68 } 69 69 EXPORT_SYMBOL_GPL(gb_hd_cport_release_reserved); 70 70 ··· 80 80 81 81 if (cport_id < 0) { 82 82 ida_start = 0; 83 - ida_end = hd->num_cports; 83 + ida_end = hd->num_cports - 1; 84 84 } else if (cport_id < hd->num_cports) { 85 85 ida_start = cport_id; 86 - ida_end = cport_id + 1; 86 + ida_end = cport_id; 87 87 } else { 88 88 dev_err(&hd->dev, "cport %d not available\n", cport_id); 89 89 return -EINVAL; 90 90 } 91 91 92 - return ida_simple_get(id_map, ida_start, ida_end, GFP_KERNEL); 92 + return ida_alloc_range(id_map, ida_start, ida_end, GFP_KERNEL); 93 93 } 94 94 95 95 /* Locking: Caller guarantees serialisation */ ··· 100 100 return; 101 101 } 102 102 103 - ida_simple_remove(&hd->cport_id_map, cport_id); 103 + ida_free(&hd->cport_id_map, cport_id); 104 104 } 105 105 106 106 static void gb_hd_release(struct device *dev) ··· 111 111 112 112 if (hd->svc) 113 113 gb_svc_put(hd->svc); 114 - ida_simple_remove(&gb_hd_bus_id_map, hd->bus_id); 114 + ida_free(&gb_hd_bus_id_map, hd->bus_id); 115 115 ida_destroy(&hd->cport_id_map); 116 116 kfree(hd); 117 117 } ··· 162 162 if (!hd) 163 163 return ERR_PTR(-ENOMEM); 164 164 165 - ret = ida_simple_get(&gb_hd_bus_id_map, 1, 0, GFP_KERNEL); 165 + ret = ida_alloc_min(&gb_hd_bus_id_map, 1, GFP_KERNEL); 166 166 if (ret < 0) { 167 167 kfree(hd); 168 168 return ERR_PTR(ret);
+4 -5
drivers/greybus/interface.c
··· 131 131 int ret; 132 132 133 133 /* Allocate an interface device id. */ 134 - ret = ida_simple_get(&svc->device_id_map, 135 - GB_SVC_DEVICE_ID_MIN, GB_SVC_DEVICE_ID_MAX + 1, 136 - GFP_KERNEL); 134 + ret = ida_alloc_range(&svc->device_id_map, GB_SVC_DEVICE_ID_MIN, 135 + GB_SVC_DEVICE_ID_MAX, GFP_KERNEL); 137 136 if (ret < 0) { 138 137 dev_err(&intf->dev, "failed to allocate device id: %d\n", ret); 139 138 return ret; ··· 164 165 * XXX anymore. 165 166 */ 166 167 err_ida_remove: 167 - ida_simple_remove(&svc->device_id_map, device_id); 168 + ida_free(&svc->device_id_map, device_id); 168 169 169 170 return ret; 170 171 } ··· 177 178 return; 178 179 179 180 gb_svc_route_destroy(svc, svc->ap_intf_id, intf->interface_id); 180 - ida_simple_remove(&svc->device_id_map, intf->device_id); 181 + ida_free(&svc->device_id_map, intf->device_id); 181 182 intf->device_id = GB_INTERFACE_DEVICE_ID_BAD; 182 183 } 183 184