From patchwork Wed Feb 12 14:07:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3638321 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 02EF8BF13A for ; Wed, 12 Feb 2014 14:07:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 282E120165 for ; Wed, 12 Feb 2014 14:07:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE93F2015D for ; Wed, 12 Feb 2014 14:07:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751883AbaBLOHs (ORCPT ); Wed, 12 Feb 2014 09:07:48 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:39703 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751065AbaBLOHs (ORCPT ); Wed, 12 Feb 2014 09:07:48 -0500 Received: by mail-pa0-f43.google.com with SMTP id rd3so9230197pab.30 for ; Wed, 12 Feb 2014 06:07:47 -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=JmTYz3sQ4me95lTX5cQnW7hbrNf8tgM/d/pKbcO8Its=; b=HPFdZ7DhW8BRBE82w95kWiUlBqWWrK4YvCGeKQWTb9EJ92JKdIhn5x4y23q05hQGy1 tGSGFfPfAM919AJaTv+a/sFfFPC8vKuWrHAR36TUAE3CWt5UANdkdZ4J1UDnBLHBR+O+ cb/ybDBiNjeezOkXMPgl7uV7MgFyFi7N29vFezil94hDtJkJIrKPz46Uky/oRq0TDyro tSrkfn+74HjJNZFM1sXkp/v0+9Y5UFfhJxqdIZxg+WkE5bFKj8jE5ACml7igt0LeKB6L 34mdsxj32xHGBPQd0IrPGV/SRdk4G+kkdo9PGI9TLuAQS9urqoX3G4j1etx1ePAcQdV/ GPfA== X-Gm-Message-State: ALoCoQmxOEaX3atZTZA+1CifevqOMHiY80/f72lRdXlKPFTsmcfExevnKdxnsDD+PGLA5Y3adQU5 X-Received: by 10.66.25.241 with SMTP id f17mr981468pag.127.1392214067271; Wed, 12 Feb 2014 06:07:47 -0800 (PST) Received: from [10.145.55.56] ([60.245.65.194]) by mx.google.com with ESMTPSA id vn10sm63978921pbc.21.2014.02.12.06.07.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Feb 2014 06:07:46 -0800 (PST) Message-ID: <1392214052.11101.2.camel@phoenix> Subject: [PATCH] spi: fsl-spi: Convert to let spi core validate xfer->bits_per_word From: Axel Lin To: Mark Brown Cc: Stefan Roese , Andreas Larsson , linux-spi@vger.kernel.org Date: Wed, 12 Feb 2014 22:07:32 +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.6 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. Signed-off-by: Axel Lin --- drivers/spi/spi-fsl-spi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index 4dcb292..28064ad 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -239,12 +239,6 @@ static int fsl_spi_setup_transfer(struct spi_device *spi, if (!bits_per_word) bits_per_word = spi->bits_per_word; - /* Make sure its a bit width we support [4..16, 32] */ - if ((bits_per_word < 4) - || ((bits_per_word > 16) && (bits_per_word != 32)) - || (bits_per_word > mpc8xxx_spi->max_bits_per_word)) - return -EINVAL; - if (!hz) hz = spi->max_speed_hz; @@ -631,6 +625,8 @@ static struct spi_master * fsl_spi_probe(struct device *dev, master->setup = fsl_spi_setup; master->cleanup = fsl_spi_cleanup; + master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16) | + SPI_BPW_MASK(32); mpc8xxx_spi = spi_master_get_devdata(master); mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg;