]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
driver core: auxiliary bus: Optimize logic of auxiliary_match_id()
authorZijun Hu <zijun.hu@oss.qualcomm.com>
Wed, 3 Sep 2025 11:37:22 +0000 (19:37 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Sep 2025 18:12:36 +0000 (20:12 +0200)
commit4c48aed6dfcd32ea23e52adc1072405a62facf46
treeb4c55aec14dd31ade72c8b127dac526205a30528
parenteca710386972f2a72708b0b2a615eb150d218e18
driver core: auxiliary bus: Optimize logic of auxiliary_match_id()

auxiliary_match_id() repeatedly calculates variable @match_size in the
for loop, however, the variable is fixed actually, so it is enough to
only calculate the variable once.

Besides, the function should return directly if name of the @auxdev
does not include '.', but it still iterates over the ID table.

Additionally, statement 'dev_name(&auxdev->dev)' is fixed, but may be
evaluated more than 3 times.

Optimize logic of the function by:
- Move the logic calculating the variable out of the for loop
- Return NULL directly if @p == NULL
- Give the statement an dedicated local variable @auxdev_name

Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250903-fix_auxbus-v2-1-3eae8374fd65@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/auxiliary.c