[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250923075302.591026-7-tzungbi@kernel.org>
Date: Tue, 23 Sep 2025 07:53:01 +0000
From: Tzung-Bi Shih <tzungbi@...nel.org>
To: Benson Leung <bleung@...omium.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Danilo Krummrich <dakr@...nel.org>
Cc: Jonathan Corbet <corbet@....net>,
Shuah Khan <shuah@...nel.org>,
Dawid Niedzwiecki <dawidn@...gle.com>,
linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org,
chrome-platform@...ts.linux.dev,
linux-kselftest@...r.kernel.org,
tzungbi@...nel.org,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Bartosz Golaszewski <brgl@...ev.pl>,
Wolfram Sang <wsa+renesas@...g-engineering.com>
Subject: [PATCH v4 6/7] char: misc: Leverage revocable fops replacement
Signed-off-by: Tzung-Bi Shih <tzungbi@...nel.org>
---
PoC patch.
v4:
- New in the series.
drivers/char/misc.c | 7 +++++++
include/linux/miscdevice.h | 3 +++
2 files changed, 10 insertions(+)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 726516fb0a3b..fcbbb0b1af35 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -159,6 +159,13 @@ static int misc_open(struct inode *inode, struct file *file)
err = 0;
replace_fops(file, new_fops);
+
+ if (c->rp && c->rops) {
+ err = revocable_replace_fops(file, c->rp, c->rops);
+ if (err)
+ goto fail;
+ }
+
if (file->f_op->open)
err = file->f_op->open(inode, file);
fail:
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 7d0aa718499c..00f5c878266a 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -5,6 +5,7 @@
#include <linux/list.h>
#include <linux/types.h>
#include <linux/device.h>
+#include <linux/revocable.h>
/*
* These allocations are managed by device@...ana.org. If you need
@@ -92,6 +93,8 @@ struct miscdevice {
const struct attribute_group **groups;
const char *nodename;
umode_t mode;
+ struct revocable_provider *rp;
+ const struct revocable_operations *rops;
};
extern int misc_register(struct miscdevice *misc);
--
2.51.0.534.gc79095c0ca-goog
Powered by blists - more mailing lists