Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp903242imm; Tue, 5 Jun 2018 06:20:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJWVj/LeNIZZmxCqhywvNo1iKK9hedxWu0DoyjPSIaVSKRAcQ+KLQzSKRpa1a4GYze+0vxo X-Received: by 2002:a17:902:a581:: with SMTP id az1-v6mr11689472plb.61.1528204852646; Tue, 05 Jun 2018 06:20:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528204852; cv=none; d=google.com; s=arc-20160816; b=gCVN7/YKu7GupCf2ku5sQT/dWiGiwIVoaQtR7TlSRSwzuSe0sO0zH6yEk8HBncxwxw lCENPl+EnAW29fGjnHZ7ClDma+1ezYzjNOb70xV4WDiK2hZqVPEVF25fDLsg8WBPi08S iVDYs/bqMowOqd0n9j7r5Kno59HPwuhL4dXSAAtGj7BbDCqWUemRdvDTqlWzi6dK1SiG i+6SYSvcgB0jAqKTR5voyKtMOBJPFKkr8bDZwAznT8m/SITgqgz/0ZfIyciaDhyBKmfr UNi68Hp030BR3hys5pjcphGdiy2gANheYL3BBCTs1GuSuH2tJ6GCVMlfOIUYBxV+QBui Nq+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=rzsJ4vN81nIDyG3GN3TKPav8ZZXipccI5pwz0xj8XoI=; b=X1x24CHfvmwdIU15AO1g9Eot94JgkJMf+VcD+CYM70tyMP2k+LHOBYgvMnlqPdkXTQ b+frO6pY+USwa5YYK04DgXIEYKXOHeJgzjh9BJ/8g7uK8FE+sq0EfUhAFFFfgSF9JVAo lAEJX4XlUccgAhaWZmpY9MdrzHniT+2Qzd5hiR8p/+adcG/lghr+sKoKoygmAOJy+mDR ZYe466d4nPl/xBLHHakvIqjdHw55KmTSZAkj+Uocz+OQWAMthhrmzKkjyyq/NoHbDFki TkrjNd6LA+uvGEgmMdWDnjQ8sHbwykURPkbbPuY9vTaTRPcyckkBIHueXdoiXG6/to83 kuyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AmyH70sK; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31-v6si49030996plz.364.2018.06.05.06.20.38; Tue, 05 Jun 2018 06:20:52 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AmyH70sK; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751991AbeFENTn (ORCPT + 99 others); Tue, 5 Jun 2018 09:19:43 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:46376 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751775AbeFENTk (ORCPT ); Tue, 5 Jun 2018 09:19:40 -0400 Received: by mail-qt0-f196.google.com with SMTP id h5-v6so2285051qtm.13; Tue, 05 Jun 2018 06:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=rzsJ4vN81nIDyG3GN3TKPav8ZZXipccI5pwz0xj8XoI=; b=AmyH70sKt15+1HGtnEfqKWJUJnoT0/zQAvRfhn448IjrEtoxyIk67fKPi/cEYgZqJD YFELVgVr7EQ+00VhZJzKwMVB+tEQTxkaPdQ5xEp1eQnWk/als2UMO/h86QwM3rpUPKH3 Dm8GUxAETwJAwSWdINQVDnCcp7k1TYh0yeeR51w6unZEAqTKh9PK6tXbFRRqtQJBA7I+ vyAahJCEgFg0Vsc637YIQ41iOsva3nEsyLcvIakfs3E9XdznCu6AQF0e5MXyT6RlO7SK f5RIq6zbzE/0c6Hj7uAA7JdBIDGqJo8Qp2lf2ID2YPuBHn1KB0hPP8sWMVGhRMFpohW5 0NyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=rzsJ4vN81nIDyG3GN3TKPav8ZZXipccI5pwz0xj8XoI=; b=Yr7nxz+ZyTURMxAJ5dfE4w0kMAAKGz+bsn60lfUSG3twpgzoCAdtY080JB9+Zy60gu ciwWLd44Ht/PxB8WSTcBO/QBp524Jdjxc3D8iRmyr32pm1JZOcjKGFCB+bD6e5N3uk8i KcBUs5dcbdQ8T5hbGlELQRKgZ8/5x9m7eYj2MVKruHyq8TZOVMnC0vV9vavToNu2D9fI sBHdCRTe7nx5JTmkjPLmSIjds4EEgGQYe5EYACLY13tCh3pGX6tFTcEzJdsOfBBTI4oO tlexfVxzfwxq6qaD2xczRD/9lSRjOH7KkkhRBySSPdNiq6Flud0EmrUwiPz4IVhicBNh bSRQ== X-Gm-Message-State: APt69E1yFgL8S5uIpqti+FG6GFYhiXiAA1AxqkL087akOweS/TzRG3zN O8tleTzqBYFGfvKAplH9tN22ivLVs55PND8n0itOPirsbno= X-Received: by 2002:aed:3ce8:: with SMTP id e37-v6mr24718624qtf.295.1528204779765; Tue, 05 Jun 2018 06:19:39 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:98f9:0:0:0:0:0 with HTTP; Tue, 5 Jun 2018 06:19:39 -0700 (PDT) In-Reply-To: <1527765086-19873-5-git-send-email-xieyisheng1@huawei.com> References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-5-git-send-email-xieyisheng1@huawei.com> From: Andy Shevchenko Date: Tue, 5 Jun 2018 16:19:39 +0300 Message-ID: Subject: Re: [PATCH v2 04/21] cxgb4: use match_string() helper To: Yisheng Xie Cc: Linux Kernel Mailing List , Ganesh Goudar , netdev Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie wrote: > 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: Ganesh Goudar > Cc: netdev@vger.kernel.org > Signed-off-by: Yisheng Xie > --- > v2: > - no change from v1. > > drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c > index 9da6f57..bd61610 100644 > --- a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c > +++ b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c > @@ -782,17 +782,11 @@ static int cudbg_get_mem_region(struct adapter *padap, > if (rc) > return rc; > > - for (i = 0; i < ARRAY_SIZE(cudbg_region); i++) { > - if (!strcmp(cudbg_region[i], region_name)) { > - found = 1; > - idx = i; > - break; > - } > - } > - if (!found) > - return -EINVAL; > + rc = match_string(cudbg_region, ARRAY_SIZE(cudbg_region), region_name); > + if (rc < 0) > + return rc; > > - found = 0; > + idx = rc; > for (i = 0; i < meminfo->mem_c; i++) { > if (meminfo->mem[i].idx >= ARRAY_SIZE(cudbg_region)) > continue; /* Skip holes */ > -- > 1.7.12.4 > -- With Best Regards, Andy Shevchenko