linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCHv7] rtc: Add support for Intersil ISL12057 I2C RTC chip
       [not found] <72207bc152a06638f0e0e21a6e00d4c2054a1a71.1387489507.git.arno@natisbad.org>
@ 2013-12-19 22:07 ` Andrew Morton
  2013-12-19 22:22   ` Arnaud Ebalard
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Morton @ 2013-12-19 22:07 UTC (permalink / raw)
  To: Arnaud Ebalard
  Cc: Jason Cooper, Mark Rutland, Alessandro Zummo, Peter Huewe,
	Linus Walleij, Thierry Reding, Mark Brown, Guenter Roeck,
	Rob Herring, Pawel Moll, Stephen Warren, Ian Campbell,
	Grant Likely, devicetree, linux-doc, Rob Landley, rtc-linux,
	Jason Gunthorpe, Kumar Gala, linux-arm-kernel, linux-kernel

On Thu, 19 Dec 2013 22:53:16 +0100 Arnaud Ebalard <arno@natisbad.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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCHv7] rtc: Add support for Intersil ISL12057 I2C RTC chip
  2013-12-19 22:07 ` [PATCHv7] rtc: Add support for Intersil ISL12057 I2C RTC chip Andrew Morton
@ 2013-12-19 22:22   ` Arnaud Ebalard
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaud Ebalard @ 2013-12-19 22:22 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Mark Rutland, Alessandro Zummo, Jason Cooper, Pawel Moll,
	Stephen Warren, rtc-linux, Linus Walleij, Ian Campbell, linux-doc,
	linux-kernel, Rob Herring, Jason Gunthorpe, devicetree,
	Mark Brown, linux-arm-kernel, Rob Landley, Kumar Gala,
	Grant Likely, Peter Huewe, Thierry Reding, Guenter Roeck

Hi Andrew,

Andrew Morton <akpm@linux-foundation.org> writes:

> On Thu, 19 Dec 2013 22:53:16 +0100 Arnaud Ebalard <arno@natisbad.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+

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-12-19 22:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <72207bc152a06638f0e0e21a6e00d4c2054a1a71.1387489507.git.arno@natisbad.org>
2013-12-19 22:07 ` [PATCHv7] rtc: Add support for Intersil ISL12057 I2C RTC chip Andrew Morton
2013-12-19 22:22   ` Arnaud Ebalard

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).