[U-Boot] [PATCH 1/2] microblaze: Disabling interrupt should return 1 if implemented

Wolfgang Denk wd at denx.de
Tue Dec 21 13:24:12 CET 2010


Dear Michal Simek,

In message <1292933384-3032-2-git-send-email-monstr at monstr.eu> you wrote:
> Microblaze implement enable/disable interrupts through MSR
> that's why disable_interrupts function should return 1.
> 
> Signed-off-by: John Linn <john.linn at xilinx.com>
> Signed-off-by: Michal Simek <monstr at monstr.eu>
> ---
>  arch/microblaze/cpu/interrupts.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/microblaze/cpu/interrupts.c b/arch/microblaze/cpu/interrupts.c
> index e9d53c1..331746c 100644
> --- a/arch/microblaze/cpu/interrupts.c
> +++ b/arch/microblaze/cpu/interrupts.c
> @@ -42,7 +42,7 @@ void enable_interrupts (void)
>  int disable_interrupts (void)
>  {
>  	MSRCLR(0x2);
> -	return 0;
> +	return 1;
>  }

I think this is wrong.  disable_interrupts() should return 1 only if
interrupts were enabled before, so code like this can make sure that
some parts are run with interrupts disabled, but then restore the
previous state, no matter if this had interrupts on or off:

	int flag = disable_interrupts();
	...
	do something
	...
	if (flag)
		enable_interrupts();

With your code, we would ALWAYS enable interrupts, even if these were
off before.

For reference, see for example arch/powerpc/lib/interrupts.c

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Quote from the Boss... "I didn't say it was your fault.  I said I was
going to blame it on you."


More information about the U-Boot mailing list