Commit 5500382e authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Greg Kroah-Hartman

staging: 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, buInputt 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>
Link: https://lore.kernel.org/r/2e7bbdaf8a495bb1273396395b5c779363287581.1705350141.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5b5ea312
...@@ -44,14 +44,14 @@ int gb_audio_manager_add(struct gb_audio_manager_module_descriptor *desc) ...@@ -44,14 +44,14 @@ int gb_audio_manager_add(struct gb_audio_manager_module_descriptor *desc)
int id; int id;
int err; int err;
id = ida_simple_get(&module_id, 0, 0, GFP_KERNEL); id = ida_alloc(&module_id, GFP_KERNEL);
if (id < 0) if (id < 0)
return id; return id;
err = gb_audio_manager_module_create(&module, manager_kset, err = gb_audio_manager_module_create(&module, manager_kset,
id, desc); id, desc);
if (err) { if (err) {
ida_simple_remove(&module_id, id); ida_free(&module_id, id);
return err; return err;
} }
...@@ -78,7 +78,7 @@ int gb_audio_manager_remove(int id) ...@@ -78,7 +78,7 @@ int gb_audio_manager_remove(int id)
list_del(&module->list); list_del(&module->list);
kobject_put(&module->kobj); kobject_put(&module->kobj);
up_write(&modules_rwsem); up_write(&modules_rwsem);
ida_simple_remove(&module_id, id); ida_free(&module_id, id);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(gb_audio_manager_remove); EXPORT_SYMBOL_GPL(gb_audio_manager_remove);
...@@ -92,7 +92,7 @@ void gb_audio_manager_remove_all(void) ...@@ -92,7 +92,7 @@ void gb_audio_manager_remove_all(void)
list_for_each_entry_safe(module, next, &modules_list, list) { list_for_each_entry_safe(module, next, &modules_list, list) {
list_del(&module->list); list_del(&module->list);
ida_simple_remove(&module_id, module->id); ida_free(&module_id, module->id);
kobject_put(&module->kobj); kobject_put(&module->kobj);
} }
......
...@@ -324,7 +324,7 @@ int gb_cap_connection_init(struct gb_connection *connection) ...@@ -324,7 +324,7 @@ int gb_cap_connection_init(struct gb_connection *connection)
if (ret) if (ret)
goto err_list_del; goto err_list_del;
minor = ida_simple_get(&cap_minors_map, 0, NUM_MINORS, GFP_KERNEL); minor = ida_alloc_max(&cap_minors_map, NUM_MINORS - 1, GFP_KERNEL);
if (minor < 0) { if (minor < 0) {
ret = minor; ret = minor;
goto err_connection_disable; goto err_connection_disable;
...@@ -351,7 +351,7 @@ int gb_cap_connection_init(struct gb_connection *connection) ...@@ -351,7 +351,7 @@ int gb_cap_connection_init(struct gb_connection *connection)
err_del_cdev: err_del_cdev:
cdev_del(&cap->cdev); cdev_del(&cap->cdev);
err_remove_ida: err_remove_ida:
ida_simple_remove(&cap_minors_map, minor); ida_free(&cap_minors_map, minor);
err_connection_disable: err_connection_disable:
gb_connection_disable(connection); gb_connection_disable(connection);
err_list_del: err_list_del:
...@@ -375,7 +375,7 @@ void gb_cap_connection_exit(struct gb_connection *connection) ...@@ -375,7 +375,7 @@ void gb_cap_connection_exit(struct gb_connection *connection)
device_destroy(&cap_class, cap->dev_num); device_destroy(&cap_class, cap->dev_num);
cdev_del(&cap->cdev); cdev_del(&cap->cdev);
ida_simple_remove(&cap_minors_map, MINOR(cap->dev_num)); ida_free(&cap_minors_map, MINOR(cap->dev_num));
/* /*
* Disallow any new ioctl operations on the char device and wait for * Disallow any new ioctl operations on the char device and wait for
......
...@@ -63,8 +63,7 @@ static void fw_req_release(struct kref *kref) ...@@ -63,8 +63,7 @@ static void fw_req_release(struct kref *kref)
* just hope that it never happens. * just hope that it never happens.
*/ */
if (!fw_req->timedout) if (!fw_req->timedout)
ida_simple_remove(&fw_req->fw_download->id_map, ida_free(&fw_req->fw_download->id_map, fw_req->firmware_id);
fw_req->firmware_id);
kfree(fw_req); kfree(fw_req);
} }
...@@ -171,7 +170,7 @@ static struct fw_request *find_firmware(struct fw_download *fw_download, ...@@ -171,7 +170,7 @@ static struct fw_request *find_firmware(struct fw_download *fw_download,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
/* Allocate ids from 1 to 255 (u8-max), 0 is an invalid id */ /* Allocate ids from 1 to 255 (u8-max), 0 is an invalid id */
ret = ida_simple_get(&fw_download->id_map, 1, 256, GFP_KERNEL); ret = ida_alloc_range(&fw_download->id_map, 1, 255, GFP_KERNEL);
if (ret < 0) { if (ret < 0) {
dev_err(fw_download->parent, dev_err(fw_download->parent,
"failed to allocate firmware id (%d)\n", ret); "failed to allocate firmware id (%d)\n", ret);
...@@ -212,7 +211,7 @@ static struct fw_request *find_firmware(struct fw_download *fw_download, ...@@ -212,7 +211,7 @@ static struct fw_request *find_firmware(struct fw_download *fw_download,
return fw_req; return fw_req;
err_free_id: err_free_id:
ida_simple_remove(&fw_download->id_map, fw_req->firmware_id); ida_free(&fw_download->id_map, fw_req->firmware_id);
err_free_req: err_free_req:
kfree(fw_req); kfree(fw_req);
......
...@@ -165,7 +165,7 @@ static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt, ...@@ -165,7 +165,7 @@ static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt,
} }
/* Allocate ids from 1 to 255 (u8-max), 0 is an invalid id */ /* Allocate ids from 1 to 255 (u8-max), 0 is an invalid id */
ret = ida_simple_get(&fw_mgmt->id_map, 1, 256, GFP_KERNEL); ret = ida_alloc_range(&fw_mgmt->id_map, 1, 255, GFP_KERNEL);
if (ret < 0) { if (ret < 0) {
dev_err(fw_mgmt->parent, "failed to allocate request id (%d)\n", dev_err(fw_mgmt->parent, "failed to allocate request id (%d)\n",
ret); ret);
...@@ -180,8 +180,7 @@ static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt, ...@@ -180,8 +180,7 @@ static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt,
GB_FW_MGMT_TYPE_LOAD_AND_VALIDATE_FW, &request, GB_FW_MGMT_TYPE_LOAD_AND_VALIDATE_FW, &request,
sizeof(request), NULL, 0); sizeof(request), NULL, 0);
if (ret) { if (ret) {
ida_simple_remove(&fw_mgmt->id_map, ida_free(&fw_mgmt->id_map, fw_mgmt->intf_fw_request_id);
fw_mgmt->intf_fw_request_id);
fw_mgmt->intf_fw_request_id = 0; fw_mgmt->intf_fw_request_id = 0;
dev_err(fw_mgmt->parent, dev_err(fw_mgmt->parent,
"load and validate firmware request failed (%d)\n", "load and validate firmware request failed (%d)\n",
...@@ -220,7 +219,7 @@ static int fw_mgmt_interface_fw_loaded_operation(struct gb_operation *op) ...@@ -220,7 +219,7 @@ static int fw_mgmt_interface_fw_loaded_operation(struct gb_operation *op)
return -ENODEV; return -ENODEV;
} }
ida_simple_remove(&fw_mgmt->id_map, fw_mgmt->intf_fw_request_id); ida_free(&fw_mgmt->id_map, fw_mgmt->intf_fw_request_id);
fw_mgmt->intf_fw_request_id = 0; fw_mgmt->intf_fw_request_id = 0;
fw_mgmt->intf_fw_status = request->status; fw_mgmt->intf_fw_status = request->status;
fw_mgmt->intf_fw_major = le16_to_cpu(request->major); fw_mgmt->intf_fw_major = le16_to_cpu(request->major);
...@@ -316,7 +315,7 @@ static int fw_mgmt_backend_fw_update_operation(struct fw_mgmt *fw_mgmt, ...@@ -316,7 +315,7 @@ static int fw_mgmt_backend_fw_update_operation(struct fw_mgmt *fw_mgmt,
} }
/* Allocate ids from 1 to 255 (u8-max), 0 is an invalid id */ /* Allocate ids from 1 to 255 (u8-max), 0 is an invalid id */
ret = ida_simple_get(&fw_mgmt->id_map, 1, 256, GFP_KERNEL); ret = ida_alloc_range(&fw_mgmt->id_map, 1, 255, GFP_KERNEL);
if (ret < 0) { if (ret < 0) {
dev_err(fw_mgmt->parent, "failed to allocate request id (%d)\n", dev_err(fw_mgmt->parent, "failed to allocate request id (%d)\n",
ret); ret);
...@@ -330,8 +329,7 @@ static int fw_mgmt_backend_fw_update_operation(struct fw_mgmt *fw_mgmt, ...@@ -330,8 +329,7 @@ static int fw_mgmt_backend_fw_update_operation(struct fw_mgmt *fw_mgmt,
GB_FW_MGMT_TYPE_BACKEND_FW_UPDATE, &request, GB_FW_MGMT_TYPE_BACKEND_FW_UPDATE, &request,
sizeof(request), NULL, 0); sizeof(request), NULL, 0);
if (ret) { if (ret) {
ida_simple_remove(&fw_mgmt->id_map, ida_free(&fw_mgmt->id_map, fw_mgmt->backend_fw_request_id);
fw_mgmt->backend_fw_request_id);
fw_mgmt->backend_fw_request_id = 0; fw_mgmt->backend_fw_request_id = 0;
dev_err(fw_mgmt->parent, dev_err(fw_mgmt->parent,
"backend %s firmware update request failed (%d)\n", tag, "backend %s firmware update request failed (%d)\n", tag,
...@@ -369,7 +367,7 @@ static int fw_mgmt_backend_fw_updated_operation(struct gb_operation *op) ...@@ -369,7 +367,7 @@ static int fw_mgmt_backend_fw_updated_operation(struct gb_operation *op)
return -ENODEV; return -ENODEV;
} }
ida_simple_remove(&fw_mgmt->id_map, fw_mgmt->backend_fw_request_id); ida_free(&fw_mgmt->id_map, fw_mgmt->backend_fw_request_id);
fw_mgmt->backend_fw_request_id = 0; fw_mgmt->backend_fw_request_id = 0;
fw_mgmt->backend_fw_status = request->status; fw_mgmt->backend_fw_status = request->status;
...@@ -617,7 +615,7 @@ int gb_fw_mgmt_connection_init(struct gb_connection *connection) ...@@ -617,7 +615,7 @@ int gb_fw_mgmt_connection_init(struct gb_connection *connection)
if (ret) if (ret)
goto err_list_del; goto err_list_del;
minor = ida_simple_get(&fw_mgmt_minors_map, 0, NUM_MINORS, GFP_KERNEL); minor = ida_alloc_max(&fw_mgmt_minors_map, NUM_MINORS - 1, GFP_KERNEL);
if (minor < 0) { if (minor < 0) {
ret = minor; ret = minor;
goto err_connection_disable; goto err_connection_disable;
...@@ -645,7 +643,7 @@ int gb_fw_mgmt_connection_init(struct gb_connection *connection) ...@@ -645,7 +643,7 @@ int gb_fw_mgmt_connection_init(struct gb_connection *connection)
err_del_cdev: err_del_cdev:
cdev_del(&fw_mgmt->cdev); cdev_del(&fw_mgmt->cdev);
err_remove_ida: err_remove_ida:
ida_simple_remove(&fw_mgmt_minors_map, minor); ida_free(&fw_mgmt_minors_map, minor);
err_connection_disable: err_connection_disable:
gb_connection_disable(connection); gb_connection_disable(connection);
err_list_del: err_list_del:
...@@ -669,7 +667,7 @@ void gb_fw_mgmt_connection_exit(struct gb_connection *connection) ...@@ -669,7 +667,7 @@ void gb_fw_mgmt_connection_exit(struct gb_connection *connection)
device_destroy(&fw_mgmt_class, fw_mgmt->dev_num); device_destroy(&fw_mgmt_class, fw_mgmt->dev_num);
cdev_del(&fw_mgmt->cdev); cdev_del(&fw_mgmt->cdev);
ida_simple_remove(&fw_mgmt_minors_map, MINOR(fw_mgmt->dev_num)); ida_free(&fw_mgmt_minors_map, MINOR(fw_mgmt->dev_num));
/* /*
* Disallow any new ioctl operations on the char device and wait for * Disallow any new ioctl operations on the char device and wait for
......
...@@ -46,7 +46,7 @@ static void gbphy_dev_release(struct device *dev) ...@@ -46,7 +46,7 @@ static void gbphy_dev_release(struct device *dev)
{ {
struct gbphy_device *gbphy_dev = to_gbphy_dev(dev); struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
ida_simple_remove(&gbphy_id, gbphy_dev->id); ida_free(&gbphy_id, gbphy_dev->id);
kfree(gbphy_dev); kfree(gbphy_dev);
} }
...@@ -225,13 +225,13 @@ static struct gbphy_device *gb_gbphy_create_dev(struct gb_bundle *bundle, ...@@ -225,13 +225,13 @@ static struct gbphy_device *gb_gbphy_create_dev(struct gb_bundle *bundle,
int retval; int retval;
int id; int id;
id = ida_simple_get(&gbphy_id, 1, 0, GFP_KERNEL); id = ida_alloc_min(&gbphy_id, 1, GFP_KERNEL);
if (id < 0) if (id < 0)
return ERR_PTR(id); return ERR_PTR(id);
gbphy_dev = kzalloc(sizeof(*gbphy_dev), GFP_KERNEL); gbphy_dev = kzalloc(sizeof(*gbphy_dev), GFP_KERNEL);
if (!gbphy_dev) { if (!gbphy_dev) {
ida_simple_remove(&gbphy_id, id); ida_free(&gbphy_id, id);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
......
...@@ -1028,7 +1028,7 @@ static int gb_loopback_probe(struct gb_bundle *bundle, ...@@ -1028,7 +1028,7 @@ static int gb_loopback_probe(struct gb_bundle *bundle,
gb->file = debugfs_create_file(name, S_IFREG | 0444, gb_dev.root, gb, gb->file = debugfs_create_file(name, S_IFREG | 0444, gb_dev.root, gb,
&gb_loopback_dbgfs_latency_fops); &gb_loopback_dbgfs_latency_fops);
gb->id = ida_simple_get(&loopback_ida, 0, 0, GFP_KERNEL); gb->id = ida_alloc(&loopback_ida, GFP_KERNEL);
if (gb->id < 0) { if (gb->id < 0) {
retval = gb->id; retval = gb->id;
goto out_debugfs_remove; goto out_debugfs_remove;
...@@ -1079,7 +1079,7 @@ static int gb_loopback_probe(struct gb_bundle *bundle, ...@@ -1079,7 +1079,7 @@ static int gb_loopback_probe(struct gb_bundle *bundle,
out_connection_disable: out_connection_disable:
gb_connection_disable(connection); gb_connection_disable(connection);
out_ida_remove: out_ida_remove:
ida_simple_remove(&loopback_ida, gb->id); ida_free(&loopback_ida, gb->id);
out_debugfs_remove: out_debugfs_remove:
debugfs_remove(gb->file); debugfs_remove(gb->file);
out_connection_destroy: out_connection_destroy:
...@@ -1121,7 +1121,7 @@ static void gb_loopback_disconnect(struct gb_bundle *bundle) ...@@ -1121,7 +1121,7 @@ static void gb_loopback_disconnect(struct gb_bundle *bundle)
spin_unlock_irqrestore(&gb_dev.lock, flags); spin_unlock_irqrestore(&gb_dev.lock, flags);
device_unregister(gb->dev); device_unregister(gb->dev);
ida_simple_remove(&loopback_ida, gb->id); ida_free(&loopback_ida, gb->id);
gb_connection_destroy(gb->connection); gb_connection_destroy(gb->connection);
kfree(gb); kfree(gb);
......
...@@ -181,7 +181,7 @@ static int gb_raw_probe(struct gb_bundle *bundle, ...@@ -181,7 +181,7 @@ static int gb_raw_probe(struct gb_bundle *bundle,
raw->connection = connection; raw->connection = connection;
greybus_set_drvdata(bundle, raw); greybus_set_drvdata(bundle, raw);
minor = ida_simple_get(&minors, 0, 0, GFP_KERNEL); minor = ida_alloc(&minors, GFP_KERNEL);
if (minor < 0) { if (minor < 0) {
retval = minor; retval = minor;
goto error_connection_destroy; goto error_connection_destroy;
...@@ -214,7 +214,7 @@ static int gb_raw_probe(struct gb_bundle *bundle, ...@@ -214,7 +214,7 @@ static int gb_raw_probe(struct gb_bundle *bundle,
gb_connection_disable(connection); gb_connection_disable(connection);
error_remove_ida: error_remove_ida:
ida_simple_remove(&minors, minor); ida_free(&minors, minor);
error_connection_destroy: error_connection_destroy:
gb_connection_destroy(connection); gb_connection_destroy(connection);
...@@ -235,7 +235,7 @@ static void gb_raw_disconnect(struct gb_bundle *bundle) ...@@ -235,7 +235,7 @@ static void gb_raw_disconnect(struct gb_bundle *bundle)
device_destroy(&raw_class, raw->dev); device_destroy(&raw_class, raw->dev);
cdev_del(&raw->cdev); cdev_del(&raw->cdev);
gb_connection_disable(connection); gb_connection_disable(connection);
ida_simple_remove(&minors, MINOR(raw->dev)); ida_free(&minors, MINOR(raw->dev));
gb_connection_destroy(connection); gb_connection_destroy(connection);
mutex_lock(&raw->list_lock); mutex_lock(&raw->list_lock);
......
...@@ -153,7 +153,7 @@ static int gb_vibrator_probe(struct gb_bundle *bundle, ...@@ -153,7 +153,7 @@ static int gb_vibrator_probe(struct gb_bundle *bundle,
* there is a "real" device somewhere in the kernel for this, but I * there is a "real" device somewhere in the kernel for this, but I
* can't find it at the moment... * can't find it at the moment...
*/ */
vib->minor = ida_simple_get(&minors, 0, 0, GFP_KERNEL); vib->minor = ida_alloc(&minors, GFP_KERNEL);
if (vib->minor < 0) { if (vib->minor < 0) {
retval = vib->minor; retval = vib->minor;
goto err_connection_disable; goto err_connection_disable;
...@@ -173,7 +173,7 @@ static int gb_vibrator_probe(struct gb_bundle *bundle, ...@@ -173,7 +173,7 @@ static int gb_vibrator_probe(struct gb_bundle *bundle,
return 0; return 0;
err_ida_remove: err_ida_remove:
ida_simple_remove(&minors, vib->minor); ida_free(&minors, vib->minor);
err_connection_disable: err_connection_disable:
gb_connection_disable(connection); gb_connection_disable(connection);
err_connection_destroy: err_connection_destroy:
...@@ -197,7 +197,7 @@ static void gb_vibrator_disconnect(struct gb_bundle *bundle) ...@@ -197,7 +197,7 @@ static void gb_vibrator_disconnect(struct gb_bundle *bundle)
turn_off(vib); turn_off(vib);
device_unregister(vib->dev); device_unregister(vib->dev);
ida_simple_remove(&minors, vib->minor); ida_free(&minors, vib->minor);
gb_connection_disable(vib->connection); gb_connection_disable(vib->connection);
gb_connection_destroy(vib->connection); gb_connection_destroy(vib->connection);
kfree(vib); kfree(vib);
......
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