From: Marco Felsch <m.felsch@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Cc: Marco Felsch <m.felsch@pengutronix.de>
Subject: [PATCH v2 2/7] serdev: add serdev_device_close
Date: Thu, 12 Feb 2026 23:02:04 +0100 [thread overview]
Message-ID: <20260212-vmaster-customers-leicageo-system1600-v2-2-f590b7d5b0e9@pengutronix.de> (raw)
In-Reply-To: <20260212-vmaster-customers-leicageo-system1600-v2-0-f590b7d5b0e9@pengutronix.de>
Add a cleanup helper which does the reverse operations of
serdev_device_open().
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
common/serdev.c | 13 +++++++++++++
include/serdev.h | 4 ++++
2 files changed, 17 insertions(+)
diff --git a/common/serdev.c b/common/serdev.c
index 8f45c0a135237da42579bbb685c9c25a67428c8b..1c8cfbd59447afa86aa78c5b05b60e9057ebc15b 100644
--- a/common/serdev.c
+++ b/common/serdev.c
@@ -92,6 +92,8 @@ int serdev_device_open(struct serdev_device *serdev)
goto err_console_close;
}
+ serdev->polling_interval_param = p;
+
return 0;
err_console_close:
@@ -106,6 +108,17 @@ int serdev_device_open(struct serdev_device *serdev)
return ret;
}
+void serdev_device_close(struct serdev_device *serdev)
+{
+ struct console_device *cdev = to_console_device(serdev);
+
+ param_remove(serdev->polling_interval_param);
+ console_close(cdev);
+ poller_async_unregister(&serdev->poller);
+ kfifo_free(serdev->fifo);
+ free(serdev->buf);
+}
+
unsigned int serdev_device_set_baudrate(struct serdev_device *serdev,
unsigned int speed)
{
diff --git a/include/serdev.h b/include/serdev.h
index b402325f39a2458bf364d84ec1d9a5da6b829525..98704d8958d016426951a038a9a80fb05626febb 100644
--- a/include/serdev.h
+++ b/include/serdev.h
@@ -3,6 +3,7 @@
#define _SERDEV_H_
#include <driver.h>
+#include <param.h>
#include <poller.h>
#include <kfifo.h>
@@ -14,6 +15,7 @@
* @buf: Buffer used to pass Rx data to consumers
* @poller Async poller used to poll this serdev
* @polling_interval: Async poller periodicity
+ * @polling_interval_param: Async poller periodicity barebox param_d
* @polling_window: Duration of a single busy loop poll
* @locked: Lock to prevent recursive polling
* @receive_buf: Function called with data received from device;
@@ -25,6 +27,7 @@ struct serdev_device {
unsigned char *buf;
struct poller_async poller;
uint64_t polling_interval;
+ struct param_d *polling_interval_param;
uint64_t polling_window;
bool locked;
@@ -33,6 +36,7 @@ struct serdev_device {
};
int serdev_device_open(struct serdev_device *);
+void serdev_device_close(struct serdev_device *);
unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int);
int serdev_device_write(struct serdev_device *, const unsigned char *,
size_t, unsigned long);
--
2.47.3
next prev parent reply other threads:[~2026-02-12 22:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 22:02 [PATCH v2 0/7] Hexagon Geosystems GS05 Board Support Marco Felsch
2026-02-12 22:02 ` [PATCH v2 1/7] serdev: add proper error cleanup to serdev_device_open() Marco Felsch
2026-02-12 22:02 ` Marco Felsch [this message]
2026-02-12 22:02 ` [PATCH v2 3/7] mfd: Add Hexagon EFI driver Marco Felsch
2026-02-12 22:02 ` [PATCH v2 4/7] watchdog: Add Hexagon EFI watchdog driver Marco Felsch
2026-02-12 22:02 ` [PATCH v2 5/7] commands: make run_command variadic Marco Felsch
2026-02-12 22:02 ` [PATCH v2 6/7] treewide: make use of new " Marco Felsch
2026-02-12 22:02 ` [PATCH v2 7/7] ARM: i.MX8MM: add Hexagon Geosystems GS05 Marco Felsch
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=20260212-vmaster-customers-leicageo-system1600-v2-2-f590b7d5b0e9@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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