[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1402477001-31132-14-git-send-email-rogerq@ti.com>
Date: Wed, 11 Jun 2014 11:56:18 +0300
From: Roger Quadros <rogerq@...com>
To: <tony@...mide.com>, <dwmw2@...radead.org>,
<computersforpeace@...il.com>
CC: <kyungmin.park@...sung.com>, <pekon@...com>,
<ezequiel.garcia@...e-electrons.com>, <javier@...hile0.org>,
<nsekhar@...com>, <linux-omap@...r.kernel.org>,
<linux-mtd@...ts.infradead.org>, <devicetree@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, Roger Quadros <rogerq@...com>
Subject: [PATCH 13/36] ARM: OMAP2+: gpmc.c: sanity check bank-width DT property
Make sure bank-width property provided via DT is sane.
Signed-off-by: Roger Quadros <rogerq@...com>
---
arch/arm/mach-omap2/gpmc.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index c713616..70cb6b0 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -1219,6 +1219,7 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
struct resource res;
unsigned long base;
int ret, cs;
+ struct device *dev = &pdev->dev;
if (of_property_read_u32(child, "reg", &cs) < 0) {
dev_err(&pdev->dev, "%s has no 'reg' property\n",
@@ -1284,7 +1285,7 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
gpmc_s.device_width = GPMC_DEVWIDTH_16BIT;
break;
default:
- dev_err(&pdev->dev, "%s: invalid 'nand-bus-width'\n",
+ dev_err(dev, "%s: invalid 'nand-bus-width'\n",
child->name);
ret = -EINVAL;
goto err;
@@ -1292,10 +1293,18 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
gpmc_s.device_nand = true;
} else {
- ret = of_property_read_u32(child, "bank-width",
- &gpmc_s.device_width);
- if (ret < 0)
+ if (of_property_read_u32(child, "bank-width",
+ &gpmc_s.device_width)) {
+ dev_err(dev, "%s: no 'bank-width' property\n",
+ child->name);
+ goto err;
+ }
+
+ if (gpmc_s.device_width < 1 || gpmc_s.device_width > 2) {
+ dev_err(dev, "%s: invalid 'bank-width'\n",
+ child->name);
goto err;
+ }
}
ret = gpmc_cs_program_settings(cs, &gpmc_s);
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists