Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp510526imm; Thu, 31 May 2018 04:45:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJAZwZnr5p/s7SMPO+meIEwCWLfkZuQRuKeyhYXe+MNfg1kqlXHPKaoBwyMsB9LhasCEdFc X-Received: by 2002:a17:902:bf01:: with SMTP id bi1-v6mr1397540plb.43.1527767141441; Thu, 31 May 2018 04:45:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527767141; cv=none; d=google.com; s=arc-20160816; b=HpCj2iOJbw61NidtAzx+THWwGFC6DsPyrdiZuBFgrEv5s45w+XxhYP9tXKgUcXGAwQ /4nauZI4qA7C9XYPLJbPJ77NOjSthji4e/7L2orjXngFUre/XayOfaqa7JNrmXQXqOU4 1TVsi5pRy/BQjLKqALoN/pxen9BxcZNlLL8vX6D7C0YB/7bxkExpFNS/i056ce4K/kQO nRcRoJUVRKMJmSus0xAvNPoDTAN38WXiKfl1GINvVeo6YNZrEWtrN4a/yNHiOeAHjo3a lM7v+ucm0/goNW/Cwlb52zwZf3tY/IcNNlKAql2y0uW1XsOC97woPL9ztZxLvG64yI7d IPQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=YP7z6ntE1HXA2sVqYT/L5LUV87ghzMSiajhny39mR5s=; b=RLTr68lB/wRHkicQaH5nnSsMsiUdURTpBoKpNGEL7/liuviLY6TkdO/49JsvPRBHJo k/PsKf7qIu7RbdITZRxdTyjT1Cfzu5OD13SsFQFObfhy+an0Cjn9xsUaSRdOatREsuCm 5yWAqlUd6TIDrDuqvO8NnaATRpcimlicVEeFXQ/ZngiZ7h2L+jLdWCurB3LEVmJcBQDi nIwM6jS/ZGtOKPBjC2AM+exPR1edkZ+k3/g3HHDqoBt0EwLyeyCfzB62NQYnZ3IMsLOa zxCZqo+uX6SdebOSnAXxWLVThBBoAEWd/K74WHcIEML7EYO6fIu69BmOalMKKMO6eam2 bg5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jjEnfWSM; 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 r10-v6si26736849pgp.363.2018.05.31.04.45.27; Thu, 31 May 2018 04:45:41 -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=@kernel.org header.s=default header.b=jjEnfWSM; 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 S1754733AbeEaLpB (ORCPT + 99 others); Thu, 31 May 2018 07:45:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:39038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754628AbeEaLpA (ORCPT ); Thu, 31 May 2018 07:45:00 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5BDEB208AE; Thu, 31 May 2018 11:44:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527767099; bh=VEspqvDfNSo1hEyZIqssLKpK1vQ5wlXMbSsWaQdigf4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jjEnfWSMKMiigGg+iPJPOS839LQh1xBwjmi66PPOq3FDB0jUKVnw7BkD10MBPg0Sh STeFX9GloQYjN4KP/WQwWmyfedFcmAaVGYHz+CL5KfGnulYLu6IH4DySQECISQwUac B//OT4O0r5Rug6N4jboIWkTW+HkhP8+oTtL4Aw1k= Date: Thu, 31 May 2018 13:44:37 +0200 From: Greg Kroah-Hartman To: Yisheng Xie Cc: linux-kernel@vger.kernel.org, andy.shevchenko@gmail.com, Quytelda Kahja , devel@driverdev.osuosl.org Subject: Re: [PATCH v2 03/21] Staging: gdm724x: use match_string() helper Message-ID: <20180531114437.GA11598@kroah.com> References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-4-git-send-email-xieyisheng1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1527765086-19873-4-git-send-email-xieyisheng1@huawei.com> User-Agent: Mutt/1.10.0 (2018-05-17) 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 07:11:08PM +0800, Yisheng Xie wrote: > match_string() returns the index of an array for a matching string, > which can be used instead of open coded variant. > > Cc: Greg Kroah-Hartman > Cc: Quytelda Kahja > Cc: devel@driverdev.osuosl.org > Signed-off-by: Yisheng Xie > --- > v2: > - const DRIVER_STRING instead - per Andy > > drivers/staging/gdm724x/gdm_tty.c | 18 +++++------------- > 1 file changed, 5 insertions(+), 13 deletions(-) > > diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c > index 3cdebb8..397ecaa 100644 > --- a/drivers/staging/gdm724x/gdm_tty.c > +++ b/drivers/staging/gdm724x/gdm_tty.c > @@ -43,7 +43,7 @@ > static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR]; > static DEFINE_MUTEX(gdm_table_lock); > > -static char *DRIVER_STRING[TTY_MAX_COUNT] = {"GCTATC", "GCTDM"}; > +static const char *DRIVER_STRING[TTY_MAX_COUNT] = {"GCTATC", "GCTDM"}; > static char *DEVICE_STRING[TTY_MAX_COUNT] = {"GCT-ATC", "GCT-DM"}; > > static void gdm_port_destruct(struct tty_port *port) > @@ -65,22 +65,14 @@ static int gdm_tty_install(struct tty_driver *driver, struct tty_struct *tty) > { > struct gdm *gdm = NULL; > int ret; > - int i; > - int j; > - > - j = GDM_TTY_MINOR; > - for (i = 0; i < TTY_MAX_COUNT; i++) { > - if (!strcmp(tty->driver->driver_name, DRIVER_STRING[i])) { > - j = tty->index; > - break; > - } > - } > > - if (j == GDM_TTY_MINOR) > + ret = match_string(DRIVER_STRING, TTY_MAX_COUNT, > + tty->driver->driver_name); > + if (ret < 0 || tty->index == GDM_TTY_MINOR) > return -ENODEV; Very odd rewrite here. Why call this function if you think the initial parameters are not correct? Are you sure about your test for tty->index? This should be cleaned up more please. thanks, greg k-h