Skip to content

Commit

Permalink
Changes to allow creation of 512 binder devices
Browse files Browse the repository at this point in the history
As there is a need to create 512 binder devices,
increase misc devices number from 256 to 1024.

Signed-off-by: Jeevaka Prabu Badrappan <[email protected]>
  • Loading branch information
JeevakaPrabu committed Nov 14, 2022
1 parent 892ce93 commit 05885e0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <linux/cred.h>
#include <linux/mnt_idmapping.h>
#include <linux/android_kabi.h>
#include <linux/major.h>

#include <asm/byteorder.h>
#include <uapi/linux/fs.h>
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit 05885e0

Please sign in to comment.