From: Baruch Siach <baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org>
To: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Cc: Alessandro Zummo
<a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org>,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 2/2] rtc: driver for Conexant Digicolor CX92755 on-chip RTC
Date: Tue, 24 Mar 2015 07:31:24 +0200 [thread overview]
Message-ID: <20150324053124.GN2825@tarshish> (raw)
In-Reply-To: <20150323153334.a373431dd5af6b669f716d83-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Hi Andrew,
On Mon, Mar 23, 2015 at 03:33:34PM -0700, Andrew Morton wrote:
> On Mon, 23 Mar 2015 15:28:54 +0200 Baruch Siach <baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org> wrote:
> > Add driver for the RTC hardware block on the Conexant CX92755 SoC, from
> > the
> > Digicolor series of SoCs. Tested on the Equinox evaluation board for the
> > CX92755 chip.
> >
> > ...
> >
> > +static int dc_rtc_read(struct dc_rtc *rtc, unsigned long *val)
> > +{
> > + u8 read_cmds[] = {CMD_READ, CMD_NOP};
> > + u32 reference, time1, time2;
> > + int ret;
> > +
> > + ret = dc_rtc_cmds(rtc, read_cmds, ARRAY_SIZE(read_cmds));
>
> This is asking the compiler to build read_cmds[] on the stack each time
> dc_rtc_read() is called.
>
> If we instead create the array at compile time:
>
> +++ a/drivers/rtc/rtc-digicolor.c
> @@ -42,7 +42,7 @@ struct dc_rtc {
> void __iomem *regs;
> };
>
> -static int dc_rtc_cmds(struct dc_rtc *rtc, u8 *cmds, int len)
> +static int dc_rtc_cmds(struct dc_rtc *rtc, const u8 *cmds, int len)
> {
> u8 val;
> int i, ret;
> @@ -62,7 +62,7 @@ static int dc_rtc_cmds(struct dc_rtc *rt
>
> static int dc_rtc_read(struct dc_rtc *rtc, unsigned long *val)
> {
> - u8 read_cmds[] = {CMD_READ, CMD_NOP};
> + static const u8 read_cmds[] = {CMD_READ, CMD_NOP};
> u32 reference, time1, time2;
> int ret;
>
> @@ -86,7 +86,7 @@ static int dc_rtc_read(struct dc_rtc *rt
>
> static int dc_rtc_write(struct dc_rtc *rtc, u32 val)
> {
> - u8 write_cmds[] = {CMD_WRITE, CMD_NOP, CMD_RESET, CMD_NOP};
> + static const u8 write_cmds[] = {CMD_WRITE, CMD_NOP, CMD_RESET, CMD_NOP};
>
> writel_relaxed(val, rtc->regs + DC_RTC_REFERENCE);
> return dc_rtc_cmds(rtc, write_cmds, ARRAY_SIZE(write_cmds));
>
> The code gets a bit smaller and faster:
>
> text data bss dec hex filename
> 1628 400 512 2540 9ec drivers/rtc/rtc-digicolor.o-before
> 1593 400 536 2529 9e1 drivers/rtc/rtc-digicolor.o-after
Thanks for the tip, and for taking the driver through your tree.
baruch
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org - tel: +972.2.679.5364, http://www.tkos.co.il -
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2015-03-24 5:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 13:28 [PATCH 1/2] rtc: digicolor: document device tree binding Baruch Siach
[not found] ` <fa36a31a1d58d626ca0cb01ca0dece85aa2dfcb9.1427117334.git.baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org>
2015-03-23 13:28 ` [PATCH 2/2] rtc: driver for Conexant Digicolor CX92755 on-chip RTC Baruch Siach
[not found] ` <374ef109005ed14c3a0052a9da5226b87f8dc215.1427117334.git.baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org>
2015-03-23 22:33 ` Andrew Morton
[not found] ` <20150323153334.a373431dd5af6b669f716d83-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2015-03-24 5:31 ` Baruch Siach [this message]
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=20150324053124.GN2825@tarshish \
--to=baruch-nswtu9s1w3p6gbpvegmw2w@public.gmane.org \
--cc=a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.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).