From patchwork Wed Jun 11 08:56:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 31739 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9653B203C2 for ; Wed, 11 Jun 2014 09:00:47 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id hz1sf7000465pad.11 for ; Wed, 11 Jun 2014 02:00:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:mime-version:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=UALalcciuin/kmu6nnUuRqVvQN/QcEuNCaw0Ru84gLY=; b=grKGA0BpmRMD/yL3wv6nA+JCwZJf3BWZwTizDYcJdNvVDSSzlwk5mtM9TsLqoiaqJp FqBroz+yOqhEMTMzXmdteexlGLflsl/cfUfTA27nkmLL00MqfcAYcGmkONz1eghxk/Gw KtVXfHvmj3YuNoX21+A06ZO9t06uYd5T9SHs/4ImCMFqoivg+rx7293KQpDb7IXGYrjC bIieJguI7j+d97OCGJRMaBYkaBDcqc0mdZfr98cP4Ab3r7/T6t+Q3vyHvbzZlGa6w5h5 hyvPYvMzk76Cbfq4E6jI666K3iz7LnLQxX0YG5sDPN9pABl9GH1MV490wHeyw5Zim0BC k/eQ== X-Gm-Message-State: ALoCoQlk+oGdAZ91Gvj3hLSyAUHoIQrUes81DB1Vf+n0zV7Nu9oZXgWc3Id940w8BIh27qVFOrZr X-Received: by 10.66.142.9 with SMTP id rs9mr2638517pab.47.1402477246890; Wed, 11 Jun 2014 02:00:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.40 with SMTP id m37ls2597857qgd.18.gmail; Wed, 11 Jun 2014 02:00:46 -0700 (PDT) X-Received: by 10.58.185.165 with SMTP id fd5mr1837710vec.41.1402477246707; Wed, 11 Jun 2014 02:00:46 -0700 (PDT) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id 20si13987613vdd.100.2014.06.11.02.00.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Jun 2014 02:00:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.170 as permitted sender) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id oz11so5648935veb.1 for ; Wed, 11 Jun 2014 02:00:46 -0700 (PDT) X-Received: by 10.220.59.65 with SMTP id k1mr37394749vch.22.1402477246640; Wed, 11 Jun 2014 02:00:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp286599vcb; Wed, 11 Jun 2014 02:00:46 -0700 (PDT) X-Received: by 10.140.98.116 with SMTP id n107mr46148610qge.93.1402477246190; Wed, 11 Jun 2014 02:00:46 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id w6si30624819qab.69.2014.06.11.02.00.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jun 2014 02:00:46 -0700 (PDT) Received-SPF: none (google.com: linux-mtd-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WueMe-0002g9-IV; Wed, 11 Jun 2014 08:58:36 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WueM6-0001sb-7y; Wed, 11 Jun 2014 08:58:03 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5B8vZDM027137; Wed, 11 Jun 2014 03:57:35 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5B8vZcH008666; Wed, 11 Jun 2014 03:57:35 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 11 Jun 2014 03:57:34 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5B8uiSl020510; Wed, 11 Jun 2014 03:57:31 -0500 From: Roger Quadros To: , , Subject: [PATCH 13/36] ARM: OMAP2+: gpmc.c: sanity check bank-width DT property Date: Wed, 11 Jun 2014 11:56:18 +0300 Message-ID: <1402477001-31132-14-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1402477001-31132-1-git-send-email-rogerq@ti.com> References: <1402477001-31132-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140611_015802_405604_E802E678 X-CRM114-Status: UNSURE ( 8.30 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.7 (-----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-5.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.94.94.41 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [192.94.94.41 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: devicetree@vger.kernel.org, nsekhar@ti.com, linux-kernel@vger.kernel.org, kyungmin.park@samsung.com, linux-mtd@lists.infradead.org, pekon@ti.com, ezequiel.garcia@free-electrons.com, javier@dowhile0.org, linux-omap@vger.kernel.org, Roger Quadros X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rogerq@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Make sure bank-width property provided via DT is sane. Signed-off-by: Roger Quadros --- 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);