Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: "J.A. Bezemer" <j.a.bezemer@opensourcepartners.nl>,
	linux-gpio@vger.kernel.org
Subject: Re: [libgpiod][PATCH v2 retry] core: fix deselection of output direction when edge detection is selected
Date: Thu, 4 Jan 2024 18:51:50 +0800	[thread overview]
Message-ID: <20240104105150.GA68799@rigel> (raw)
In-Reply-To: <CAMRc=MeoSzL=BbknUWFZkUD57pym+D9Ghjb9iyrgJJBUhRdXHg@mail.gmail.com>

On Thu, Jan 04, 2024 at 01:13:35AM -0800, Bartosz Golaszewski wrote:
> On Wed, 3 Jan 2024 20:18:27 +0100, "J.A. Bezemer"
> <j.a.bezemer@opensourcepartners.nl> said:
> > Fix deselection of output direction when edge detection is selected in
> > make_kernel_flags(). Use correct flag to perform deselection rather than
> > a library enum.
> >
> > For correct usage, there are no visible side-effects. The wrongly reset
> > kernel flags are always zero already.
> >
> > For incorrect usage of edge detection combined with output direction,
> > both output and input directions would have been requested from the
> > kernel, causing a confusing error. Such usage will now be sanitized, as
> > intended, into a working configuration with only input direction.
> >
> > Signed-off-by: Anne Bezemer <j.a.bezemer@opensourcepartners.nl>
> > ---
> >  lib/line-config.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/lib/line-config.c b/lib/line-config.c
> > index 2749a2a..9bf7734 100644
> > --- a/lib/line-config.c
> > +++ b/lib/line-config.c
> > @@ -381,18 +381,18 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
> >  	case GPIOD_LINE_EDGE_FALLING:
> >  		flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
> >  			  GPIO_V2_LINE_FLAG_INPUT);
> > -		flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
> > +		flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
> >  		break;
> >  	case GPIOD_LINE_EDGE_RISING:
> >  		flags |= (GPIO_V2_LINE_FLAG_EDGE_RISING |
> >  			  GPIO_V2_LINE_FLAG_INPUT);
> > -		flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
> > +		flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
> >  		break;
> >  	case GPIOD_LINE_EDGE_BOTH:
> >  		flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
> >  			  GPIO_V2_LINE_FLAG_EDGE_RISING |
> >  			  GPIO_V2_LINE_FLAG_INPUT);
> > -		flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
> > +		flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
> >  		break;
> >  	default:
> >  		break;
> > --
> > 2.30.2
> >
> >
> >
>
> It doesn't seem like you ran the test suite because it breaks one of
> the test cases:
>
> **
> gpiod-test:ERROR:tests-edge-event.c:80:_gpiod_test_func_cannot_request_lines_in_output_mode_with_edge_detection:
> 'request' should be NULL
> # gpiod-test:ERROR:tests-edge-event.c:80:_gpiod_test_func_cannot_request_lines_in_output_mode_with_edge_detection:
> 'request' should be NULL
> **
> gpiod-test:ERROR:tests-edge-event.c:81:_gpiod_test_func_cannot_request_lines_in_output_mode_with_edge_detection:
> assertion failed (22 == errno): (22 == 0)
> # gpiod-test:ERROR:tests-edge-event.c:81:_gpiod_test_func_cannot_request_lines_in_output_mode_with_edge_detection:
> assertion failed (22 == errno): (22 == 0)
> not ok 19 /gpiod/edge-event/cannot_request_lines_in_output_mode_with_edge_detection
>

Interesting.  So the actual bug is that make_kernel_flags() shouldm't be
sanatizing the flags at all?

Cheers,
Kent.


  reply	other threads:[~2024-01-04 10:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-03 19:18 [libgpiod][PATCH v2 retry] core: fix deselection of output direction when edge detection is selected J.A. Bezemer
2024-01-04  9:13 ` Bartosz Golaszewski
2024-01-04 10:51   ` Kent Gibson [this message]
2024-01-04 13:13     ` Bartosz Golaszewski
2024-01-04 13:34       ` Kent Gibson
2024-01-04 13:37         ` Bartosz Golaszewski

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=20240104105150.GA68799@rigel \
    --to=warthog618@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=j.a.bezemer@opensourcepartners.nl \
    --cc=linux-gpio@vger.kernel.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