From mboxrd@z Thu Jan 1 00:00:00 1970 From: marc.zyngier@arm.com (Marc Zyngier) Date: Thu, 08 Oct 2015 17:02:27 +0100 Subject: [PATCH 2/5] irqchip/gic-v3: Make gic_enable_sre an inline function In-Reply-To: <20151008155404.GN17192@e104818-lin.cambridge.arm.com> References: <1443803874-9566-1-git-send-email-marc.zyngier@arm.com> <1443803874-9566-3-git-send-email-marc.zyngier@arm.com> <20151008155404.GN17192@e104818-lin.cambridge.arm.com> Message-ID: <56169393.5050606@arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org 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... From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757450AbbJHQCb (ORCPT ); Thu, 8 Oct 2015 12:02:31 -0400 Received: from foss.arm.com ([217.140.101.70]:35299 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757153AbbJHQCa (ORCPT ); Thu, 8 Oct 2015 12:02:30 -0400 Message-ID: <56169393.5050606@arm.com> Date: Thu, 08 Oct 2015 17:02:27 +0100 From: Marc Zyngier Organization: ARM Ltd User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Catalin Marinas CC: Thomas Gleixner , Jason Cooper , Will Deacon , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 2/5] irqchip/gic-v3: Make gic_enable_sre an inline function References: <1443803874-9566-1-git-send-email-marc.zyngier@arm.com> <1443803874-9566-3-git-send-email-marc.zyngier@arm.com> <20151008155404.GN17192@e104818-lin.cambridge.arm.com> In-Reply-To: <20151008155404.GN17192@e104818-lin.cambridge.arm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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...