Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7659072rwl; Thu, 23 Mar 2023 07:12:19 -0700 (PDT) X-Google-Smtp-Source: AK7set/b2jEeNhxcGxZ33IylrBPiLqtpv8q9BoSN2dS++3mAVwT3UHct73RHyhf6RM/Pw6KbDSVH X-Received: by 2002:a17:90b:4f92:b0:23f:ef7:7897 with SMTP id qe18-20020a17090b4f9200b0023f0ef77897mr7864772pjb.49.1679580739178; Thu, 23 Mar 2023 07:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679580739; cv=none; d=google.com; s=arc-20160816; b=G1AI6CTw/6ABjUfly7u9O9znkv+CQcuuPp/gyrX9h9RDnuaX8iwMbrP7UCXQkACgDE qohF5bQYDRzPCXEmSDvCctp5tXeAcIgDAbC6IrefI8r/30Nsfj+2KLuG9dsZXwc5pa/K RgijLfRwprdM53cbp6qEYE6uYkLClXh8cG5GVjwmGpi481G4C8/PUdhn9q+2NUqC9gPF SB32yO5jUdXctwYXfLeh4wycBjWewErKekXQZ8FTFL6lU/m66+kHo3TkhUTMUO9jn8jo Qt6gA3Z8tAQ+9187VazM7dNyDw8z9VAAhe6RqhLuH/dTr0HGa/yLgmjwGmR7hqICIHNZ P/uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Z4BMiXjAP1ZDCS80RIcwxql2HNxRwPUInw3Q2X6diKU=; b=PhZ5ySw+o58I87j53SBzZs8EP1IvbqiQjKZIyx9Beo08AVteEp2V9xNaKQM2o5liui OCkBeHitxyJTUTA3r3XBoPX9P8AMaGStr8Dh+TBhRDsbdFDCtxHfc7LA2BMryUFH8i8L Ufvs5DGtxHWWfdC0+yDq8ymFKJEWlxyTJlaUnoiXJkLJJgRNcBh9EyhLiYMaSYeXhqc1 aOegV5ADsSQ2FuFcdNV4oUFfMbwLS1FiDIbgivg+1k6cD0uh35l8cAGL4rDCdA2fhHiM WNNYaYpP7wYZQSeTBQp8naFZAVzLC0QFlwKiYbg8OXs1jEClNx47T6cmlN5l2mngf1Hs MtZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GPQuBpzB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oo6-20020a17090b1c8600b0023fbe02fbf2si2025617pjb.108.2023.03.23.07.12.07; Thu, 23 Mar 2023 07:12:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GPQuBpzB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231168AbjCWOHh (ORCPT + 99 others); Thu, 23 Mar 2023 10:07:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230157AbjCWOHg (ORCPT ); Thu, 23 Mar 2023 10:07:36 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90A8222793; Thu, 23 Mar 2023 07:06:23 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id j18-20020a05600c1c1200b003ee5157346cso1277887wms.1; Thu, 23 Mar 2023 07:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679580378; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Z4BMiXjAP1ZDCS80RIcwxql2HNxRwPUInw3Q2X6diKU=; b=GPQuBpzB70pNVCwyNA98ZNN6PaiMrOOhDlHsXGsvfQ7Rk0AKwWgWIQR09P3q7tyxrW 3zel+WM6jx5cSkf0wf7H4HZQC+RNr/ewq6fxF/RGDaZICvsTYKUCRWD50VT7z2N2j/cB EYYvpNwajjWjyYQAXdwiYuTxMeWChWl5THqn3vgb6PvSX2nizF1aVufdlUJ0IQrUyxUJ 1z7GLmeDN5EseQPF5m9w0DddAqosd/9X26frWdbsH/nblx7vC1bAlv4uQ0IBEzuji011 GuNpDqzgjcE9zPpkRS/s91mEJiubyJQCdqiEGUDg9rFbnOJmE24FMnOWzHxUZXD8tDJm TMVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679580378; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Z4BMiXjAP1ZDCS80RIcwxql2HNxRwPUInw3Q2X6diKU=; b=MQvpw7sC05LBfNEK63EzII0Ga5X8hZmgW56khA6J2gKU+hYynWg4xFEW1755fA5y2u SNjxtEmzPKaysXaBVoPKU5ahOxEynrfKKiaxQ0umULV/o5JDhDmauGtQ935C3dgqKOOq SiSRGZF3f926t9Wg25SiYy+/2fHpF1fawlejT/jOOpB0sbIQXa82qq86BAOK++egyd2E n6wzrzDlookojo/pzj0rgWkJCbsYQuk4FHfo8U0CAPGgpDTiRjOCCe8XF0JxOcDdwov6 A/0x23PDD4HvfB+3WE5sennVbleqECDU6RdmrRDlgrtIYjWVQUFRSi6AWlHfnq6dAP4e Lksw== X-Gm-Message-State: AO0yUKXtbmALT5+vBGz0PTWiXx7KKOVLSSwShXXhCsCTVvZzqe8X+YAn tUeU2TvCvelF9aYuf7KwdTX94YCHJRQ= X-Received: by 2002:a05:600c:3795:b0:3ed:93de:49ff with SMTP id o21-20020a05600c379500b003ed93de49ffmr2390666wmr.0.1679580378202; Thu, 23 Mar 2023 07:06:18 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id i11-20020a05600c290b00b003ee20b4b2dasm1912223wmd.46.2023.03.23.07.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Mar 2023 07:06:17 -0700 (PDT) Date: Thu, 23 Mar 2023 17:06:14 +0300 From: Dan Carpenter To: Oliver Neukum Cc: Sergei Shtylyov , Mingxuan Xiang , Thinh Nguyen , Greg Kroah-Hartman , hust-os-kernel-patches@googlegroups.com, Dongliang Mu , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] usb: dwc3: host: remove dead code in dwc3_host_get_irq() Message-ID: <6677e2c6-b621-4c7e-9dd6-631a02ce5996@kili.mountain> References: <20230323095311.1266655-1-mx_xiang@hust.edu.cn> <129aec21-4997-6b8d-5bd2-8e013f575208@gmail.com> <73fd29ce-3072-dfce-ebf0-3e197230fa94@suse.com> <201fba22-f537-4d1f-bfc4-e4dc931707bc@kili.mountain> <181feb34-c46d-cadb-ad20-46074a53b4c9@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <181feb34-c46d-cadb-ad20-46074a53b4c9@suse.com> X-Spam-Status: No, score=0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 23, 2023 at 02:48:56PM +0100, Oliver Neukum wrote: > On 23.03.23 12:13, Dan Carpenter wrote: > > > > > > v1->v2: remove redundant goto > > > > > drivers/usb/dwc3/host.c | 4 ---- > > > > > 1 file changed, 4 deletions(-) > > > > > > > > > > diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c > > > > > index f6f13e7f1ba1..ca1e8294e835 100644 > > > > > --- a/drivers/usb/dwc3/host.c > > > > > +++ b/drivers/usb/dwc3/host.c > > > > > @@ -54,12 +54,8 @@ static int dwc3_host_get_irq(struct dwc3 *dwc) > > > > > irq = platform_get_irq(dwc3_pdev, 0); > > > > > if (irq > 0) { > > > > > dwc3_host_fill_xhci_irq_res(dwc, irq, NULL); > > > > > - goto out; > > > > > } > > > > > > > > Now drop {} please. :-) > > > > > > Well, no, please drop the whole patch. > > > If platform_get_irq() returns -EPROBE_DEFER you now give that > > > as a return value. > > > > > > This tiny bit of optimization is not worth changing semantics. > > > > The v2 patch doesn't change the semantics. Mine did though... > > Now I may be dense, but let's look at the current code: > > irq = platform_get_irq(dwc3_pdev, 0); > > assuming irq = -EPROBE_DEFER > > if (irq > 0) { > > not taken > dwc3_host_fill_xhci_irq_res(dwc, irq, NULL); > goto out; > } > > if (!irq) > > irq != 0 You've reversed this if statement in your head. It says that if platform_get_irq() returns zero, then return -EINVAL. The problem that Mingxuan is trying to address is that checking for zero is dead code and sometimes represents a bug when people check for zero instead of negatives. > irq = -EINVAL; > > out: > return irq; > > returning -EINVAL We do *want* it to return -EPROBE_DEFER as the current code does. regards, dan carpenter