Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp206354ybi; Wed, 29 May 2019 19:43:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKrVgad2jAPmoHv8n06jyLpP2x6XbfyqkDfUKDAApkCgl8gDve0KnLVdj2EbZt6cypRVQX X-Received: by 2002:a65:52c3:: with SMTP id z3mr1485140pgp.56.1559184235213; Wed, 29 May 2019 19:43:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559184235; cv=none; d=google.com; s=arc-20160816; b=bZ+10Xne6kEt4BRm4szAQrluXgnrkoHebo9ajR1r+O23UWO/0Hi4IaLDHubXD9pA28 DRdeSDv2Flv2eV8TEC1OyAPqVfycdCd+wiDbWCVULPMgJbFG+/i5wGlyEO6kRqt/0WU5 SYdtgypR1drWFcF99mHPfQt/GellnfKV0aBQ5qhod+DOdHvRQiDrWwUIsSw4gzR8a00P T9hjqODKqtpIJ43LcYC25g7l5LmxRpLWGnoCy6/5ryQSwxmE+3rSZhNIX5ge1r11bOiN ro/doaU7gLwkZnncwMyLdUWv85XipcelqH8K5V8eOnudYvd3azIhO0xBoWsL6Uawxipc 6NYw== 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 :message-id:to:from:cc:in-reply-to:subject:date; bh=KpcFXbFBwLxCGyy/Jk49fis3KZuLGYD4HsSFk6V42fk=; b=PnmaCjPvJOijizvUcRgwEpPCn4/4jMBCFolG4SMvs/NKLpelH4TSWRL7U2CQya2p8+ 2YYj40uUhp9ogxciSl/Vw9V0EZacFBr3hBS3rYmLwKmLMfTUFsGivlqb/DTxJtQjhCD4 Bk+gcgLIPN7M1U1IT2SFClL8YPWWD6DSJq1VWDnAtXXjhlVTXan7ndAH07OmI7CFVl9G ByGaM6GklxhF0sHdkYLXoJcnsXELcdBSWt4Ksm/wHCjKrltqsB9Tn65P7U5g+geSJ5ze EJ1bKoYGA9694PbG59/5Qc3fDXPo3e11ZjGO1EBoJUNojnEndj9lMS+OmEeuIacKYF/t I21A== 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 q125si1883432pfq.163.2019.05.29.19.43.39; Wed, 29 May 2019 19:43:55 -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 S1726589AbfE3Cme (ORCPT + 99 others); Wed, 29 May 2019 22:42:34 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36154 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726065AbfE3Cme (ORCPT ); Wed, 29 May 2019 22:42:34 -0400 Received: by mail-pg1-f196.google.com with SMTP id a3so1068650pgb.3 for ; Wed, 29 May 2019 19:42:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=KpcFXbFBwLxCGyy/Jk49fis3KZuLGYD4HsSFk6V42fk=; b=SwDEMuVWt+wXYfUu4gJ15OAEZ7+G3FIIa+bPjk8FIlYoqpNS3i1o9uOLJEPbzLw7bi YtVjPcR3FgTtg6vJaFWevXMAplzwPeodmX6A40w2ZIhM6KxYwRc21OUbXiF5UGTWnw4h doAVBe94v6zRig/xZFF7R8Q8c2ZS7JAVUW7lf6o8AbcrRfAwgK99yEV3DGtqlsmnhLPJ cyfkNXScLB4zV56msk/FryHWDWrAw7YkWKBdLG5Nig/Kh6JxwPAH0u6zLCPM+PrW/cBg IvjyxhY9B/QfcU1J2pGRXJ6LA6MD4E+5zrV0i4GWEoP0w5GGNA74m0dquu/4bV8ZlO1b 7mCg== X-Gm-Message-State: APjAAAXh44fa5nXzglVWYscL5EDJXTJ9XBrpooo6KNBvXxusPFen59A/ W6AEPpz9620dIbGedMNQojf7dg== X-Received: by 2002:a62:ea0a:: with SMTP id t10mr1228321pfh.236.1559184153533; Wed, 29 May 2019 19:42:33 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id b90sm363054pjc.0.2019.05.29.19.42.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 May 2019 19:42:32 -0700 (PDT) Date: Wed, 29 May 2019 19:42:32 -0700 (PDT) X-Google-Original-Date: Wed, 29 May 2019 19:42:12 PDT (-0700) Subject: Re: [PATCH 2/2] net: macb: Add support for SiFive FU540-C000 In-Reply-To: <20190524134847.GF2979@lunn.ch> CC: yash.shah@sifive.com, mark.rutland@arm.com, devicetree@vger.kernel.org, aou@eecs.berkeley.edu, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, nicolas.ferre@microchip.com, Sachin Ghadi , robh+dt@kernel.org, Paul Walmsley , ynezz@true.cz, linux-riscv@lists.infradead.org, davem@davemloft.net From: Palmer Dabbelt To: andrew@lunn.ch Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 24 May 2019 06:48:47 PDT (-0700), andrew@lunn.ch wrote: > On Fri, May 24, 2019 at 10:22:06AM +0530, Yash Shah wrote: >> On Thu, May 23, 2019 at 8:24 PM Andrew Lunn wrote: >> > >> > > +static int fu540_macb_tx_set_rate(struct clk_hw *hw, unsigned long rate, >> > > + unsigned long parent_rate) >> > > +{ >> > > + rate = fu540_macb_tx_round_rate(hw, rate, &parent_rate); >> > > + iowrite32(rate != 125000000, mgmt->reg); >> > >> > That looks odd. Writing the result of a comparison to a register? >> >> The idea was to write "1" to the register if the value of rate is >> anything else than 125000000. > > I'm not a language lawyer. Is it guaranteed that an expression like > this returns 1? Any value !0 is true, so maybe it actually returns 42? From Stack Overflow: https://stackoverflow.com/questions/18097922/return-value-of-operator-in-c "C11(ISO/IEC 9899:201x) ยง6.5.8 Relational operators Each of the operators < (less than), > (greater than), <= (less than or equal to), and >= (greater than or equal to) shall yield 1 if the specified relation is true and 0 if it is false. The result has type int." >> To make it easier to read, I will change this to below: >> - iowrite32(rate != 125000000, mgmt->reg); >> + if (rate != 125000000) >> + iowrite32(1, mgmt->reg); >> + else >> + iowrite32(0, mgmt->reg); >> >> Hope that's fine. Thanks for your comment > > Yes, that is good. > > Andrew