Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp231068imm; Mon, 21 May 2018 05:16:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr8sAz/GYu1HPDcOmKZXU605ygM97fPG1/6+iHyeXYMkXCQscoHwfH7axipAw/G+GfTwEID X-Received: by 2002:a17:902:8bcb:: with SMTP id r11-v6mr20279607plo.51.1526905002299; Mon, 21 May 2018 05:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526905002; cv=none; d=google.com; s=arc-20160816; b=alxbrEnRtglNWxvCA+l3J+p/D417nuEbXYY4dxK8ZF9jLM4dSk/X23/wcqXLkvlBfI g3/coMXi7mIyU+kKmX8sCEHJbk3tFdHw7b7eBOGe2VV4yCNx4URBb++YhjDJh9jEZMTR Yj5juus03lHgmKBvyNA6ErmFEyUyQQWHLhYJvQ7L4eFr4f42SP5TwFcyhEOXdCVim50W wXHo/Paf+9yEoVm2C2U0sJCMZM2seeDedLOqnyqgZA8ZvwUQPrNM5KOTktkSmMqwGhT9 DF9+uF5V1BVDLjuXp3LKfc+hTVwU2cYBDT4Vf9TAtwS6t4OBmERsUGyXpagBMrwuawCh bMnw== 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=fXCzZZNykCkdwu3cp3GpDfnxO912Ex87Ko3I65TRgDs=; b=CYjTAlBZ89cXeZ5dlWDvCSzXEkF5ur8YOh8tEik03mtbJW+x1MSyFpBJ9TmSDemcoL dIrHttp/3nnOkNlKqqCSHncdxaOFzIg2KzOBedDTU9LjnpNVu/Rd1DcmRdidfKlf79qK azAzzqLiwk1OtzVkvocxoseB3O2Up/yXHPTkkQP8WRxfDV7hl/uKOOfzMWAieZhuGnr7 vH3pENuQ3iqkJ+KJPQSUEM9i4vNFs44eWMB40VqUOABLadSxxiLF8Bj+F8TFN/LA4GJ7 TUk+TiVW9mqT0FOFX3iH41BYgSwj56p9cHLNuISMv2D5mTWyYH3NpEWL9QSJfna8+7Bt CoGg== 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 t12-v6si11204635pgr.690.2018.05.21.05.16.26; Mon, 21 May 2018 05:16:42 -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 S1752728AbeEUMPe (ORCPT + 99 others); Mon, 21 May 2018 08:15:34 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:38694 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752095AbeEUMJF (ORCPT ); Mon, 21 May 2018 08:09:05 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 176EB1BD82738; Mon, 21 May 2018 20:09:01 +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:52 +0800 From: Yisheng Xie To: CC: Yisheng Xie , Bartlomiej Zolnierkiewicz , Tejun Heo , Subject: [PATCH 10/33] pata_hpt37x: use match_string() helper Date: Mon, 21 May 2018 19:57:47 +0800 Message-ID: <1526903890-35761-11-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: Bartlomiej Zolnierkiewicz Cc: Tejun Heo Cc: linux-ide@vger.kernel.org Signed-off-by: Yisheng Xie --- drivers/ata/pata_hpt37x.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index 3ba843f..ef8aaeb 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c @@ -224,17 +224,14 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, const char * const list[]) { unsigned char model_num[ATA_ID_PROD_LEN + 1]; - int i = 0; + int i; ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num)); - while (list[i] != NULL) { - if (!strcmp(list[i], model_num)) { - pr_warn("%s is not supported for %s\n", - modestr, list[i]); - return 1; - } - i++; + i = match_string(list, -1, model_num); + if (i >= 0) { + pr_warn("%s is not supported for %s\n", modestr, list[i]); + return 1; } return 0; } -- 1.7.12.4