drivers: greybus: Directly use ida_alloc()/free()
PATCH 1/1 drivers: greybus: Directly use ida_alloc()/free()
Use ida_alloc()/ida_free() instead of deprecated
ida_simple_get()/ida_simple_remove() .
--- drivers/greybus/es2.c | 4 ++-- drivers/greybus/hd.c | 12 ++++++------ drivers/greybus/interface.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-)
drivers/greybus/es2.c +2 -2
@@ -522,7 +522,7 @@ static int es2_cport_allocate(struct gb_host_device *hd, int cport_id,return -EINVAL ; } -return ida_simple_get (id_map, ida_start, ida_end,GFP_KERNEL ); +return ida_alloc_range (id_map, ida_start, ida_end -1 ,GFP_KERNEL ); }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 ; } -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,
drivers/greybus/hd.c +6 -6
@@ -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;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 ) {dev_err (&hd->dev,"failed to reserve cport %u\n" , cport_id);return ret;
@@ -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; -ida_simple_remove (id_map, cport_id); +ida_free (id_map, cport_id); }EXPORT_SYMBOL_GPL (gb_hd_cport_release_reserved);
@@ -89,7 +89,7 @@ int gb_hd_cport_allocate(struct gb_host_device *hd, int cport_id,return -EINVAL ; } -return ida_simple_get (id_map, ida_start, ida_end,GFP_KERNEL ); +return ida_alloc_range (id_map, ida_start, ida_end -1 ,GFP_KERNEL ); }/* Locking: Caller guarantees serialisation */
@@ -100,7 +100,7 @@ void gb_hd_cport_release(struct gb_host_device *hd, u16 cport_id)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)
@@ -111,7 +111,7 @@ static void gb_hd_release(struct device *dev)if (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);kfree (hd); }
@@ -162,7 +162,7 @@ struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver,if (!hd)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 ) {kfree (hd);return ERR_PTR (ret);
drivers/greybus/interface.c +4 -4
@@ -131,8 +131,8 @@ static int gb_interface_route_create(struct gb_interface *intf)int ret;/* Allocate an interface device id. */ - ret =ida_simple_get (&svc->device_id_map, -GB_SVC_DEVICE_ID_MIN ,GB_SVC_DEVICE_ID_MAX +1 , + ret =ida_alloc_range (&svc->device_id_map, +GB_SVC_DEVICE_ID_MIN ,GB_SVC_DEVICE_ID_MAX ,GFP_KERNEL );if (ret <0 ) {dev_err (&intf->dev,"failed to allocate device id: %d\n" , ret);
@@ -165,7 +165,7 @@ static int gb_interface_route_create(struct gb_interface *intf)* XXX anymore. */ err_ida_remove: -ida_simple_remove (&svc->device_id_map, device_id); +ida_free (&svc->device_id_map, device_id);return ret; }
@@ -178,7 +178,7 @@ static void gb_interface_route_destroy(struct gb_interface *intf)return ;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 ; }
Signature · 1 line
2.25.1
Johan Hovold
maintainerOn Fri, May 27, 2022 at 11:13:48AM +0000, keliu wrote:
Please drop "drivers: " from Subject and use a more descriptive summary like:
greybus: replace ida_simple interface
Quoted 4 lines
Use ida_alloc()/ida_free() instead of deprecated
ida_simple_get()/ida_simple_remove() .Signed-off-by keliu <[email protected]>
Again, this needs to be a full (legal) name.
Quoted 11 lines
--- drivers/greybus/es2.c | 4 ++-- drivers/greybus/hd.c | 12 ++++++------ drivers/greybus/interface.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-)drivers/greybus/es2.c +0
-0
drivers/greybus/es2.c static int es2_cport_allocate(struct gb_host_device *hd, int cport_id, · line 525
Quoted 5 lines
drivers/greybus/es2.c +1
-1@@ -522,7 +522,7 @@ static int es2_cport_allocate(struct gb_host_device *hd, int cport_id,return -EINVAL ; } -return ida_simple_get (id_map, ida_start, ida_end,GFP_KERNEL ); +return ida_alloc_range (id_map, ida_start, ida_end -1 ,GFP_KERNEL );
Please mention in the commit message that the upper bound is inclusive in the new API.
Quoted 95 lines
drivers/greybus/es2.c +1
-1}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 ; } -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,drivers/greybus/hd.c +6
-6@@ -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;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 ) {dev_err (&hd->dev,"failed to reserve cport %u\n" , cport_id);return ret;@@ -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; -ida_simple_remove (id_map, cport_id); +ida_free (id_map, cport_id); }EXPORT_SYMBOL_GPL (gb_hd_cport_release_reserved);@@ -89,7 +89,7 @@ int gb_hd_cport_allocate(struct gb_host_device *hd, int cport_id,return -EINVAL ; } -return ida_simple_get (id_map, ida_start, ida_end,GFP_KERNEL ); +return ida_alloc_range (id_map, ida_start, ida_end -1 ,GFP_KERNEL ); }/* Locking: Caller guarantees serialisation */ @@ -100,7 +100,7 @@ void gb_hd_cport_release(struct gb_host_device *hd, u16 cport_id)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)@@ -111,7 +111,7 @@ static void gb_hd_release(struct device *dev)if (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);kfree (hd); }@@ -162,7 +162,7 @@ struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver,if (!hd)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 ) {kfree (hd);return ERR_PTR (ret);drivers/greybus/interface.c +3
-3@@ -131,8 +131,8 @@ static int gb_interface_route_create(struct gb_interface *intf)int ret;/* Allocate an interface device id. */ - ret =ida_simple_get (&svc->device_id_map, -GB_SVC_DEVICE_ID_MIN ,GB_SVC_DEVICE_ID_MAX +1 , + ret =ida_alloc_range (&svc->device_id_map, +GB_SVC_DEVICE_ID_MIN ,GB_SVC_DEVICE_ID_MAX ,GFP_KERNEL );if (ret <0 ) {dev_err (&intf->dev,"failed to allocate device id: %d\n" , ret);@@ -165,7 +165,7 @@ static int gb_interface_route_create(struct gb_interface *intf)* XXX anymore. */ err_ida_remove: -ida_simple_remove (&svc->device_id_map, device_id); +ida_free (&svc->device_id_map, device_id);return ret; }
drivers/greybus/interface.c static void gb_interface_route_destroy(struct gb_interface *intf) · line 183
Quoted 7 lines
drivers/greybus/interface.c +1
-1@@ -178,7 +178,7 @@ static void gb_interface_route_destroy(struct gb_interface *intf)return ;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 ; }
Looks good otherwise.
Johan