match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Zhang Rui <rui.zh...@intel.com>
Cc: Eduardo Valentin <edubez...@gmail.com>
Cc: linux...@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyishe...@huawei.com>
---
 drivers/thermal/db8500_thermal.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c
index f491faf..dd83614 100644
--- a/drivers/thermal/db8500_thermal.c
+++ b/drivers/thermal/db8500_thermal.c
@@ -50,12 +50,10 @@ static int db8500_thermal_match_cdev(struct 
thermal_cooling_device *cdev,
        if (!strlen(cdev->type))
                return -EINVAL;
 
-       for (i = 0; i < COOLING_DEV_MAX; i++) {
-               if (!strcmp(trip_point->cdev_name[i], cdev->type))
-                       return 0;
-       }
+       i = match_string((const char **)trip_point->cdev_name,
+                        COOLING_DEV_MAX, cdev->type);
 
-       return -ENODEV;
+       return (i < 0) ? -ENODEV : 0;
 }
 
 /* Callback to bind cooling device to thermal zone */
-- 
1.7.12.4

Reply via email to