]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
driver core: Move true expression out of if condition in 3 device finding APIs
authorZijun Hu <quic_zijuhu@quicinc.com>
Sun, 5 Jan 2025 08:34:04 +0000 (16:34 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Jan 2025 14:26:12 +0000 (15:26 +0100)
commit3f58ee540d190e9c52b91e055683d15c8ed81112
tree8e4baa3dc7b308bfeb533d9d350776240655c364
parentd1248436cbef1f924c04255367ff4845ccd9025e
driver core: Move true expression out of if condition in 3 device finding APIs

For bus_find_device(), driver_find_device(), and device_find_child(), all
of their function body have pattern below:

{
struct klist_iter i;
struct device *dev;

...
while ((dev = next_device(&i)))
if (match(dev, data) && get_device(dev))
break;
...
}

The expression 'get_device(dev)' in the if condition always returns true
since @dev != NULL.

Move the expression to if body to make logic of these APIs more clearer.

Reviewed-by: Fan Ni <fan.ni@samsung.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20250105-class_fix-v6-3-3a2f1768d4d4@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/bus.c
drivers/base/core.c
drivers/base/driver.c