Commit 551d315e authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Doug Ledford

RDMA/umad: Use kernel API to allocate umad indexes

Replace custom code to allocate indexes to generic kernel API.
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 90f6e41c
...@@ -138,7 +138,7 @@ static const dev_t base_issm_dev = MKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE) + ...@@ -138,7 +138,7 @@ static const dev_t base_issm_dev = MKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE) +
static dev_t dynamic_umad_dev; static dev_t dynamic_umad_dev;
static dev_t dynamic_issm_dev; static dev_t dynamic_issm_dev;
static DECLARE_BITMAP(dev_map, IB_UMAD_MAX_PORTS); static DEFINE_IDA(umad_ida);
static void ib_umad_add_one(struct ib_device *device); static void ib_umad_add_one(struct ib_device *device);
static void ib_umad_remove_one(struct ib_device *device, void *client_data); static void ib_umad_remove_one(struct ib_device *device, void *client_data);
...@@ -1159,11 +1159,10 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, ...@@ -1159,11 +1159,10 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
dev_t base_umad; dev_t base_umad;
dev_t base_issm; dev_t base_issm;
devnum = find_first_zero_bit(dev_map, IB_UMAD_MAX_PORTS); devnum = ida_alloc_max(&umad_ida, IB_UMAD_MAX_PORTS - 1, GFP_KERNEL);
if (devnum >= IB_UMAD_MAX_PORTS) if (devnum < 0)
return -1; return -1;
port->dev_num = devnum; port->dev_num = devnum;
set_bit(devnum, dev_map);
if (devnum >= IB_UMAD_NUM_FIXED_MINOR) { if (devnum >= IB_UMAD_NUM_FIXED_MINOR) {
base_umad = dynamic_umad_dev + devnum - IB_UMAD_NUM_FIXED_MINOR; base_umad = dynamic_umad_dev + devnum - IB_UMAD_NUM_FIXED_MINOR;
base_issm = dynamic_issm_dev + devnum - IB_UMAD_NUM_FIXED_MINOR; base_issm = dynamic_issm_dev + devnum - IB_UMAD_NUM_FIXED_MINOR;
...@@ -1227,7 +1226,7 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, ...@@ -1227,7 +1226,7 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
err_cdev: err_cdev:
cdev_del(&port->cdev); cdev_del(&port->cdev);
clear_bit(devnum, dev_map); ida_free(&umad_ida, devnum);
return -1; return -1;
} }
...@@ -1261,7 +1260,7 @@ static void ib_umad_kill_port(struct ib_umad_port *port) ...@@ -1261,7 +1260,7 @@ static void ib_umad_kill_port(struct ib_umad_port *port)
} }
mutex_unlock(&port->file_mutex); mutex_unlock(&port->file_mutex);
clear_bit(port->dev_num, dev_map); ida_free(&umad_ida, port->dev_num);
} }
static void ib_umad_add_one(struct ib_device *device) static void ib_umad_add_one(struct ib_device *device)
......
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