From patchwork Fri Feb 14 13:06:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3652601 X-Patchwork-Delegate: broonie@sirena.org.uk 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 761DDBF13A for ; Fri, 14 Feb 2014 13:06:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8ECA120222 for ; Fri, 14 Feb 2014 13:06:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B408B2021E for ; Fri, 14 Feb 2014 13:06:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752201AbaBNNGu (ORCPT ); Fri, 14 Feb 2014 08:06:50 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:47782 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751288AbaBNNGt (ORCPT ); Fri, 14 Feb 2014 08:06:49 -0500 Received: by mail-pd0-f169.google.com with SMTP id v10so11902456pde.14 for ; Fri, 14 Feb 2014 05:06:49 -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=HWpNOzMFWIdhPCNR8R7teJ+QWT7+RGNS3ORKAG6VVQ8=; b=KNDiRFq8LEd1M8dZkv/SfCE8f+vuO7p67k7Xt2CiontfYiJ2VI3JSO4UYXvWs4rtyo hyWfAAaYWTK3yYLPmnsCCls9XCenset0a639JeMXp7Hb16BtaUQhzLS1g8l8nM35C7Dh S63cZ6P3/md2ISrM01S4H3ksjDRSaiM5F68AYIT7Gq0QFz9BPc+TW0dNQXwGUvT1m8yD Y+T3XjmWgTgGxb5ax6bq3yNJN0goga//vZv3dhdkwsZ1v1DP/1P4+nOIsVqgiLFd3yzw Tybo2LlxyfjGVqZhEycWlBwxJZBYVN9h0Y9+EdXOYcJ3bXpm1WGN10+Q1at1FXaL/Zft FDvw== X-Gm-Message-State: ALoCoQncfgq+4TeLnZPhyWQvFShBHkUL+B/3I9jGL4PGd8dk4wGy+rvYPgPkmSXMefhGR7KaQHOz X-Received: by 10.68.203.135 with SMTP id kq7mr8850244pbc.85.1392383209126; Fri, 14 Feb 2014 05:06:49 -0800 (PST) Received: from [192.168.0.102] (218-164-130-78.dynamic.hinet.net. [218.164.130.78]) by mx.google.com with ESMTPSA id rb6sm17050327pbb.41.2014.02.14.05.06.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Feb 2014 05:06:48 -0800 (PST) Message-ID: <1392383203.31961.3.camel@phoenix> Subject: [PATCH] spi: xilinx: Convert to let spi core validate bits_per_word From: Axel Lin To: Mark Brown Cc: Michal Simek , linux-spi@vger.kernel.org Date: Fri, 14 Feb 2014 21:06:43 +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=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 Set bits_per_word_mask so spi core will reject transfers that attempt to use an unsupported bits_per_word value. spi_bitbang requires custom setup_transfer() to be defined if there is a custom txrx_bufs(). Thus keep the empty xilinx_spi_setup_transfer() function in the code. Signed-off-by: Axel Lin Acked-by: Michal Simek --- drivers/spi/spi-xilinx.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index e6cd111..66dbefc 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c @@ -208,26 +208,11 @@ static void xilinx_spi_chipselect(struct spi_device *spi, int is_on) } /* spi_bitbang requires custom setup_transfer() to be defined if there is a - * custom txrx_bufs(). We have nothing to setup here as the SPI IP block - * supports 8 or 16 bits per word which cannot be changed in software. - * SPI clock can't be changed in software either. - * Check for correct bits per word. Chip select delay calculations could be - * added here as soon as bitbang_work() can be made aware of the delay value. + * custom txrx_bufs(). */ static int xilinx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) { - struct xilinx_spi *xspi = spi_master_get_devdata(spi->master); - u8 bits_per_word; - - bits_per_word = (t && t->bits_per_word) - ? t->bits_per_word : spi->bits_per_word; - if (bits_per_word != xspi->bits_per_word) { - dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n", - __func__, bits_per_word); - return -EINVAL; - } - return 0; } @@ -406,6 +391,7 @@ static int xilinx_spi_probe(struct platform_device *pdev) xspi->write_fn = xspi_write32_be; } + master->bits_per_word_mask = SPI_BPW_MASK(bits_per_word); xspi->bits_per_word = bits_per_word; if (xspi->bits_per_word == 8) { xspi->tx_fn = xspi_tx8;