Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 452a3b68 authored by Fenglin Wu's avatar Fenglin Wu Committed by David Collins
Browse files

regmap: Make regmap debugfs write optional



Regmap debugfs write could be risky when accessing some essential
hardwares. Make REGMAP_ALLOW_WRITE_DEBUGFS configurable so that debugfs
write could be disabled if it's not desired.

CRs-Fixed: 1103178
Change-Id: I4a494e98e9556d694f45302bf294bb58bc2adba2
Signed-off-by: default avatarFenglin Wu <fenglinw@codeaurora.org>
parent 362ed751
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -60,3 +60,12 @@ config REGMAP_WCD_IRQ
	  This config is intended for enabling REGMAP_IRQ for
	  WCD IRQ. Generic WCD IRQ will be used for
	  wcd937x and later targets.

config REGMAP_ALLOW_WRITE_DEBUGFS
	depends on REGMAP && DEBUG_FS
	bool "Allow REGMAP debugfs write"
	default n
	help
	  Say 'y' here to allow the regmap debugfs write. Regmap debugfs write
	  could be risky when accessing some essential hardwares, so it is not
	  recommended to enable this option on any production device.
+3 −4
Original line number Diff line number Diff line
@@ -274,8 +274,7 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
				   count, ppos);
}

#define REGMAP_ALLOW_WRITE_DEBUGFS
#ifdef REGMAP_ALLOW_WRITE_DEBUGFS
#ifdef CONFIG_REGMAP_ALLOW_WRITE_DEBUGFS
/*
 * This can be dangerous especially when we have clients such as
 * PMICs, therefore don't provide any real compile time configuration option
@@ -345,7 +344,7 @@ static ssize_t regmap_data_read_file(struct file *file, char __user *user_buf,
			new_count, ppos);
}

#ifdef REGMAP_ALLOW_WRITE_DEBUGFS
#ifdef CONFIG_REGMAP_ALLOW_WRITE_DEBUGFS
static ssize_t regmap_data_write_file(struct file *file,
				     const char __user *user_buf,
				     size_t count, loff_t *ppos)
@@ -661,7 +660,7 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
	if (map->max_register || regmap_readable(map, 0)) {
		umode_t registers_mode;

#if defined(REGMAP_ALLOW_WRITE_DEBUGFS)
#ifdef CONFIG_REGMAP_ALLOW_WRITE_DEBUGFS
		registers_mode = 0600;
#else
		registers_mode = 0400;