Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
---
PoC patch.
v5:
- No primary changes but modify the API usage accordingly to support
multiple revocable providers.
v4: https://lore.kernel.org/chrome-platform/20250923075302.591026-7-tzungbi@kernel.org
- New in the series.
drivers/char/misc.c | 8 ++++++++
include/linux/miscdevice.h | 4 ++++
2 files changed, 12 insertions(+)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 726516fb0a3b..5b412e18b8a6 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -50,6 +50,7 @@
#include <linux/tty.h>
#include <linux/kmod.h>
#include <linux/gfp.h>
+#include <linux/fs_revocable.h>
/*
* Head entry for the doubly linked miscdevice list
@@ -159,6 +160,13 @@ static int misc_open(struct inode *inode, struct file *file)
err = 0;
replace_fops(file, new_fops);
+
+ if (c->frops && c->rps) {
+ err = fs_revocable_replace(file, c->frops, c->rps, c->num_rps);
+ 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..b7024a0cebb9 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@lanana.org. If you need
@@ -92,6 +93,9 @@ struct miscdevice {
const struct attribute_group **groups;
const char *nodename;
umode_t mode;
+ struct revocable_provider **rps;
+ size_t num_rps;
+ const struct fs_revocable_operations *frops;
};
extern int misc_register(struct miscdevice *misc);
--
2.51.0.788.g6d19910ace-goog