Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1242556 > unrolled thread

Re: [PATCH 2/5] irqchip/gic-v3: Make gic_enable_sre an inline function

Started byCatalin Marinas <catalin.marinas@arm.com>
First post2015-10-08 18:00 +0200
Last post2015-10-08 18:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 2/5] irqchip/gic-v3: Make gic_enable_sre an inline  function Catalin Marinas <catalin.marinas@arm.com> - 2015-10-08 18:00 +0200
    Re: [PATCH 2/5] irqchip/gic-v3: Make gic_enable_sre an inline function Marc Zyngier <marc.zyngier@arm.com> - 2015-10-08 18:10 +0200

#1242556 — Re: [PATCH 2/5] irqchip/gic-v3: Make gic_enable_sre an inline function

FromCatalin Marinas <catalin.marinas@arm.com>
Date2015-10-08 18:00 +0200
SubjectRe: [PATCH 2/5] irqchip/gic-v3: Make gic_enable_sre an inline function
Message-ID<qhlLP-81t-1@gated-at.bofh.it>
On Fri, Oct 02, 2015 at 05:37:51PM +0100, Marc Zyngier wrote:
> +static inline bool gic_enable_sre(void)
> +{
> +	u64 val;
> +
> +	asm volatile("mrs_s %0, " __stringify(ICC_SRE_EL1) : "=r" (val));
> +	if (val & ICC_SRE_EL1_SRE)
> +		return true;
> +
> +	val |= ICC_SRE_EL1_SRE;
> +	asm volatile("msr_s " __stringify(ICC_SRE_EL1) ", %0" : : "r" (val));
> +	isb();
> +	asm volatile("mrs_s %0, " __stringify(ICC_SRE_EL1) : "=r" (val));
> +
> +	return !!(val & ICC_SRE_EL1_SRE);
> +}

I don't think !! is needed ;). Apparently, from ISO C99: "When any
scalar value is converted to _Bool, the result is 0 if the value
compares equal to 0; otherwise, the result is 1."

-- 
Catalin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1242579 — Re: [PATCH 2/5] irqchip/gic-v3: Make gic_enable_sre an inline function

FromMarc Zyngier <marc.zyngier@arm.com>
Date2015-10-08 18:10 +0200
SubjectRe: [PATCH 2/5] irqchip/gic-v3: Make gic_enable_sre an inline function
Message-ID<qhlVw-8s5-31@gated-at.bofh.it>
In reply to#1242556
On 08/10/15 16:54, Catalin Marinas wrote:
> On Fri, Oct 02, 2015 at 05:37:51PM +0100, Marc Zyngier wrote:
>> +static inline bool gic_enable_sre(void)
>> +{
>> +	u64 val;
>> +
>> +	asm volatile("mrs_s %0, " __stringify(ICC_SRE_EL1) : "=r" (val));
>> +	if (val & ICC_SRE_EL1_SRE)
>> +		return true;
>> +
>> +	val |= ICC_SRE_EL1_SRE;
>> +	asm volatile("msr_s " __stringify(ICC_SRE_EL1) ", %0" : : "r" (val));
>> +	isb();
>> +	asm volatile("mrs_s %0, " __stringify(ICC_SRE_EL1) : "=r" (val));
>> +
>> +	return !!(val & ICC_SRE_EL1_SRE);
>> +}
> 
> I don't think !! is needed ;). Apparently, from ISO C99: "When any
> scalar value is converted to _Bool, the result is 0 if the value
> compares equal to 0; otherwise, the result is 1."

Are you going to break my fingers? ;-)

From my very own PoV, !! acts as a reminder that I have realised what
the return type is. Yeah, that's how bad my brain is these days :-)

	M.
-- 
Jazz is not dead. It just smells funny...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web