From patchwork Tue Feb 4 03:05:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3573691 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 5CDB5C02DC for ; Tue, 4 Feb 2014 03:06:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D62120179 for ; Tue, 4 Feb 2014 03:06:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 168002017A for ; Tue, 4 Feb 2014 03:05:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752755AbaBDDF4 (ORCPT ); Mon, 3 Feb 2014 22:05:56 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:52661 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752643AbaBDDF4 (ORCPT ); Mon, 3 Feb 2014 22:05:56 -0500 Received: by mail-pa0-f43.google.com with SMTP id rd3so7871089pab.16 for ; Mon, 03 Feb 2014 19:05:55 -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=M0fFdq7VAuGmvaYKCrXTxaBA6/8lyCsYbbqEAlCs8Yk=; b=gBZLItYKmFxMA++27EIcov8VF9UDP2zBS/lSm1L3/FMJ6QFZOgl1gOrDI0w9/hNVO1 G4uz0xzUvfqWK/JtYxPhmrpHV21NTx8bhpDv2j5eiLhkwVVyGtSqtjkZTSn5w0K8ApAd sDn/dUAV7thPDV1xaUmXmvI99IvOablnGb2CG8//otFUhPJGi4Cj6pfBT1UW7FEkJxeR gX1IYHGYwqEtLv8vYr5mqrB0xvaOJ9i50AXA6Dln5k6IMVxHy8+iV1yAfKSTwULMv/+6 wc1TibvXJmbuFOIdQKsRql++2CiSZPvqqQAQJ/cvHo7oUQnguQPra0/FpzcuP1783UFz gEUg== X-Gm-Message-State: ALoCoQlwQ0W8ujJEOoz4RRsdA2/mh9cCbx2JZkHVeBpdF2+TPI75nmy3CxR9k50v5rdUQycLKfPF X-Received: by 10.68.87.98 with SMTP id w2mr41085311pbz.2.1391483155441; Mon, 03 Feb 2014 19:05:55 -0800 (PST) Received: from [192.168.0.102] (36-239-254-240.dynamic-ip.hinet.net. [36.239.254.240]) by mx.google.com with ESMTPSA id j3sm60958136pbh.38.2014.02.03.19.05.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Feb 2014 19:05:54 -0800 (PST) Message-ID: <1391483150.4695.3.camel@phoenix> Subject: [PATCH RFT] spi: orion: Let spi core handle checking transfer speed From: Axel Lin To: Mark Brown Cc: Shadi Ammouri , linux-spi@vger.kernel.org Date: Tue, 04 Feb 2014 11:05:50 +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 Since commit a2fd4f9fa3b9 'spi: Support transfer speed checking in the core', the SPI core validates the desired speed of a given transfer against the minimum and maximum speeds supported by the controller. So we can remove the same code in this driver and let spi core handle checking the desired speed of a given transfer. Signed-off-by: Axel Lin --- drivers/spi/spi-orion.c | 39 ++------------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index a362425..d432b1c 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c @@ -42,8 +42,6 @@ struct orion_spi { struct spi_master *master; void __iomem *base; - unsigned int max_speed; - unsigned int min_speed; struct clk *clk; }; @@ -320,16 +318,6 @@ static int orion_spi_transfer_one_message(struct spi_master *master, goto msg_done; } - if (t->speed_hz && t->speed_hz < orion_spi->min_speed) { - dev_err(&spi->dev, - "message rejected : " - "device min speed (%d Hz) exceeds " - "required transfer speed (%d Hz)\n", - orion_spi->min_speed, t->speed_hz); - status = -EIO; - goto msg_done; - } - if (par_override || t->speed_hz || t->bits_per_word) { par_override = 1; status = orion_spi_setup_transfer(spi, t); @@ -374,28 +362,6 @@ static int orion_spi_reset(struct orion_spi *orion_spi) return 0; } -static int orion_spi_setup(struct spi_device *spi) -{ - struct orion_spi *orion_spi; - - orion_spi = spi_master_get_devdata(spi->master); - - if ((spi->max_speed_hz == 0) - || (spi->max_speed_hz > orion_spi->max_speed)) - spi->max_speed_hz = orion_spi->max_speed; - - if (spi->max_speed_hz < orion_spi->min_speed) { - dev_err(&spi->dev, "setup: requested speed too low %d Hz\n", - spi->max_speed_hz); - return -EINVAL; - } - - /* - * baudrate & width will be set orion_spi_setup_transfer - */ - return 0; -} - static int orion_spi_probe(struct platform_device *pdev) { struct spi_master *master; @@ -424,7 +390,6 @@ static int orion_spi_probe(struct platform_device *pdev) /* we support only mode 0, and no options */ master->mode_bits = SPI_CPHA | SPI_CPOL; - master->setup = orion_spi_setup; master->transfer_one_message = orion_spi_transfer_one_message; master->num_chipselect = ORION_NUM_CHIPSELECTS; @@ -442,8 +407,8 @@ static int orion_spi_probe(struct platform_device *pdev) clk_prepare(spi->clk); clk_enable(spi->clk); tclk_hz = clk_get_rate(spi->clk); - spi->max_speed = DIV_ROUND_UP(tclk_hz, 4); - spi->min_speed = DIV_ROUND_UP(tclk_hz, 30); + master->max_speed_hz = DIV_ROUND_UP(tclk_hz, 4); + master->min_speed_hz = DIV_ROUND_UP(tclk_hz, 30); r = platform_get_resource(pdev, IORESOURCE_MEM, 0); spi->base = devm_ioremap_resource(&pdev->dev, r);