From patchwork Sat Feb 8 15:52:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3610431 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 C68BFBF418 for ; Sat, 8 Feb 2014 15:52:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C08DE2011D for ; Sat, 8 Feb 2014 15:52:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB15120163 for ; Sat, 8 Feb 2014 15:52:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751514AbaBHPwc (ORCPT ); Sat, 8 Feb 2014 10:52:32 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:55509 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751462AbaBHPwb (ORCPT ); Sat, 8 Feb 2014 10:52:31 -0500 Received: by mail-pa0-f51.google.com with SMTP id ld10so4442168pab.38 for ; Sat, 08 Feb 2014 07:52:31 -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=/dLVFgJ69z83Wv/JDKk2vY/B2gvdbZ1lndYVUnmW9kA=; b=Te4MhHl5rPt5/siyhmSi4RaBjw/2hBh+I+/P68CKPeZJU0yoCLNjLBd1uMYXxSUD0n wvXJOt0KtMK5Y7qOUtnU4p5zSJXkS6IpF2cSH9zaOLvyOlcExeZRVT8x+ag0UMURdeGZ IH7ixYL1OAYTs9dIURSWcXLkgYQULiFMSkzglMI70QE9k7PQkRoelCa4ucwRUILlC6jR xZVnern6JKiW22Z/nufcvd1a2NowhRaSUB3yIPrkwTxkhPHiEQ3vGKQj3q91+FYI5WO2 xzFmhjfgSIeVVPpWdZgUaMeGErNTWZdOU1xaBrOT3VLONtvityMH5rmEe8V4GkWFRzuF cKCQ== X-Gm-Message-State: ALoCoQlkRa0An2dkAv401UoYpoczuBxu+j/Pnf4JJcnExPbSo9+rqtZrCnY/JPf35xDv639fNfjU X-Received: by 10.68.143.34 with SMTP id sb2mr26614751pbb.135.1391874751241; Sat, 08 Feb 2014 07:52:31 -0800 (PST) Received: from [192.168.0.102] (218-164-154-231.dynamic.hinet.net. [218.164.154.231]) by mx.google.com with ESMTPSA id n6sm24738975pbj.22.2014.02.08.07.52.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 08 Feb 2014 07:52:30 -0800 (PST) Message-ID: <1391874746.24507.1.camel@phoenix> Subject: [PATCH RFT] spi: ep93xx: Convert to let spi core handle checking transfer speed From: Axel Lin To: Mark Brown Cc: Mika Westerberg , linux-spi@vger.kernel.org Date: Sat, 08 Feb 2014 23:52:26 +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.4 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 Acked-by: Mika Westerberg --- drivers/spi/spi-ep93xx.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c index 1bfaed6..2f675d3 100644 --- a/drivers/spi/spi-ep93xx.c +++ b/drivers/spi/spi-ep93xx.c @@ -73,8 +73,6 @@ * @clk: clock for the controller * @regs_base: pointer to ioremap()'d registers * @sspdr_phys: physical address of the SSPDR register - * @min_rate: minimum clock rate (in Hz) supported by the controller - * @max_rate: maximum clock rate (in Hz) supported by the controller * @wait: wait here until given transfer is completed * @current_msg: message that is currently processed (or %NULL if none) * @tx: current byte in transfer to transmit @@ -95,8 +93,6 @@ struct ep93xx_spi { struct clk *clk; void __iomem *regs_base; unsigned long sspdr_phys; - unsigned long min_rate; - unsigned long max_rate; struct completion wait; struct spi_message *current_msg; size_t tx; @@ -199,9 +195,9 @@ static void ep93xx_spi_disable_interrupts(const struct ep93xx_spi *espi) * @div_scr: pointer to return the scr divider */ static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi, - unsigned long rate, - u8 *div_cpsr, u8 *div_scr) + u32 rate, u8 *div_cpsr, u8 *div_scr) { + struct spi_master *master = platform_get_drvdata(espi->pdev); unsigned long spi_clk_rate = clk_get_rate(espi->clk); int cpsr, scr; @@ -210,7 +206,7 @@ static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi, * controller. Note that minimum value is already checked in * ep93xx_spi_transfer_one_message(). */ - rate = clamp(rate, espi->min_rate, espi->max_rate); + rate = clamp(rate, master->min_speed_hz, master->max_speed_hz); /* * Calculate divisors so that we can get speed according the @@ -735,13 +731,6 @@ static int ep93xx_spi_transfer_one_message(struct spi_master *master, struct spi_message *msg) { struct ep93xx_spi *espi = spi_master_get_devdata(master); - struct spi_transfer *t; - - /* first validate each transfer */ - list_for_each_entry(t, &msg->transfers, transfer_list) { - if (t->speed_hz < espi->min_rate) - return -EINVAL; - } msg->state = NULL; msg->status = 0; @@ -917,8 +906,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev) * Calculate maximum and minimum supported clock rates * for the controller. */ - espi->max_rate = clk_get_rate(espi->clk) / 2; - espi->min_rate = clk_get_rate(espi->clk) / (254 * 256); + master->max_speed_hz = clk_get_rate(espi->clk) / 2; + master->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256); espi->pdev = pdev; espi->sspdr_phys = res->start + SSPDR;