From patchwork Tue Feb 11 14:07:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3627351 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E16F7BF418 for ; Tue, 11 Feb 2014 14:07:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4187201F2 for ; Tue, 11 Feb 2014 14:07:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C028F201CE for ; Tue, 11 Feb 2014 14:07:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751199AbaBKOHm (ORCPT ); Tue, 11 Feb 2014 09:07:42 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:36673 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750984AbaBKOHl (ORCPT ); Tue, 11 Feb 2014 09:07:41 -0500 Received: by mail-pa0-f43.google.com with SMTP id rd3so7690230pab.2 for ; Tue, 11 Feb 2014 06:07:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=CQWqgZTkdgcYQ2IfnpUDApsc4CtcPlKouIhR67gQ15s=; b=C0DcUmsMnsy0Htsqq2Ir9KDbLKp/cc8cUjsaRp/6hLhVMd1G6RJSDvmkRb3xConds0 XJ7AOVY7Gdo4dvij/9RVZy4Bmk0iFU7I9g2xRXqP0gFXeB6j6a6W/mjRCVxfg+7KZ4xw 11M909epah8WKdhKIJip3y+EBis89l3ffdO6eo++Gu6I4fjb4K6E7Plc99+LCLcZlAuT iDxGJzsdAjOONccWYDqOT6i0y0Nb5yfM7V8Ek4A5GejSPbl/S93GcyKAFE8WaQ0OZtYx 2mbwpTjRAVq69ctet5SWF2BpFJgxqiiElOWIdc6BV5rSUvKcpDpzXdJNwswwJkQ4lLX/ 2tgw== X-Gm-Message-State: ALoCoQno7SRzT4XqSFCxecMhBUTH7t0fHV4e7+2vCcUbGjcVPqVlFMhTYn9Mjmdd557ELZIKd890 X-Received: by 10.67.22.100 with SMTP id hr4mr32549487pad.112.1392127659090; Tue, 11 Feb 2014 06:07:39 -0800 (PST) Received: from [10.145.55.56] ([60.245.65.194]) by mx.google.com with ESMTPSA id cz3sm53464845pbc.9.2014.02.11.06.07.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 06:07:38 -0800 (PST) Message-ID: <1392127650.9833.1.camel@phoenix> Subject: [PATCH] spi: Remove duplicate code to check chip_select From: Axel Lin To: Mark Brown Cc: Wenyou Yang , Steven King , Thomas Langer , Grant Likely , Tony Lindgren , Laxman Dewangan , Stephen Warren , linux-spi@vger.kernel.org Date: Tue, 11 Feb 2014 22:07:30 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 In spi_add_device(), we have the code to validate spi->chip_select. So remove the duplicate code in various drivers. Cc: Wenyou Yang Cc: Steven King Cc: Thomas Langer Cc: Grant Likely Cc: Tony Lindgren Cc: Laxman Dewangan Cc: Stephen Warren Signed-off-by: Axel Lin --- drivers/spi/spi-atmel.c | 7 ------- drivers/spi/spi-coldfire-qspi.c | 6 ------ drivers/spi/spi-falcon.c | 3 --- drivers/spi/spi-mpc52xx.c | 3 --- drivers/spi/spi-omap-uwire.c | 6 ------ drivers/spi/spi-tegra114.c | 2 -- drivers/spi/spi-tegra20-slink.c | 2 -- 7 files changed, 29 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 88796df..c3ed7ed 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -992,13 +992,6 @@ static int atmel_spi_setup(struct spi_device *spi) as = spi_master_get_devdata(spi->master); - if (spi->chip_select > spi->master->num_chipselect) { - dev_dbg(&spi->dev, - "setup: invalid chipselect %u (%u defined)\n", - spi->chip_select, spi->master->num_chipselect); - return -EINVAL; - } - /* see notes above re chipselect */ if (!atmel_spi_is_v2(as) && spi->chip_select == 0 diff --git a/drivers/spi/spi-coldfire-qspi.c b/drivers/spi/spi-coldfire-qspi.c index cabed8f..0ab2c55 100644 --- a/drivers/spi/spi-coldfire-qspi.c +++ b/drivers/spi/spi-coldfire-qspi.c @@ -356,12 +356,6 @@ static int mcfqspi_transfer_one_message(struct spi_master *master, static int mcfqspi_setup(struct spi_device *spi) { - if (spi->chip_select >= spi->master->num_chipselect) { - dev_dbg(&spi->dev, "%d chip select is out of range\n", - spi->chip_select); - return -EINVAL; - } - mcfqspi_cs_deselect(spi_master_get_devdata(spi->master), spi->chip_select, spi->mode & SPI_CS_HIGH); diff --git a/drivers/spi/spi-falcon.c b/drivers/spi/spi-falcon.c index dd5bd46..0ae7f45 100644 --- a/drivers/spi/spi-falcon.c +++ b/drivers/spi/spi-falcon.c @@ -312,9 +312,6 @@ static int falcon_sflash_setup(struct spi_device *spi) unsigned int i; unsigned long flags; - if (spi->chip_select > 0) - return -ENODEV; - spin_lock_irqsave(&ebu_lock, flags); if (spi->max_speed_hz >= CLOCK_100M) { diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c index f573c3c..bd404c2 100644 --- a/drivers/spi/spi-mpc52xx.c +++ b/drivers/spi/spi-mpc52xx.c @@ -364,9 +364,6 @@ static int mpc52xx_spi_setup(struct spi_device *spi) if (spi->mode & ~(SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST)) return -EINVAL; - if (spi->chip_select >= spi->master->num_chipselect) - return -EINVAL; - return 0; } diff --git a/drivers/spi/spi-omap-uwire.c b/drivers/spi/spi-omap-uwire.c index 9313fd3..462ddd4 100644 --- a/drivers/spi/spi-omap-uwire.c +++ b/drivers/spi/spi-omap-uwire.c @@ -332,12 +332,6 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t) uwire = spi_master_get_devdata(spi->master); - if (spi->chip_select > 3) { - pr_debug("%s: cs%d?\n", dev_name(&spi->dev), spi->chip_select); - status = -ENODEV; - goto done; - } - bits = spi->bits_per_word; if (t != NULL && t->bits_per_word) bits = t->bits_per_word; diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c index 2f8aba5..3d10ece 100644 --- a/drivers/spi/spi-tegra114.c +++ b/drivers/spi/spi-tegra114.c @@ -759,8 +759,6 @@ static int tegra_spi_setup(struct spi_device *spi) spi->mode & SPI_CPHA ? "" : "~", spi->max_speed_hz); - BUG_ON(spi->chip_select >= MAX_CHIP_SELECT); - ret = pm_runtime_get_sync(tspi->dev); if (ret < 0) { dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret); diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c index 9a060aa..8e21651 100644 --- a/drivers/spi/spi-tegra20-slink.c +++ b/drivers/spi/spi-tegra20-slink.c @@ -759,8 +759,6 @@ static int tegra_slink_setup(struct spi_device *spi) spi->mode & SPI_CPHA ? "" : "~", spi->max_speed_hz); - BUG_ON(spi->chip_select >= MAX_CHIP_SELECT); - ret = pm_runtime_get_sync(tspi->dev); if (ret < 0) { dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret);