soc/tegra: fuse: Warn if accessing unmapped registers
authorThierry Reding <treding@nvidia.com>
Mon, 26 Jun 2017 15:23:27 +0000 (17:23 +0200)
committerThierry Reding <treding@nvidia.com>
Wed, 13 Dec 2017 11:43:31 +0000 (12:43 +0100)
If the FUSE registers are accessed but the region is not mapped, warn
and return 0. This potentially catches hard to diagnose bugs because the
accesses happen before any kernel log output.

Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/soc/tegra/fuse/fuse-tegra30.c

index 497eb044095fe249c9875e117ff47017b247b624..257e254c6137f806e6cf77112184ce4796bf0257 100644 (file)
@@ -50,6 +50,9 @@
     defined(CONFIG_ARCH_TEGRA_186_SOC)
 static u32 tegra30_fuse_read_early(struct tegra_fuse *fuse, unsigned int offset)
 {
+       if (WARN_ON(!fuse->base))
+               return 0;
+
        return readl_relaxed(fuse->base + FUSE_BEGIN + offset);
 }