[PATCH 19/33] thermal: db8500: use match_string() helper

From: Yisheng Xie
Date: Mon May 21 2018 - 07:18:11 EST


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.zhang@xxxxxxxxx>
Cc: Eduardo Valentin <edubezval@xxxxxxxxx>
Cc: linux-pm@xxxxxxxxxxxxxxx
Signed-off-by: Yisheng Xie <xieyisheng1@xxxxxxxxxx>
---
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