From 52d1e1f342b07696210075a90ccf537edbfb1bcb Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 12 Nov 2013 23:42:47 +0100 Subject: [PATCH] backports: add replace_fops() This is needed by drivers/media/dvb-core/dvbdev.c and was added in: commit e84f9e57b90ca89664d733a7cef19aa7ccd832f3 Author: Al Viro Date: Sun Sep 22 14:17:15 2013 -0400 consolidate the reassignments of ->f_op in ->open() instances Signed-off-by: Hauke Mehrtens --- backport/backport-include/linux/fs.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backport/backport-include/linux/fs.h b/backport/backport-include/linux/fs.h index 9de51097eaf0..9874f815a4a1 100644 --- a/backport/backport-include/linux/fs.h +++ b/backport/backport-include/linux/fs.h @@ -38,4 +38,18 @@ extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, const void __user *from, size_t count); #endif +#ifndef replace_fops +/* + * This one is to be used *ONLY* from ->open() instances. + * fops must be non-NULL, pinned down *and* module dependencies + * should be sufficient to pin the caller down as well. + */ +#define replace_fops(f, fops) \ + do { \ + struct file *__file = (f); \ + fops_put(__file->f_op); \ + BUG_ON(!(__file->f_op = (fops))); \ + } while(0) +#endif /* replace_fops */ + #endif /* _COMPAT_LINUX_FS_H */ -- 2.30.2