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: 5732391 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6FC7B9F398 for ; Wed, 28 Jan 2015 22:14:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4514520103 for ; Wed, 28 Jan 2015 22:14:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5626F200E8 for ; Wed, 28 Jan 2015 22:14:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753067AbbA1UQW (ORCPT ); Wed, 28 Jan 2015 15:16:22 -0500 Received: from mail-lb0-f175.google.com ([209.85.217.175]:37301 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753143AbbA1UQV (ORCPT ); Wed, 28 Jan 2015 15:16:21 -0500 Received: by mail-lb0-f175.google.com with SMTP id 10so21024436lbg.6; Wed, 28 Jan 2015 12:16:19 -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 Cc: Ricardo Ribalda 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 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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;