linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yisheng Xie <xieyisheng1@huawei.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: <linux-kernel@vger.kernel.org>, <andy.shevchenko@gmail.com>,
	"Quytelda Kahja" <quytelda@tamalin.org>,
	<devel@driverdev.osuosl.org>
Subject: Re: [PATCH v2 03/21] Staging: gdm724x: use match_string() helper
Date: Thu, 31 May 2018 20:12:59 +0800	[thread overview]
Message-ID: <22803947-32e5-6d71-31d3-0f732ee34cda@huawei.com> (raw)
In-Reply-To: <20180531114437.GA11598@kroah.com>

Hi Greg,

On 2018/5/31 19:44, Greg Kroah-Hartman wrote:
> 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 <gregkh@linuxfoundation.org>
>> Cc: Quytelda Kahja <quytelda@tamalin.org>
>> Cc: devel@driverdev.osuosl.org
>> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
>> ---
>> 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?

Hmm, actually, I thought it no need to test tty->index here, but I not so sure
about that so I kept it, I will remove this check next version.

> 
> This should be cleaned up more please.
Sure!


Thanks
Yisheng
> 
> thanks,
> 
> greg k-h
> 
> .
> 

  reply	other threads:[~2018-05-31 12:14 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-31 11:11 [PATCH v2 00/21] use match_string() helper Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 01/21] usb: phy: " Yisheng Xie
2018-05-31 16:55   ` Sergei Shtylyov
2018-05-31 18:47     ` Andy Shevchenko
2018-05-31 18:56       ` Sergei Shtylyov
2018-05-31 18:59         ` Andy Shevchenko
2018-06-05  9:28           ` Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 02/21] mfd: omap-usb-host: " Yisheng Xie
2018-06-04  7:44   ` Lee Jones
2018-06-04  8:13     ` Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 03/21] Staging: gdm724x: " Yisheng Xie
2018-05-31 11:44   ` Greg Kroah-Hartman
2018-05-31 12:12     ` Yisheng Xie [this message]
2018-06-06  2:21   ` [PATCH v3 " Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 04/21] cxgb4: " Yisheng Xie
2018-06-05 13:19   ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 05/21] hp100: " Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 06/21] iwlwifi: mvm: " Yisheng Xie
2018-06-05 13:19   ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 07/21] bus: fsl-mc: " Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 08/21] clk: bcm2835: " Yisheng Xie
2018-06-02  6:17   ` Stephen Boyd
2018-05-31 11:11 ` [PATCH v2 09/21] clk: " Yisheng Xie
2018-06-02  6:17   ` Stephen Boyd
2018-05-31 11:11 ` [PATCH v2 10/21] cpufreq: intel_pstate: " Yisheng Xie
2018-06-26 15:23   ` Rafael J. Wysocki
2018-06-26 23:56     ` Srinivas Pandruvada
2018-07-04 10:52       ` Rafael J. Wysocki
2018-05-31 11:11 ` [PATCH v2 11/21] drm/nouveau: " Yisheng Xie
2018-06-05 13:20   ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 12/21] drm: i2c: ch7006: " Yisheng Xie
2018-06-05 13:21   ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 13/21] ima: " Yisheng Xie
2018-05-31 15:02   ` Mimi Zohar
2018-06-01 10:55     ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 14/21] sched/debug: " Yisheng Xie
2018-06-05 13:21   ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 15/21] ALSA: oxygen: " Yisheng Xie
2018-05-31 18:39   ` Takashi Iwai
2018-05-31 18:40     ` Andy Shevchenko
2018-05-31 18:43       ` Takashi Iwai
2018-05-31 18:44         ` Andy Shevchenko
2018-05-31 18:41   ` Andy Shevchenko
2018-05-31 18:59     ` Takashi Iwai
2018-05-31 19:02       ` Andy Shevchenko
2018-05-31 20:30         ` Takashi Iwai
2018-05-31 11:11 ` [PATCH v2 16/21] ASoC: max98088: " Yisheng Xie
2018-05-31 11:49   ` Mark Brown
2018-05-31 12:25     ` Yisheng Xie
2018-05-31 16:02       ` Mark Brown
2018-06-01  0:38         ` Yisheng Xie
2018-05-31 16:09   ` Applied "ASoC: max98088: use match_string() helper" to the asoc tree Mark Brown
2018-05-31 11:11 ` [PATCH v2 17/21] ASoC: max98095: use match_string() helper Yisheng Xie
2018-05-31 16:09   ` Applied "ASoC: max98095: use match_string() helper" to the asoc tree Mark Brown
2018-05-31 11:11 ` [PATCH v2 18/21] ASoC: dapm: use match_string() helper Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 19/21] bcache: " Yisheng Xie
2018-06-01  3:45   ` Coly Li
2018-06-01  4:32     ` Yisheng Xie
2018-06-01  5:04       ` Coly Li
2018-05-31 11:11 ` [PATCH v2 20/21] powerpc/xmon: " Yisheng Xie
2018-06-04 14:11   ` [v2,20/21] " Michael Ellerman
2018-05-31 11:11 ` [PATCH v2 21/21] sparc64: " Yisheng Xie
2018-06-01 11:34   ` Andy Shevchenko
2018-06-04  1:06     ` Yisheng Xie
2018-06-04 10:06       ` Andy Shevchenko
2018-06-05  9:05         ` Yisheng Xie
2018-06-06  2:19   ` [PATCH v3 " Yisheng Xie
2018-06-06  5:01     ` Andy Shevchenko
2018-06-21  1:13       ` Yisheng Xie
2018-06-21  1:39       ` [PATCH v4 " Yisheng Xie
2018-06-21  2:24         ` Andy Shevchenko
2018-05-31 12:23 ` [PATCH v2 00/21] " Yisheng Xie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=22803947-32e5-6d71-31d3-0f732ee34cda@huawei.com \
    --to=xieyisheng1@huawei.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quytelda@tamalin.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).