From patchwork Sat Feb 15 06:26:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3655741 X-Patchwork-Delegate: broonie@sirena.org.uk 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7C52E9F382 for ; Sat, 15 Feb 2014 06:26:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 74EA2201DE for ; Sat, 15 Feb 2014 06:26:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 92F6D201CE for ; Sat, 15 Feb 2014 06:26:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751069AbaBOG02 (ORCPT ); Sat, 15 Feb 2014 01:26:28 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:54075 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750995AbaBOG02 (ORCPT ); Sat, 15 Feb 2014 01:26:28 -0500 Received: by mail-pa0-f46.google.com with SMTP id rd3so13265255pab.33 for ; Fri, 14 Feb 2014 22:26:27 -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=NdojCwkKEah0ZRNenrs6BAlsX8T62zQsQn2cLrpw0nI=; b=agMqfr82BkqH5mJoJib+vo6+hd4+pCSZYcPF87yiLj7F0Re5pJABNVSiU0yLQWd20m i1D2QmO8YZ1NxJhwcMRmZZgC7mi/FalV/lO2k3fEfqOf3mgoVflM2GMfh2BrB9osfCTO gXuzfGXYi6Exp1qybo0mh3eiEhDCasWZ78SpCLy0ip03C7c7MprL78a72JRtvX1pMFhq EflcygO6HWKnuThi/mddqqn6eE/06WzED151QYhti/lyE8hEuVu4j9LDo9DCiCwmMmPA VlrkSrJBeP/WvCa6OXYMKWq05Tq9m1Kwdf7Fj1jOwHMB73Zh9J6D+AmFbgyzHiuOgoHA ZVFA== X-Gm-Message-State: ALoCoQkBu9v8C9e/MBo7m5OFkjDwuMWZWEpOIhP+laKOOW9C9cal0MMSVWe6YVHPR+inbLF+h1yB X-Received: by 10.67.23.135 with SMTP id ia7mr13503087pad.5.1392445587426; Fri, 14 Feb 2014 22:26:27 -0800 (PST) Received: from [192.168.0.102] (218-164-139-15.dynamic.hinet.net. [218.164.139.15]) by mx.google.com with ESMTPSA id jk16sm23767340pbb.34.2014.02.14.22.26.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Feb 2014 22:26:26 -0800 (PST) Message-ID: <1392445581.32256.1.camel@phoenix> Subject: [PATCH] spi: omap-uwire: Convert to use bits_per_word_mask From: Axel Lin To: Mark Brown Cc: Imre Deak , Tony Lindgren , linux-spi@vger.kernel.org Date: Sat, 15 Feb 2014 14:26:21 +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 Set bits_per_word_mask so spi core will reject transfers that attempt to use an unsupported bits_per_word value. Signed-off-by: Axel Lin --- drivers/spi/spi-omap-uwire.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/spi/spi-omap-uwire.c b/drivers/spi/spi-omap-uwire.c index 462ddd4..95cc694 100644 --- a/drivers/spi/spi-omap-uwire.c +++ b/drivers/spi/spi-omap-uwire.c @@ -99,7 +99,6 @@ struct uwire_spi { }; struct uwire_state { - unsigned bits_per_word; unsigned div1_idx; }; @@ -210,9 +209,8 @@ static void uwire_chipselect(struct spi_device *spi, int value) static int uwire_txrx(struct spi_device *spi, struct spi_transfer *t) { - struct uwire_state *ust = spi->controller_state; unsigned len = t->len; - unsigned bits = ust->bits_per_word; + unsigned bits = t->bits_per_word ? : spi->bits_per_word; unsigned bytes; u16 val, w; int status = 0; @@ -322,7 +320,6 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t) struct uwire_state *ust = spi->controller_state; struct uwire_spi *uwire; unsigned flags = 0; - unsigned bits; unsigned hz; unsigned long rate; int div1_idx; @@ -332,17 +329,6 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t) uwire = spi_master_get_devdata(spi->master); - bits = spi->bits_per_word; - if (t != NULL && t->bits_per_word) - bits = t->bits_per_word; - - if (bits > 16) { - pr_debug("%s: wordsize %d?\n", dev_name(&spi->dev), bits); - status = -ENODEV; - goto done; - } - ust->bits_per_word = bits; - /* mode 0..3, clock inverted separately; * standard nCS signaling; * don't treat DI=high as "not ready" @@ -509,7 +495,7 @@ static int uwire_probe(struct platform_device *pdev) /* the spi->mode bits understood by this driver: */ master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; - + master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 16); master->flags = SPI_MASTER_HALF_DUPLEX; master->bus_num = 2; /* "official" */