Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp229019imm; Mon, 21 May 2018 05:14:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpRlx3FOseubFKBGCSVoG/2v+7icjW5TRigA1J/iLXJKfTZ/woZUXpAIPYD5CTeOJk/cFxM X-Received: by 2002:a17:902:b216:: with SMTP id t22-v6mr20454534plr.105.1526904880636; Mon, 21 May 2018 05:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526904880; cv=none; d=google.com; s=arc-20160816; b=rTb6GlwLclutAHvjLDP2M4V2gzcwJOf3Mmq1R1g11z5XFOxKsuKJfAlm5sOLYknlc5 6I3vnDJS8v+/5DG6yX4OgbgSUGTO+ztHLuQ1IipGNqDYZJptaFsq4zw/FAbHNDNMBzeI irIvJI1TmTY1KvIV+fuHWfnE9gGCThEjq/P8XZLt5wrX46z1pv7vGHvw++KF/sxeZGoy X+jq0e7BbUuPKhabhXX6uqZSpDvzzL10VDLLMWWFrszBCf4hdlY3XHe5gCtoyCHldIzV +fHOcCeMnmzuj5KIt2A5+BDeDQKV0SYLm42AjyWWt6UTUNxgBzP3xClLhhws0VfKyGTy B2EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=Jm3H2LRz8ycbDgwMOVtF/gR+DtGXuKRzGV5TpSW4sEw=; b=v+fuX7jAmUJPkSdU2ZX0wS9SteBcKrQapbu02lyzi2g0cPhoY89bBKYA0GipWw/wTA yvOmcBl2XJw8avBUV3ZhjthJqWEJwRDqQsEeConacJcsechsY0o13ZXUmbU/hOw9JVIo lAFFuqkrKAq5S6mkVQPFsjk7T6MDvcuXqxRIb9ImjoYv9hYFsZM/zyrRJf0/i/MVoHv/ aH5SflTBWqgnsqAayFZx3IqvRp8FlBixTi1aLIsNF/+8HPQx5flFKeRahGoyld1QDYH8 DegMi9mdokxpFRva3rAyIUP5bGsuftgu+K4nGku+HmI+jyLbiZAOq0F/oZiFAj03cf1n 8IyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j28-v6si14204980pfe.337.2018.05.21.05.14.26; Mon, 21 May 2018 05:14:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752902AbeEUMMj (ORCPT + 99 others); Mon, 21 May 2018 08:12:39 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7715 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752977AbeEUMJU (ORCPT ); Mon, 21 May 2018 08:09:20 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 8817A7077B94; Mon, 21 May 2018 20:09:06 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Mon, 21 May 2018 20:08:57 +0800 From: Yisheng Xie To: CC: Yisheng Xie , Zhang Rui , Eduardo Valentin , Subject: [PATCH 19/33] thermal: db8500: use match_string() helper Date: Mon, 21 May 2018 19:57:56 +0800 Message-ID: <1526903890-35761-20-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org match_string() returns the index of an array for a matching string, which can be used intead of open coded variant. Cc: Zhang Rui Cc: Eduardo Valentin Cc: linux-pm@vger.kernel.org Signed-off-by: Yisheng Xie --- 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