From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Andy Shevchenko <andy@kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 1/1] gpiolib: cdev: Split line_get_debounce_period() and use
Date: Thu, 21 Dec 2023 19:55:27 +0200 [thread overview]
Message-ID: <20231221175527.2814506-1-andriy.shevchenko@linux.intel.com> (raw)
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.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.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
next reply other threads:[~2023-12-21 18:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-21 17:55 Andy Shevchenko [this message]
2023-12-22 1:12 ` [PATCH v1 1/1] gpiolib: cdev: Split line_get_debounce_period() and use Kent Gibson
2023-12-22 8:58 ` Bartosz Golaszewski
2023-12-22 12:40 ` Andy Shevchenko
2023-12-22 12:58 ` Kent Gibson
2023-12-22 12:39 ` Andy Shevchenko
2023-12-22 12:56 ` Kent Gibson
2023-12-22 13:37 ` Bartosz Golaszewski
2023-12-22 14:08 ` Kent Gibson
2023-12-22 14:09 ` Bartosz Golaszewski
2023-12-22 14:14 ` Kent Gibson
2023-12-22 17:49 ` Linus Walleij
2023-12-23 2:08 ` Kent Gibson
2023-12-28 0:26 ` Linus Walleij
2023-12-28 0:49 ` Kent Gibson
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=20231221175527.2814506-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).