Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4237276rwd; Tue, 30 May 2023 02:24:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7OAElve0z1OX905D0fvDtuRp57NCJrmjlulksLpxlL1pFpgfCh/BnWJEbRfJ3Uag/HZ0C0 X-Received: by 2002:a17:902:f549:b0:1b0:113e:1031 with SMTP id h9-20020a170902f54900b001b0113e1031mr2119362plf.39.1685438690195; Tue, 30 May 2023 02:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685438690; cv=none; d=google.com; s=arc-20160816; b=waVaUEPYKGSDNAlD9YyM1Y36hSKCRy/U+46LJ6dQyim+z2HsCW44u98H4Hp09cSgdW pOFOtHE/tzGxmenldmYLMqPz1MiWrd+NfgDY9ih9yJFsiCXzOt43ni/Kf/YNYmS7Bdlu e/UHGup13cqwhLSL0xF0gEXRQGDrptHHukzVlZ+opGxKACm//VfTWQTxC5dwknHtRxLp y3rFZNUuLx73oJm/saWyXjX7cZd5oPODVGtvUWIyYK6T2JpPoDMXJdBQMZdM1ZZ9iNUT 7GBbyUfZ1xFIBCUsz1GgiclvIanBo9naYWTj2EwbuOtibT49ZQTk1pHZgkyXiWcOajaW Mgzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=d5bTC9ePIjeDHAn1QNvw27hbRPZAZpSBv6bbVVhO9e4=; b=Ssia1wwlll8GfrASbvVaSk0+b55zE/7khF1Q6R0zxoGzrxBbq9dokn0YxcLQLeQ2SI 8yvQYcWvPYsSBGqY+KBtk3UedFakhd6r7ulqKW6ZVaKm6FOYUvTqxH6CBbU1BnfbVqmD f9U8KCg9yI0KRrLrP5GroydOMeLRDwddmLPZ2J+wsjms4esMtiqPUrQyKuqjMQkd8QTG gFWe9DRMWrO6sYfqVv+LhIWbvanvcEhVoTnryuBKpJkA68JmRPH2wkUkmN2Vrp2303+l kVnSdOaXzpHwd7K3assmHtfjnH0rWrojqWHwyTgd3qhEp1tjPCvDvXFXTszKe+DsG6CV WbaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=p4Y6Rqn1; 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 jd18-20020a170903261200b001b0347b904csi4870250plb.275.2023.05.30.02.24.38; Tue, 30 May 2023 02:24:50 -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=20221208 header.b=p4Y6Rqn1; 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 S230075AbjE3JDk (ORCPT + 99 others); Tue, 30 May 2023 05:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbjE3JDi (ORCPT ); Tue, 30 May 2023 05:03:38 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD840CD; Tue, 30 May 2023 02:03:36 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-96f850b32caso816943066b.3; Tue, 30 May 2023 02:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685437415; x=1688029415; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=d5bTC9ePIjeDHAn1QNvw27hbRPZAZpSBv6bbVVhO9e4=; b=p4Y6Rqn1ty2pcP5fz7B/SLQTYhEeCBYts56LJfdu8UXM8utM7zp8/JJxcV+uyB/VGV xACPmpZz2saVNBaKuhtFnemTrhSn4l/ZlBdoZQmeV6ls6AD+WCFqvxuxyjO8YJXZAjrA 1Dy5660ee57yQCxHkQfCkuyldbbb1kh7ZE+XYbU4JNsIbcXbOzXF7N0428PLdtgF/rsX 0FLKYXM4GAAoYeoEg0Z1lGJuDY3T3HGoFm8FiXffiEKnyqo0iSPYRYUDEfZ+QxsYdSHd gZQciYn3VNlB7EoOYLnFtxZap0xZ9GCfMDgCZJR4AP02ZGS5NclU7mRzfo7HsUJPhmyC SPNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685437415; x=1688029415; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=d5bTC9ePIjeDHAn1QNvw27hbRPZAZpSBv6bbVVhO9e4=; b=IUOpTQ+Eu9y/47Nmjk1RpkyU26RteVgv3jNb/+Qu/iCxaSY+czl0/bAuhH53Z1IM7t hP9cYXhYfzQ+CRKjEx3Tc0qpdXCq2vUPDW2bw3b9kjnm+gaG0t+fbNOCh9Ru5GzwHm9b ungXa4mwrA1dvFYgyN4F53ylUv2Id9/ocym96pDhBzPVyK1rLGVWicFTdO+pSKV48MLo 6s4YtoLBWBAdlb4xHVmQ0Yum+FgYQcFTSQ/YNjUdfmufwfdX6sv2W8sJ9C6K+HBbZuYL 3v4ic3ElXPwXajE+gjD9BKl0ooXMJmVNEybOEReZ0dQkfxqf59avefj8cBMSkqjKKqFv DeUg== X-Gm-Message-State: AC+VfDyX63BAGi2x/6X6Cd7lWbuS6SFytamiJS1Zl2utKVFiEQuFnvIi HIXRfegf3HeG3UujJ/1RnOc= X-Received: by 2002:a17:907:971e:b0:96b:4ed5:a1d8 with SMTP id jg30-20020a170907971e00b0096b4ed5a1d8mr1751323ejc.36.1685437414798; Tue, 30 May 2023 02:03:34 -0700 (PDT) Received: from ?IPV6:2a01:c22:6f01:a200:d5f5:8fd7:7c5e:94b2? (dynamic-2a01-0c22-6f01-a200-d5f5-8fd7-7c5e-94b2.c22.pool.telefonica.de. [2a01:c22:6f01:a200:d5f5:8fd7:7c5e:94b2]) by smtp.googlemail.com with ESMTPSA id u5-20020a17090626c500b0096f641a4c01sm7109593ejc.179.2023.05.30.02.03.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 May 2023 02:03:34 -0700 (PDT) Message-ID: <81b74ddc-58dc-78e7-e647-8f90933d6a88@gmail.com> Date: Tue, 30 May 2023 11:03:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH] net: Replace the ternary conditional operator with min() To: Lu Hongfei , Andrew Lunn , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "open list:ETHERNET PHY LIBRARY" , open list Cc: opensource.kernel@vivo.com References: <20230530084531.7354-1-luhongfei@vivo.com> Content-Language: en-US From: Heiner Kallweit In-Reply-To: <20230530084531.7354-1-luhongfei@vivo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 30.05.2023 10:45, Lu Hongfei wrote: > It would be better to replace the traditional ternary conditional > operator with min() > No. If you say something is better you should explain the benefit. > Signed-off-by: Lu Hongfei > --- > drivers/net/phy/phy.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > mode change 100644 => 100755 drivers/net/phy/phy.c > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index 0c0df38cd1ab..a8beb4ab8451 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -1002,7 +1002,7 @@ static int phy_poll_aneg_done(struct phy_device *phydev) > if (!ret) > return -ETIMEDOUT; > > - return ret < 0 ? ret : 0; > + return min(ret, 0); ret < 0 stands for is_err(ret), therefore an arithmetic operator isn't appropriate here. > } > > int phy_ethtool_ksettings_set(struct phy_device *phydev, > @@ -1526,7 +1526,7 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable) > ret = phy_set_bits_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, > MDIO_PCS_CTRL1_CLKSTOP_EN); > > - return ret < 0 ? ret : 0; > + return min(ret, 0); > } > EXPORT_SYMBOL(phy_init_eee); >