LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Palmer Dabbelt <palmer@sifive.com>
To: andrew@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 <sachin.ghadi@sifive.com>,
	robh+dt@kernel.org, Paul Walmsley <paul.walmsley@sifive.com>,
	ynezz@true.cz, linux-riscv@lists.infradead.org,
	davem@davemloft.net
Subject: Re: [PATCH 2/2] net: macb: Add support for SiFive FU540-C000
Date: Wed, 29 May 2019 19:42:32 -0700 (PDT)	[thread overview]
Message-ID: <mhng-c7fba225-8035-4808-bdd6-bc05da5d2674@palmer-si-x1e> (raw)
In-Reply-To: <20190524134847.GF2979@lunn.ch>

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 <andrew@lunn.ch> 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

  reply	other threads:[~2019-05-30  2:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23 11:45 [PATCH 0/2] " Yash Shah
2019-05-23 11:45 ` [PATCH 1/2] net/macb: bindings doc: add sifive fu540-c000 binding Yash Shah
2019-05-23 20:50   ` Rob Herring
2019-05-24  4:56     ` Yash Shah
2019-06-24 15:38     ` Nicolas.Ferre
2019-07-17  9:07       ` Yash Shah
2019-05-23 11:45 ` [PATCH 2/2] net: macb: Add support for SiFive FU540-C000 Yash Shah
2019-05-23 14:54   ` Andrew Lunn
2019-05-24  4:52     ` Yash Shah
2019-05-24 13:48       ` Andrew Lunn
2019-05-30  2:42         ` Palmer Dabbelt [this message]
2019-05-23 12:49 ` [PATCH 0/2] " Andreas Schwab
2019-05-24  4:39   ` Yash Shah
2019-05-27  8:04     ` Andreas Schwab
2019-05-27 11:52       ` Yash Shah
2019-05-23 16:28 ` David Miller
2019-05-24  4:54   ` Yash Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mhng-c7fba225-8035-4808-bdd6-bc05da5d2674@palmer-si-x1e \
    --to=palmer@sifive.com \
    --cc=andrew@lunn.ch \
    --cc=aou@eecs.berkeley.edu \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=paul.walmsley@sifive.com \
    --cc=robh+dt@kernel.org \
    --cc=sachin.ghadi@sifive.com \
    --cc=yash.shah@sifive.com \
    --cc=ynezz@true.cz \
    --subject='Re: [PATCH 2/2] net: macb: Add support for SiFive FU540-C000' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).