Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp493620imm; Thu, 31 May 2018 04:26:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK0GrPzoaqKZo6/kbOBSvR0FNZbktURIPq2wppjqe1PnEpLtIVRATHt9RlV4uVZYJCuoR59 X-Received: by 2002:a17:902:9a95:: with SMTP id w21-v6mr6400929plp.168.1527765993503; Thu, 31 May 2018 04:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527765993; cv=none; d=google.com; s=arc-20160816; b=NMaZ8w9O2T5CbZEfFyUOGxZAzpUYbLj5e1ZPSMY2iACcCprfhiPjMIM99lxDjnUaP0 p579HQjHVMB8BheWd59ZRkMJEMvCBM72HPXy0ydo7TU19a65vXgX6paCwKe06D2YAF/R F7Q10/VWH4ACbmNdfQVB37yoDLvFyP+tV9Bobs84+2zzxUlzcB4U5N/+3Ew/+C/Q5RR5 zXGal/pXsVbK2l71xsQSSg9bVKaj6KeNrcEEM69O8Fwxw6wWw+TYHJwl3mGuv3BiiTlo j60gQBiK3iupPmdpFX4Ly5cAkl+RaSIdyRuWMra2+reQiNzaRRzkB/ZrVM7+y5nTBTe2 K/IQ== 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=MRYJAYpWytRQ/zJYeloVkxskUox/5LnpHiw/4shmyJ8=; b=LYWRvu9cbT49pceSxYhUoH10TLt3CCpp5QiW4iNTONkJeFTVku+vnB/KVJ/ms+sM9f UTcZ+lsqlemmT5i8pOWxOKSTRZ43hEb+3nC5HqQzIb9AEAPAAxO8mXNJNwkgXrwrfpd+ O/ffpoVvnoXZIiVrtmsIcBiJNcN7pmXHlo/YFtJ8BBGz03EblO766urLcVRfTfsY8+Sc VZWeF7t10/GajwqpaSxUq5YTPzL0/Z1VYh3IqHSNxFlbA2dIk55KhhglAemNeP3Yh+Tw na24l6oOPLwT3z4NzQ0DJJ510ucz88znZwHYDDZhay5VwOyytLmhboKPqN329ONAyr15 B4YA== 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 r8-v6si19651131plj.40.2018.05.31.04.26.18; Thu, 31 May 2018 04:26:33 -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 S1754780AbeEaLWn (ORCPT + 99 others); Thu, 31 May 2018 07:22:43 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8222 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754598AbeEaLWi (ORCPT ); Thu, 31 May 2018 07:22:38 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D61ACA6312F60; Thu, 31 May 2018 19:22:24 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 19:22:20 +0800 From: Yisheng Xie To: CC: , Yisheng Xie , "Stuart Yoder" , Laurentiu Tudor Subject: [PATCH v2 07/21] bus: fsl-mc: use match_string() helper Date: Thu, 31 May 2018 19:11:12 +0800 Message-ID: <1527765086-19873-8-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> References: <1527765086-19873-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 instead of open coded variant. Reviewed-by: Andy Shevchenko Cc: Stuart Yoder Cc: Laurentiu Tudor Signed-off-by: Yisheng Xie --- v2: - add Reviewed-by tag. drivers/bus/fsl-mc/fsl-mc-allocator.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c index fb1442b..63c4735 100644 --- a/drivers/bus/fsl-mc/fsl-mc-allocator.c +++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c @@ -156,22 +156,6 @@ static int __must_check fsl_mc_resource_pool_remove_device(struct fsl_mc_device [FSL_MC_POOL_IRQ] = "irq", }; -static int __must_check object_type_to_pool_type(const char *object_type, - enum fsl_mc_pool_type - *pool_type) -{ - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(fsl_mc_pool_type_strings); i++) { - if (strcmp(object_type, fsl_mc_pool_type_strings[i]) == 0) { - *pool_type = i; - return 0; - } - } - - return -EINVAL; -} - int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus, enum fsl_mc_pool_type pool_type, struct fsl_mc_resource **new_resource) @@ -581,9 +565,11 @@ static int fsl_mc_allocator_probe(struct fsl_mc_device *mc_dev) return -EINVAL; mc_bus = to_fsl_mc_bus(mc_bus_dev); - error = object_type_to_pool_type(mc_dev->obj_desc.type, &pool_type); - if (error < 0) - return error; + pool_type = match_string(fsl_mc_pool_type_strings, + ARRAY_SIZE(fsl_mc_pool_type_strings), + mc_dev->obj_desc.type); + if (pool_type < 0) + return pool_type; error = fsl_mc_resource_pool_add_device(mc_bus, pool_type, mc_dev); if (error < 0) -- 1.7.12.4