nvme-fc: Utilise min3() to simplify queue count calculation
authorQasim Ijaz <qasdev00@gmail.com>
Thu, 13 Feb 2025 22:16:22 +0000 (22:16 +0000)
committerKeith Busch <kbusch@kernel.org>
Thu, 20 Mar 2025 23:53:55 +0000 (16:53 -0700)
Refactor nvme_fc_create_io_queues() and nvme_fc_recreate_io_queues() to
use the min3() macro to find the minimum between 3 values instead of
multiple min()'s. This shortens the code and makes it easier to read.

Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/fc.c

index 7de29dae8e74f776c6a28ab4005ab7be5c2bf291..38fa2d049dcf40899b7345f195c71dec4fa8e623 100644 (file)
@@ -2907,7 +2907,7 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
        unsigned int nr_io_queues;
        int ret;
 
-       nr_io_queues = min(min(opts->nr_io_queues, num_online_cpus()),
+       nr_io_queues = min3(opts->nr_io_queues, num_online_cpus(),
                                ctrl->lport->ops->max_hw_queues);
        ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues);
        if (ret) {
@@ -2961,7 +2961,7 @@ nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl)
        unsigned int nr_io_queues;
        int ret;
 
-       nr_io_queues = min(min(opts->nr_io_queues, num_online_cpus()),
+       nr_io_queues = min3(opts->nr_io_queues, num_online_cpus(),
                                ctrl->lport->ops->max_hw_queues);
        ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues);
        if (ret) {