From patchwork Wed Jan 28 19:53:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 5729181 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9C02FBF440 for ; Wed, 28 Jan 2015 19:56:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD2D12027D for ; Wed, 28 Jan 2015 19:56:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 15AF82012D for ; Wed, 28 Jan 2015 19:56:06 +0000 (UTC) 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 1YGYgs-00080i-Mt; Wed, 28 Jan 2015 19:54:18 +0000 Received: from mail-lb0-x22f.google.com ([2a00:1450:4010:c04::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YGYgk-0007L7-Ko for linux-arm-kernel@lists.infradead.org; Wed, 28 Jan 2015 19:54:11 +0000 Received: by mail-lb0-f175.google.com with SMTP id 10so20816283lbg.6 for ; Wed, 28 Jan 2015 11:53:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=B/v5jPr/6cUAW+OX2dGiHcT9Vbz22zqdiEfUIh4Whjo=; b=w2zPuJOeXlDnkpoQ3kyySA+XkzQ2Nh8r6wM0v1/OGEKoRUGySV87CmxXwTJSFLW4r5 547/dNWouIqpFHgpBdSPPQfOL1V963QFvXWTtOZiO7VTXsY047Gz6tPpO8m0cLi9ZbCw 6ja5J1PL/nfSV1s6NuTYXHYadKZki0EqDnHXrv8ACYi89bE+qWfkA+QyoethzvXKBZzf NoJpfhvG9qvc/Ff3O7jl8Gi6nPVEB/RSQAdjZT42A8qpcLp4jd3DL5CH24SR08l4g0Lc 9H+cXoqTksuzy7cKu6dk+ERcIKxO3UoukXermqddPr1VQvp01UDkWwXs2gjKfm/d1SvR Wrag== X-Received: by 10.112.30.135 with SMTP id s7mr10340067lbh.63.1422474827902; Wed, 28 Jan 2015 11:53:47 -0800 (PST) Received: from localhost.localdomain (x1-6-30-46-9a-6d-3c-54.cpe.webspeed.dk. [2.108.161.190]) by mx.google.com with ESMTPSA id x1sm1566405lby.26.2015.01.28.11.53.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Jan 2015 11:53:47 -0800 (PST) From: Ricardo Ribalda Delgado To: Mark Brown , Michal Simek , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi/xilinx: Check number of slaves range Date: Wed, 28 Jan 2015 20:53:39 +0100 Message-Id: <1422474819-22689-1-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150128_115410_874471_1AA87EF7 X-CRM114-Status: UNSURE ( 9.17 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.8 (/) Cc: Ricardo Ribalda X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ricardo Ribalda The core only supports up to 32 slaves, and the chipselect function expects the same. Signed-off-by: Ricardo Ribalda Delgado --- v2: Change suggested by Mark Brown -Namespace the constant drivers/spi/spi-xilinx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index 416b227..354dbb4 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c @@ -22,6 +22,8 @@ #include #include +#define XILINX_SPI_MAX_CS 32 + #define XILINX_SPI_NAME "xilinx_spi" /* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e) @@ -354,6 +356,11 @@ static int xilinx_spi_probe(struct platform_device *pdev) return -EINVAL; } + if (num_cs > XILINX_SPI_MAX_CS) { + dev_err(&pdev->dev, "Invalid number of spi slaves\n"); + return -EINVAL; + } + master = spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi)); if (!master) return -ENODEV;