ARM: tegra: Fix debugfs strings for powergate
Peter De Schrijver [Thu, 30 Aug 2012 13:57:21 +0000 (16:57 +0300)]
Replace powergate_name[] by a call to tegra_powergate_get_name().
This fixes the out of bounds accesses for SoCs other than Tegra20.

bug 1041476

Change-Id: I0e299960404fae33af3ef0423344001e133b8653
Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/130597
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>

Rebase-Id: Rb97068d00a429d16bca1fc7ddda3a97c9d3f919b

arch/arm/mach-tegra/powergate.c

index b4da563..ade757a 100644 (file)
@@ -894,26 +894,21 @@ const char *tegra_powergate_get_name(int id)
 
 #ifdef CONFIG_DEBUG_FS
 
-static const char * const powergate_name[] = {
-       [TEGRA_POWERGATE_CPU]   = "cpu",
-       [TEGRA_POWERGATE_3D]    = "3d",
-       [TEGRA_POWERGATE_VENC]  = "venc",
-       [TEGRA_POWERGATE_VDEC]  = "vdec",
-       [TEGRA_POWERGATE_PCIE]  = "pcie",
-       [TEGRA_POWERGATE_L2]    = "l2",
-       [TEGRA_POWERGATE_MPE]   = "mpe",
-};
-
 static int powergate_show(struct seq_file *s, void *data)
 {
        int i;
+       const char *name;
 
        seq_printf(s, " powergate powered\n");
        seq_printf(s, "------------------\n");
 
-       for (i = 0; i < tegra_num_powerdomains; i++)
-               seq_printf(s, " %9s %7s\n", powergate_name[i],
-                       tegra_powergate_is_powered(i) ? "yes" : "no");
+       for (i = 0; i < tegra_num_powerdomains; i++) {
+               name = tegra_powergate_get_name(i);
+               if (name)
+                       seq_printf(s, " %9s %7s\n", name,
+                               tegra_powergate_is_powered(i) ? "yes" : "no");
+       }
+
        return 0;
 }