From patchwork Tue Feb 11 12:49:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3626881 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 846CEBF418 for ; Tue, 11 Feb 2014 12:49:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B2B5F201F4 for ; Tue, 11 Feb 2014 12:49:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C66ED201F2 for ; Tue, 11 Feb 2014 12:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750903AbaBKMtO (ORCPT ); Tue, 11 Feb 2014 07:49:14 -0500 Received: from mail-pd0-f174.google.com ([209.85.192.174]:48285 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750767AbaBKMtN (ORCPT ); Tue, 11 Feb 2014 07:49:13 -0500 Received: by mail-pd0-f174.google.com with SMTP id z10so7435633pdj.19 for ; Tue, 11 Feb 2014 04:49:12 -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=Kf7Le3ApruSQRx0M5ZQj88AOCoqahOE6J+gpHtzyfJ4=; b=hCBrWo03RbGDkSaLPZKkasvhj8Sq2fM10Oh5xBdwJBeJytgZFbnw29LDGce+JzwYPR YVlPirVQFjnguSbjUZgqb8SRWG3fSrSmBC7pLJ+DH/U284VdgLtLNpO5COqaXrhNsS8t xSWqbDIwkq9xUXzaRgyWaWOl7x0aNjtp8XTDL5bRhvf3Hdm11zMtPDWLhMhtwQORC9N8 uTFBncs4J/rzI+XB4dN2k0nbk3q03jO5aHHmatwbNeG2xhox2xKUFwD7+g36KVja4rec XROneCnfX7CBKZJQx7ldt4N4g3VSH2YP8dwjp5vTMYCuZ/4wP4KMbAQE7eQduirgtq1x V+4A== X-Gm-Message-State: ALoCoQlyZXSs7gwy5GGGOvKtBTok9IG3TUepBGPTii71l/9jAquClt3hht7almdu7mwLI+UIDRPk X-Received: by 10.66.227.193 with SMTP id sc1mr2965777pac.102.1392122952190; Tue, 11 Feb 2014 04:49:12 -0800 (PST) Received: from [10.145.55.56] ([60.245.65.194]) by mx.google.com with ESMTPSA id nz11sm4703263pab.6.2014.02.11.04.49.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 04:49:11 -0800 (PST) Message-ID: <1392122947.1351.4.camel@phoenix> Subject: [PATCH RFT] spi: au1550: Convert to let spi core handle checking transfer speed From: Axel Lin To: Mark Brown Cc: Jan Nikitenko , linux-spi@vger.kernel.org Date: Tue, 11 Feb 2014 20:49:07 +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 By setting master->max_speed_hz and master->min_speed_hz, spi core will handle checking transfer speed. So we can remove the same checking in this driver. Signed-off-by: Axel Lin --- drivers/spi/spi-au1550.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/drivers/spi/spi-au1550.c b/drivers/spi/spi-au1550.c index c4141c9..aafb812 100644 --- a/drivers/spi/spi-au1550.c +++ b/drivers/spi/spi-au1550.c @@ -55,8 +55,6 @@ struct au1550_spi { volatile psc_spi_t __iomem *regs; int irq; - unsigned freq_max; - unsigned freq_min; unsigned len; unsigned tx_count; @@ -248,11 +246,8 @@ static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t) hz = t->speed_hz; } - if (hz > spi->max_speed_hz || hz > hw->freq_max || hz < hw->freq_min) { - dev_err(&spi->dev, "setupxfer: clock rate=%d out of range\n", - hz); + if (!hz) return -EINVAL; - } au1550_spi_bits_handlers_set(hw, spi->bits_per_word); @@ -287,23 +282,6 @@ static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t) return 0; } -static int au1550_spi_setup(struct spi_device *spi) -{ - struct au1550_spi *hw = spi_master_get_devdata(spi->master); - - if (spi->max_speed_hz == 0) - spi->max_speed_hz = hw->freq_max; - if (spi->max_speed_hz > hw->freq_max - || spi->max_speed_hz < hw->freq_min) - return -EINVAL; - /* - * NOTE: cannot change speed and other hw settings immediately, - * otherwise sharing of spi bus is not possible, - * so do not call setupxfer(spi, NULL) here - */ - return 0; -} - /* * for dma spi transfers, we have to setup rx channel, otherwise there is * no reliable way how to recognize that spi transfer is done @@ -838,7 +816,6 @@ static int au1550_spi_probe(struct platform_device *pdev) hw->bitbang.master = hw->master; hw->bitbang.setup_transfer = au1550_spi_setupxfer; hw->bitbang.chipselect = au1550_spi_chipsel; - hw->bitbang.master->setup = au1550_spi_setup; hw->bitbang.txrx_bufs = au1550_spi_txrx_bufs; if (hw->usedma) { @@ -909,8 +886,9 @@ static int au1550_spi_probe(struct platform_device *pdev) { int min_div = (2 << 0) * (2 * (4 + 1)); int max_div = (2 << 3) * (2 * (63 + 1)); - hw->freq_max = hw->pdata->mainclk_hz / min_div; - hw->freq_min = hw->pdata->mainclk_hz / (max_div + 1) + 1; + master->max_speed_hz = hw->pdata->mainclk_hz / min_div; + master->min_speed_hz = + hw->pdata->mainclk_hz / (max_div + 1) + 1; } au1550_spi_setup_psc_as_spi(hw);