lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=McSXrivkzhJVEh7-+1fzO6EBLMawhxYd7YgcsXW9wBKbA@mail.gmail.com>
Date: Fri, 22 Dec 2023 09:58:48 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Kent Gibson <warthog618@...il.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, 
	Bartosz Golaszewski <bartosz.golaszewski@...aro.org>, linux-gpio@...r.kernel.org, 
	linux-kernel@...r.kernel.org, Linus Walleij <linus.walleij@...aro.org>, 
	Andy Shevchenko <andy@...nel.org>
Subject: Re: [PATCH v1 1/1] gpiolib: cdev: Split line_get_debounce_period()
 and use

On Fri, Dec 22, 2023 at 2:12 AM Kent Gibson <warthog618@...il.com> wrote:
>
> On Thu, Dec 21, 2023 at 07:55:27PM +0200, Andy Shevchenko wrote:
> > Instead of repeating the same code and reduce possible miss
> > of READ_ONCE(), split line_get_debounce_period() heler out
> > and use in the existing cases.
> >
>
> helper
>
>
> Not a fan of this change.
>

Yeah, sorry but NAK. READ_ONCE() is well known and tells you what the
code does. Arbitrary line_get_debounce_period() makes me have to look
it up.

Bart

> So using READ_ONCE() is repeating code??
> Doesn't providing a wrapper around READ_ONCE() just rename that repitition?
> What of all the other uses of READ_ONCE() in cdev (and there are a lot) -
> why pick on debounce_period?
>
> The line_set_debounce_period() is necessary as the set is now a
> multi-step process as it can impact whether the line is contained
> in the supinfo_tree.  The get is just a get.
>
> And you could've included me in the Cc so I didn't just find it by
> accident.
>
> Cheers,
> Kent.
>
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> > ---
> >  drivers/gpio/gpiolib-cdev.c | 23 ++++++++++++++---------
> >  1 file changed, 14 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> > index 744734405912..c573820d5722 100644
> > --- a/drivers/gpio/gpiolib-cdev.c
> > +++ b/drivers/gpio/gpiolib-cdev.c
> > @@ -651,6 +651,16 @@ static struct line *supinfo_find(struct gpio_desc *desc)
> >       return NULL;
> >  }
> >
> > +static unsigned int line_get_debounce_period(struct line *line)
> > +{
> > +     return READ_ONCE(line->debounce_period_us);
> > +}
> > +
> > +static inline bool line_has_supinfo(struct line *line)
> > +{
> > +     return line_get_debounce_period(line);
> > +}
> > +
> >  static void supinfo_to_lineinfo(struct gpio_desc *desc,
> >                               struct gpio_v2_line_info *info)
> >  {
> > @@ -665,15 +675,10 @@ static void supinfo_to_lineinfo(struct gpio_desc *desc,
> >
> >       attr = &info->attrs[info->num_attrs];
> >       attr->id = GPIO_V2_LINE_ATTR_ID_DEBOUNCE;
> > -     attr->debounce_period_us = READ_ONCE(line->debounce_period_us);
> > +     attr->debounce_period_us = line_get_debounce_period(line);
> >       info->num_attrs++;
> >  }
> >
> > -static inline bool line_has_supinfo(struct line *line)
> > -{
> > -     return READ_ONCE(line->debounce_period_us);
> > -}
> > -
> >  /*
> >   * Checks line_has_supinfo() before and after the change to avoid unnecessary
> >   * supinfo_tree access.
> > @@ -846,7 +851,7 @@ static enum hte_return process_hw_ts(struct hte_ts_data *ts, void *p)
> >               line->total_discard_seq++;
> >               line->last_seqno = ts->seq;
> >               mod_delayed_work(system_wq, &line->work,
> > -               usecs_to_jiffies(READ_ONCE(line->debounce_period_us)));
> > +                              usecs_to_jiffies(line_get_debounce_period(line)));
> >       } else {
> >               if (unlikely(ts->seq < line->line_seqno))
> >                       return HTE_CB_HANDLED;
> > @@ -987,7 +992,7 @@ static irqreturn_t debounce_irq_handler(int irq, void *p)
> >       struct line *line = p;
> >
> >       mod_delayed_work(system_wq, &line->work,
> > -             usecs_to_jiffies(READ_ONCE(line->debounce_period_us)));
> > +                      usecs_to_jiffies(line_get_debounce_period(line)));
> >
> >       return IRQ_HANDLED;
> >  }
> > @@ -1215,7 +1220,7 @@ static int edge_detector_update(struct line *line,
> >                       gpio_v2_line_config_debounce_period(lc, line_idx);
> >
> >       if ((active_edflags == edflags) &&
> > -         (READ_ONCE(line->debounce_period_us) == debounce_period_us))
> > +         (line_get_debounce_period(line) == debounce_period_us))
> >               return 0;
> >
> >       /* sw debounced and still will be...*/
> > --
> > 2.43.0.rc1.1.gbec44491f096
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ