From 05885e0bfcc336e56b86029b0c7c7ab8ad520c33 Mon Sep 17 00:00:00 2001 From: Jeevaka Prabu Badrappan Date: Tue, 15 Feb 2022 22:41:49 +0530 Subject: [PATCH] Changes to allow creation of 512 binder devices As there is a need to create 512 binder devices, increase misc devices number from 256 to 1024. Signed-off-by: Jeevaka Prabu Badrappan --- include/linux/fs.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 3dd3632de00b8..481df7f6c191e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -2782,6 +2783,15 @@ extern const struct file_operations def_chr_fops; #define CHRDEV_MAJOR_DYN_EXT_START 511 #define CHRDEV_MAJOR_DYN_EXT_END 384 +/* Need to create 512 binder devices */ +/* Increase misc devices number from 256 to 1024 */ +#define MAJOR_FILTER(x, y, base) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x == _y ? base * 4 : base; \ +}) + extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *); extern int register_chrdev_region(dev_t, unsigned, const char *); extern int __register_chrdev(unsigned int major, unsigned int baseminor, @@ -2795,12 +2805,13 @@ extern void chrdev_show(struct seq_file *,off_t); static inline int register_chrdev(unsigned int major, const char *name, const struct file_operations *fops) { - return __register_chrdev(major, 0, 256, name, fops); + return __register_chrdev(major, 0, MAJOR_FILTER(major, (unsigned int)MISC_MAJOR, 256), + name, fops); } static inline void unregister_chrdev(unsigned int major, const char *name) { - __unregister_chrdev(major, 0, 256, name); + __unregister_chrdev(major, 0, MAJOR_FILTER(major, (unsigned int)MISC_MAJOR, 256), name); } extern void init_special_inode(struct inode *, umode_t, dev_t);