From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Paul Cercueil <paul@crapouillou.net>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
linux-rtc@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rtc: jz4740: Add support for the JZ4725B, JZ4760, JZ4770
Date: Sat, 14 Jul 2018 18:24:19 +0200 [thread overview]
Message-ID: <20180714162419.GX16084@piout.net> (raw)
In-Reply-To: <1531576208.2831.1@smtp.crapouillou.net>
On 14/07/2018 15:50:08+0200, Paul Cercueil wrote:
> > > > This would avoid that change (and the test would preferably be
> > > > (rtc->type == ID_JZ4780))
> > >
> > > That branch should be taken if the SoC is JZ4760, JZ4770 or JZ4780.
> > > It should not be taken if the SoC is JZ4740 or JZ4725B.
> >
> > Sure but you can achieve that with only 2 ids...
> >
> > >
> > > > > ret = jz4780_rtc_enable_write(rtc);
> > > > > if (ret == 0)
> > > > > ret = jz4740_rtc_wait_write_ready(rtc);
> > > > > @@ -300,6 +303,9 @@ static void jz4740_rtc_power_off(void)
> > > > >
> > > > > static const struct of_device_id jz4740_rtc_of_match[] = {
> > > > > { .compatible = "ingenic,jz4740-rtc", .data = (void
> > > *)ID_JZ4740 },
> > > > > + { .compatible = "ingenic,jz4725b-rtc", .data = (void
> > > *)ID_JZ4725B
> > > > > },
> > > > > + { .compatible = "ingenic,jz4760-rtc", .data = (void
> > > *)ID_JZ4760 },
> > > > > + { .compatible = "ingenic,jz4770-rtc", .data = (void
> > > *)ID_JZ4770 },
> >
> > By doing the correct mapping here e.g:
> >
> > { .compatible = "ingenic,jz4725b-rtc", .data = (void *)ID_JZ4740 },
>
> Not very pretty and future-proof if you ask me...
> But you're the boss...
>
I think it makes the code simpler to follow . Regarding future
proofness, you will have to add code and probably use a switch case at
the time you need to handle an RTC differently. At that time, the >=
test trick will not work anymore anyway.
--
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2018-07-14 16:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-13 15:14 [PATCH] rtc: jz4740: Add support for the JZ4725B, JZ4760, JZ4770 Paul Cercueil
2018-07-14 13:19 ` Alexandre Belloni
2018-07-14 13:25 ` Paul Cercueil
2018-07-14 13:32 ` Alexandre Belloni
2018-07-14 13:50 ` Paul Cercueil
2018-07-14 16:24 ` Alexandre Belloni [this message]
2018-07-20 15:39 ` Rob Herring
2018-07-20 19:03 ` Paul Cercueil
2018-07-23 14:18 ` Rob Herring
2018-07-23 14:20 ` Paul Cercueil
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=20180714162419.GX16084@piout.net \
--to=alexandre.belloni@bootlin.com \
--cc=a.zummo@towertech.it \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=paul@crapouillou.net \
--cc=robh+dt@kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).