From patchwork Wed Feb 12 14:09:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3638331 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 265DB9F35F for ; Wed, 12 Feb 2014 14:09:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B95B20165 for ; Wed, 12 Feb 2014 14:09:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6713420160 for ; Wed, 12 Feb 2014 14:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751416AbaBLOJ5 (ORCPT ); Wed, 12 Feb 2014 09:09:57 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:48874 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751167AbaBLOJ4 (ORCPT ); Wed, 12 Feb 2014 09:09:56 -0500 Received: by mail-pa0-f45.google.com with SMTP id lf10so9224509pab.32 for ; Wed, 12 Feb 2014 06:09:56 -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=eYJx0bAZRXjSAyi/IhpUNKeK6YEmsnfnvHn9FJu//0A=; b=cyCQUtENcOt5QCk1zXKIYYf1VlGkAuziwPzpdn7cQjhgdp0M0STYu07X/K3C1GUAH6 /wxQqLY7K6SYompQf+66fAx76CGQIF8Uzm3EUQQ9kFczHyBaPli4ekHSTuf66eisogkn gqb23wdL0qUplD6S2HlR7Uhj0pufRCJGB6RqAV7HWZseiXAtBeZT9202rzKbVXsCaGm8 aDSk2JE5Sy/pb5I4Ftb81ut3L4QM9fpx35Cpyr1eCecUuDdRvK58pWD7vA6FqiOxUzL7 dC/2FDl9mlgg5htx2k2igC8MRMoskpf5FLL3pFINgTz3vIFwz/i5N4cFmz9S2NNpnhCn GJIA== X-Gm-Message-State: ALoCoQkQstqn9Usdzl6+FOEflMIXNZFF0OHSq6EE6PlXp0lLzv1uZE07guwbGT51OGVsckal9D4z X-Received: by 10.66.27.13 with SMTP id p13mr39064804pag.76.1392214196338; Wed, 12 Feb 2014 06:09:56 -0800 (PST) Received: from [10.145.55.56] ([60.245.65.194]) by mx.google.com with ESMTPSA id db3sm64004046pbb.10.2014.02.12.06.09.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Feb 2014 06:09:55 -0800 (PST) Message-ID: <1392214192.11101.4.camel@phoenix> Subject: [PATCH] spi: sh-hspi: Convert to let spi core validate bits_per_word From: Axel Lin To: Mark Brown Cc: Kuninori Morimoto , linux-spi@vger.kernel.org Date: Wed, 12 Feb 2014 22:09:52 +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-sh-hspi.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/spi/spi-sh-hspi.c b/drivers/spi/spi-sh-hspi.c index 82d2f92..dbd2c44 100644 --- a/drivers/spi/spi-sh-hspi.c +++ b/drivers/spi/spi-sh-hspi.c @@ -230,21 +230,6 @@ static int hspi_transfer_one_message(struct spi_master *master, return ret; } -static int hspi_setup(struct spi_device *spi) -{ - struct hspi_priv *hspi = spi_master_get_devdata(spi->master); - struct device *dev = hspi->dev; - - if (8 != spi->bits_per_word) { - dev_err(dev, "bits_per_word should be 8\n"); - return -EIO; - } - - dev_dbg(dev, "%s setup\n", spi->modalias); - - return 0; -} - static void hspi_cleanup(struct spi_device *spi) { struct hspi_priv *hspi = spi_master_get_devdata(spi->master); @@ -300,12 +285,13 @@ static int hspi_probe(struct platform_device *pdev) master->num_chipselect = 1; master->bus_num = pdev->id; - master->setup = hspi_setup; master->cleanup = hspi_cleanup; master->mode_bits = SPI_CPOL | SPI_CPHA; master->dev.of_node = pdev->dev.of_node; master->auto_runtime_pm = true; master->transfer_one_message = hspi_transfer_one_message; + master->bits_per_word_mask = SPI_BPW_MASK(8); + ret = devm_spi_register_master(&pdev->dev, master); if (ret < 0) { dev_err(&pdev->dev, "spi_register_master error.\n");