qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Miles Glenn <milesg@linux.vnet.ibm.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org, clg@kaod.org,
	andrew@codeconstruct.com.au, joel@jms.id.au, philmd@linaro.org
Subject: Re: [PATCH] misc/led: LED state is set opposite of what is expected
Date: Tue, 24 Oct 2023 13:35:46 -0500	[thread overview]
Message-ID: <a8ca6e4e89ec34b68bb246e9d6e4bf5277a42d15.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAFEAcA9ZLk7XYpjOQ-_9JXELK_qjgW3ABmpHY=aiPa+DS-131A@mail.gmail.com>

On Tue, 2023-10-24 at 18:46 +0100, Peter Maydell wrote:
> On Tue, 24 Oct 2023 at 18:40, Glenn Miles <milesg@linux.vnet.ibm.com>
> wrote:
> > Testing of the LED state showed that when the LED polarity was
> > set to GPIO_POLARITY_ACTIVE_LOW and a low logic value was set on
> > the input GPIO of the LED, the LED was being turned off when it was
> > expected to be turned on.
> 
> It looks to me from reading the code like the bug is there
> for active-high GPIO as well ?

Yes, this should fix the issue for both situations.

> 
> > Signed-off-by: Glenn Miles <milesg@linux.vnet.ibm.com>
> > ---
> >  hw/misc/led.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/hw/misc/led.c b/hw/misc/led.c
> > index f6d6d68bce..96cad7578e 100644
> > --- a/hw/misc/led.c
> > +++ b/hw/misc/led.c
> > @@ -63,7 +63,7 @@ static void led_set_state_gpio_handler(void
> > *opaque, int line, int new_state)
> >      LEDState *s = LED(opaque);
> > 
> >      assert(line == 0);
> > -    led_set_state(s, !!new_state != s->gpio_active_high);
> > +    led_set_state(s, !new_state != s->gpio_active_high);
> >  }
> 
> Maybe "!!new_state == s->gpio_active_high" would be clearer?
> Then you can see that we are (1) converting the int new_state
> to a bool with the !! idiom and (2) we enable the LED for a
> high input and active-high GPIO.
> 
> thanks
> -- PMM

Yes, I agree,  that is easier to read.  Thanks!

Glenn



      reply	other threads:[~2023-10-24 18:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-24 17:39 [PATCH] misc/led: LED state is set opposite of what is expected Glenn Miles
2023-10-24 17:46 ` Peter Maydell
2023-10-24 18:35   ` Miles Glenn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8ca6e4e89ec34b68bb246e9d6e4bf5277a42d15.camel@linux.vnet.ibm.com \
    --to=milesg@linux.vnet.ibm.com \
    --cc=andrew@codeconstruct.com.au \
    --cc=clg@kaod.org \
    --cc=joel@jms.id.au \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).