regmap: Fix debugfs-file 'registers' mode
authorMarkus Pargmann <mpa@pengutronix.de>
Mon, 8 Sep 2014 06:43:37 +0000 (08:43 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 29 Sep 2014 17:22:26 +0000 (18:22 +0100)
The macro "REGMAP_ALLOW_WRITE_DEBUGFS" can be used to enable write
support on the registers file in the debugfs. The mode of the file is
fixed to 0400 so it is not possible to write the file ever.

This patch fixes the mode by setting it to the correct value depending
on the macro.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regmap-debugfs.c

index bdd88708e4d6735b3fa10e83b324bde0cfc7d68b..a88cbd42edf0e3bc2d3e0a09dcc4d78115ed634f 100644 (file)
@@ -516,7 +516,14 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
                            map, &regmap_reg_ranges_fops);
 
        if (map->max_register || regmap_readable(map, 0)) {
-               debugfs_create_file("registers", 0400, map->debugfs,
+               umode_t registers_mode;
+
+               if (IS_ENABLED(REGMAP_ALLOW_WRITE_DEBUGFS))
+                       registers_mode = 0600;
+               else
+                       registers_mode = 0400;
+
+               debugfs_create_file("registers", registers_mode, map->debugfs,
                                    map, &regmap_map_fops);
                debugfs_create_file("access", 0400, map->debugfs,
                                    map, &regmap_access_fops);