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>
 
        klist_iter_init_node(&sp->klist_devices, &i,
                             (start ? &start->p->knode_bus : NULL));
-       while ((dev = next_device(&i)))
-               if (match(dev, data) && get_device(dev))
+       while ((dev = next_device(&i))) {
+               if (match(dev, data)) {
+                       get_device(dev);
                        break;
+               }
+       }
        klist_iter_exit(&i);
        subsys_put(sp);
        return dev;
 
                return NULL;
 
        klist_iter_init(&parent->p->klist_children, &i);
-       while ((child = next_device(&i)))
-               if (match(child, data) && get_device(child))
+       while ((child = next_device(&i))) {
+               if (match(child, data)) {
+                       get_device(child);
                        break;
+               }
+       }
        klist_iter_exit(&i);
        return child;
 }
 
 
        klist_iter_init_node(&drv->p->klist_devices, &i,
                             (start ? &start->p->knode_driver : NULL));
-       while ((dev = next_device(&i)))
-               if (match(dev, data) && get_device(dev))
+       while ((dev = next_device(&i))) {
+               if (match(dev, data)) {
+                       get_device(dev);
                        break;
+               }
+       }
        klist_iter_exit(&i);
        return dev;
 }