Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp798699imu; Tue, 11 Dec 2018 07:46:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/WrHSEMw6Jlid6QaZjAe8dQRBNGjSF40ZiblMi7Bkv4L0h38o04Zr0Rg0ju4fVTCDFzuyew X-Received: by 2002:a63:ee4c:: with SMTP id n12mr14587245pgk.21.1544543176768; Tue, 11 Dec 2018 07:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544543176; cv=none; d=google.com; s=arc-20160816; b=urSwVkB4sQwIuqdlBbD+GbAgkFBycpEJnjNcwtmDSgryhvPR/1Gjp8RXjCuS6IM2P5 3XlvIxRF5jBnml7d+eperWmyxFJVtEigKiffoRce3WUmFboImoHjqeyaCgKk0TZixgGV yqo+KluXtivh77kt9217JWK6b17RGnKaY9dvPly7lACjPKBA459QV2v9jw6Q3YT/RSOh sPi7qm/uYgRRzFB8fcn7aAn7tbtzSZUSW/fGKIAU/R5V3bEFFk4QLaYK4qbeYFLNfWsQ coOolduHl6xkYol8kdN3VlGuAAhE5x6MTr9mp16xWb0DTntVaIgewYW1hwDLzYLpsySY 3NWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cTXDZEOrQRKzVhpGjpDZ/loJ0NdUNM7YtZTvkTNZr7M=; b=bDtfHlFsTQW2flLr6zbxdcDuGH9z4aAyRkFWIPK2fORwlfXuqtuk+RUySSliVYjK09 hL6dLAEUjXJ2uc08q5yr7ZZ64WOfMggzhwYDYpa3vgJex+VwXuHGB8vS0u4gtsAbrLa4 x0NOhYHzCjLzzdczfMB1bczKOqHXeszvS90AtbzLA56JK66D2lo4uwmeevpputlG8v4K v4Jop0Rq0G73SwmXiJbIPUofi6yr/YZ3l7hiMPpvis6venZ2JlXOjzlFpAqzmomL3Whg qaiutSWzQx6b3+B0KH+tNimnj9IdO4XUGVjNckE9sSo+aNHxCDIeR3zdB8u6j5bpNPT3 /CKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1HRiLaTD; 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 r7si13188310pfb.237.2018.12.11.07.46.02; Tue, 11 Dec 2018 07:46:16 -0800 (PST) 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=1HRiLaTD; 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 S1727572AbeLKPng (ORCPT + 99 others); Tue, 11 Dec 2018 10:43:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:60094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727559AbeLKPnd (ORCPT ); Tue, 11 Dec 2018 10:43:33 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 768B020870; Tue, 11 Dec 2018 15:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543012; bh=8ee5csuBoPGvKgb5+WrQ3q5m/c5hSpxW2Zn5wvAOM0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1HRiLaTDtzq0RKVVfLNKxLgRAM/18ftJpPOWGomWDTy9FCetQzu8hKF14YGKaGEf+ /3q1A7fJKGtJX4RX1U1iIS3VOVxTR4Nv1dqASvWUb/TRZQSRc/TD95dwlS3fZ/ESyT 0zMGjMnYShYs25OES0XvWyOq/fm9Q5JWr//qqspY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tatyana Brokhman , Felipe Balbi , Alan Stern , Arnd Bergmann , Felipe Balbi Subject: [PATCH 3.18 33/54] usb: gadget: dummy: fix nonsensical comparisons Date: Tue, 11 Dec 2018 16:41:21 +0100 Message-Id: <20181211151547.964103910@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151546.010073210@linuxfoundation.org> References: <20181211151546.010073210@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnd Bergmann commit 7661ca09b2ff98f48693f431bb01fed62830e433 upstream. gcc-8 points out two comparisons that are clearly bogus and almost certainly not what the author intended to write: drivers/usb/gadget/udc/dummy_hcd.c: In function 'set_link_state_by_speed': drivers/usb/gadget/udc/dummy_hcd.c:379:31: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] USB_PORT_STAT_ENABLE) == 1 && ^~ drivers/usb/gadget/udc/dummy_hcd.c:381:25: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] USB_SS_PORT_LS_U0) == 1 && ^~ I looked at the code for a bit and came up with a change that makes it look like what the author probably meant here. This makes it look reasonable to me and to gcc, shutting up the warning. It does of course change behavior as the two conditions are actually evaluated rather than being hardcoded to false, and I have made no attempt at verifying that the changed logic makes sense in the context of a USB HCD, so that part needs to be reviewed carefully. Fixes: 1cd8fd2887e1 ("usb: gadget: dummy_hcd: add SuperSpeed support") Cc: Tatyana Brokhman Cc: Felipe Balbi Acked-by: Alan Stern Signed-off-by: Arnd Bergmann Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/dummy_hcd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -313,11 +313,10 @@ static void set_link_state_by_speed(stru USB_PORT_STAT_CONNECTION) == 0) dum_hcd->port_status |= (USB_PORT_STAT_C_CONNECTION << 16); - if ((dum_hcd->port_status & - USB_PORT_STAT_ENABLE) == 1 && - (dum_hcd->port_status & - USB_SS_PORT_LS_U0) == 1 && - dum_hcd->rh_state != DUMMY_RH_SUSPENDED) + if ((dum_hcd->port_status & USB_PORT_STAT_ENABLE) && + (dum_hcd->port_status & + USB_PORT_STAT_LINK_STATE) == USB_SS_PORT_LS_U0 && + dum_hcd->rh_state != DUMMY_RH_SUSPENDED) dum_hcd->active = 1; } } else {