lkml.org 
[lkml]   [2018]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 19/33] thermal: db8500: use match_string() helper
Date
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@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@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
\
 
 \ /
  Last update: 2018-05-21 14:13    [W:0.488 / U:24.904 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site