Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp591660img; Mon, 18 Mar 2019 09:49:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBUR4rOLS9UGqBLxDdHjcXUOP1jTcO+LdwLdjCdLRqKfj+SkHE+YPLQGaNlmUXJyktPcjO X-Received: by 2002:a17:902:b609:: with SMTP id b9mr20902873pls.134.1552927760533; Mon, 18 Mar 2019 09:49:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552927760; cv=none; d=google.com; s=arc-20160816; b=q3bh71IWPVgHenCCMuxSuKeRyBOrenYQiTIh0I2c4NNZu7j3S38xlRsIqm1croeg9V +yJq1bBb5RnseuYrUwc3GoLHwT+/AO/BNLNpP4J8k3LHsQloOETUIZbxp/tH0KZ4TAJm xt5Hjor06WuUeQrkEv32qCPCWuumBGeuA6S6nQzUFwx1iQkJTxcc2N92AlIAFmNeMBVQ 4QxYdSXjkU7n0g96vKHIymGLscWKe7ZZ3j8EVsSy7y7Ep/1GSF7K0rFBvECFLlijP58z 4NSkFKFfPpHq8d3wTduMe1Nzqe4/LH3Phh8CNliMvkx2RWXKKHbwl/BIG3gFxRUyAIco IBGg== 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; bh=H/BUsaldC478ltxrARFWmgwrvUN1zwbsGpzkw0am7bc=; b=AkH5ri1UcSInMH7h1d4pwAHN51KGhd0UmfR/iYKTvSyrPQz9qlVgtsDJBuqX6cdLW6 VuglMlJvVYdgeWeTK0OCbZ01aaxPdY6yIXNDgI+Jtt25F8O5D4YOQ6M/MH8w1RNiHB21 1lcaYhDmlFMjRV/lr1Z0tMUjtILLovaUWFH2zrhxgv4nQfnbfxKV2y7tJXBfQxyUKLfQ T4QMkzZK33H8EZ/7kxSSswPMBh+BqlyIh8qKOphm5oYM275L975qh7Z4xUnvvaISSvbb 9OLRndBQEoNVGEE6fMEA640h0na4ECdUo1ZDxCZPFB6OUeEtmhHRlYCYWW78ELY13Qcc ySJg== 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 n3si9087400pgv.458.2019.03.18.09.49.04; Mon, 18 Mar 2019 09:49:20 -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 S1727174AbfCRQsQ (ORCPT + 99 others); Mon, 18 Mar 2019 12:48:16 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:52087 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726719AbfCRQsQ (ORCPT ); Mon, 18 Mar 2019 12:48:16 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h5vQp-00071e-Uc; Mon, 18 Mar 2019 17:48:11 +0100 Received: from mfe by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1h5vQp-0008RY-5b; Mon, 18 Mar 2019 17:48:11 +0100 Date: Mon, 18 Mar 2019 17:48:11 +0100 From: Marco Felsch To: Richard Leitner Cc: "Gustavo A. R. Silva" , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: usb251xb: Remove unnecessary comparison of unsigned integer with >= 0 Message-ID: <20190318164811.quofap3b5mjlj5tc@pengutronix.de> References: <20190318145024.GA572@embeddedor> <20190318153425.rxx3fwq2hi6tfocr@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 17:43:29 up 58 days, 21:25, 51 users, load average: 0.05, 0.05, 0.01 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Richard, On 19-03-18 16:46, Richard Leitner wrote: > Hi Marco, Hi Gustavo, > thanks for the fix, please feel free to add > > Reviewed-by: Richard Leitner > > On 18/03/2019 16:34, Marco Felsch wrote: > > Hi Silva, > > > > On 19-03-18 09:50, Gustavo A. R. Silva wrote: > > > There is no need to compare *port* with >= 0 because such comparison > > > of an unsigned value is always true. > > > > Absolutly.. It seems that it was an copy'n'paste failure. Thanks for > > fixing that. > > A small note on further improvement from my side: > > According the datasheet, when you set swap-dx-lanes to 0 (-> setting port to > 0 -> setting bit 0 of PRTSP) " the upstream port DP/DM is swapped". Yes I know that's not intuitve and may confuses the users. > IMHO this is not straight-forward, so maybe we want to additionally > > a) mention it somewhere in the documentation IMHO this is the correct place. > b) check on port >= 1 I think this isn't doable since we shouldn't break the existing dt. Regards, Marco > c) something else? > > Any opinions on that from your side? ... I'd prefer "a"... > > regards;Richard.L > > > > > Regards, > > Marco > > > > > Fix this by removing such comparison. > > > > > > Addresses-Coverity-ID: 1443949 ("Unsigned compared against 0") > > > Fixes: 02a50b875046 ("usb: usb251xb: add usb data lane port swap feature") > > > Signed-off-by: Gustavo A. R. Silva > > > --- > > > drivers/usb/misc/usb251xb.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c > > > index 4d72b7d1d383..2c8e2cad7e10 100644 > > > --- a/drivers/usb/misc/usb251xb.c > > > +++ b/drivers/usb/misc/usb251xb.c > > > @@ -547,7 +547,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub, > > > */ > > > hub->port_swap = USB251XB_DEF_PORT_SWAP; > > > of_property_for_each_u32(np, "swap-dx-lanes", prop, p, port) { > > > - if ((port >= 0) && (port <= data->port_cnt)) > > > + if (port <= data->port_cnt) > > > hub->port_swap |= BIT(port); > > > } > > > -- > > > 2.21.0 > > > > > > > > > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |