[PATCH 60/79] block: fix arg type in `blk_mq_update_nr_hw_queues`

Andreas Hindborg
2026-02-15T23:40:44Z

The type of the argument `nr_hw_queues` in the function
`blk_mq_update_nr_hw_queues` is a signed integer. This is wrong,
considering the field `nr_hw_queues` of `struct blk_mq_tag_set` is
unsigned. Thus, change the type of the parameter to unsigned.

Cascade the change to downstream functions.

Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
---
block/blk-mq.c | 13 +++++++------
include/linux/blk-mq.h | 2 +-
2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index a29d8ac9d3e35..6a44ebb6aac43 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4779,10 +4779,10 @@ static void blk_mq_update_queue_map(struct blk_mq_tag_set *set)
}

static int blk_mq_realloc_tag_set_tags(struct blk_mq_tag_set *set,
- int new_nr_hw_queues)
+ unsigned int new_nr_hw_queues)
{
struct blk_mq_tags **new_tags;
- int i;
+ unsigned int i;

if (set->nr_hw_queues >= new_nr_hw_queues)
goto done;
@@ -5086,12 +5086,12 @@ static int blk_mq_elv_switch_none(struct request_queue *q,
}

static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
- int nr_hw_queues)
+ unsigned int nr_hw_queues)
{
struct request_queue *q;
- int prev_nr_hw_queues = set->nr_hw_queues;
+ unsigned int prev_nr_hw_queues = set->nr_hw_queues;
unsigned int memflags;
- int i;
+ unsigned int i;
struct xarray elv_tbl;
bool queues_frozen = false;

@@ -5178,7 +5178,8 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
__blk_mq_free_map_and_rqs(set, i);
}

-void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues)
+void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
+ unsigned int nr_hw_queues)
{
down_write(&set->update_nr_hwq_lock);
mutex_lock(&set->tag_list_lock);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index cae9e857aea42..171521e716e49 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -972,7 +972,7 @@ unsigned int blk_mq_num_online_queues(unsigned int max_queues);
void blk_mq_map_queues(struct blk_mq_queue_map *qmap);
void blk_mq_map_hw_queues(struct blk_mq_queue_map *qmap,
struct device *dev, unsigned int offset);
-void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues);
+void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, unsigned int nr_hw_queues);

void blk_mq_quiesce_queue_nowait(struct request_queue *q);

--
2.51.2