[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87ob4c1nwf.fsf@natisbad.org>
Date: Thu, 19 Dec 2013 23:22:56 +0100
From: arno@...isbad.org (Arnaud Ebalard)
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Mark Rutland <mark.rutland@....com>,
Alessandro Zummo <a.zummo@...ertech.it>,
Jason Cooper <jason@...edaemon.net>,
Pawel Moll <pawel.moll@....com>,
Stephen Warren <swarren@...dotorg.org>,
rtc-linux@...glegroups.com,
Linus Walleij <linus.walleij@...aro.org>,
Ian Campbell <ijc+devicetree@...lion.org.uk>,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
Rob Herring <rob.herring@...xeda.com>,
Jason Gunthorpe <jgunthorpe@...idianresearch.com>,
devicetree@...r.kernel.org, Mark Brown <broonie@...nel.org>,
linux-arm-kernel@...ts.infradead.org,
Rob Landley <rob@...dley.net>,
Kumar Gala <galak@...eaurora.org>,
Grant Likely <grant.likely@...aro.org>,
Peter Huewe <peter.huewe@...ineon.com>,
Thierry Reding <treding@...dia.com>,
Guenter Roeck <linux@...ck-us.net>
Subject: Re: [PATCHv7] rtc: Add support for Intersil ISL12057 I2C RTC chip
Hi Andrew,
Andrew Morton <akpm@...ux-foundation.org> writes:
> On Thu, 19 Dec 2013 22:53:16 +0100 Arnaud Ebalard <arno@...isbad.org> wrote:
>
>> +static int isl12057_i2c_validate_chip(struct regmap *regmap)
>> +{
>> + u8 regs[ISL12057_MEM_MAP_LEN];
>> + u8 mask[ISL12057_MEM_MAP_LEN] = { 0x80, 0x80, 0x80, 0xf8,
>> + 0xc0, 0x60, 0x00, 0x00,
>> + 0x00, 0x00, 0x00, 0x00,
>> + 0x00, 0x00, 0x60, 0x7c };
>> + int ret, i;
>> +
>> + ret = regmap_bulk_read(regmap, 0, regs, ISL12057_MEM_MAP_LEN);
>> + if (ret)
>> + return ret;
>> +
>> + for (i = 0; i < ISL12057_MEM_MAP_LEN; ++i) {
>> + if (regs[i] & mask[i]) /* check if bits are cleared */
>> + return -ENODEV;
>> + }
>> +
>> + return 0;
>> +}
>
> When I build this for x86_64, mask[] is assembled on-stack at runtime:
>
> leaq -48(%rbp), %r14 #, tmp130
> xorl %esi, %esi #
> movl $16, %ecx #,
> movq %rax, %rdi # regmap,
> incq .LPBX1+552(%rip) # *.LPBX1
> movb $-128, -64(%rbp) #, mask
> movq %r14, %rdx # tmp130,
> movb $-128, -63(%rbp) #, mask
> movb $-128, -62(%rbp) #, mask
> movb $-8, -61(%rbp) #, mask
> movb $-64, -60(%rbp) #, mask
> movb $96, -59(%rbp) #, mask
> movb $0, -58(%rbp) #, mask
> movb $0, -57(%rbp) #, mask
> movb $0, -56(%rbp) #, mask
> movb $0, -55(%rbp) #, mask
> movb $0, -54(%rbp) #, mask
> movb $0, -53(%rbp) #, mask
> movb $0, -52(%rbp) #, mask
> movb $0, -51(%rbp) #, mask
> movb $96, -50(%rbp) #, mask
> movb $124, -49(%rbp) #, mask
> call regmap_bulk_read #
>
> If we make `mask' static const, that all gets done at compile time instead:
>
> leaq -48(%rbp), %r14 #, tmp134
> xorl %esi, %esi #
> movl $16, %ecx #,
> movq %rax, %rdi # regmap,
> incq .LPBX1+552(%rip) # *.LPBX1
> movq %r14, %rdx # tmp134,
> call regmap_bulk_read #
>
> much nicer.
Damned. That's a good argument for a v8 ;-) Give me some minutes to
assemble one.
Cheers,
a+
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists