From patchwork Sun Feb 9 04:15: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: 3611641 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 A4400BF418 for ; Sun, 9 Feb 2014 04:15:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A904920172 for ; Sun, 9 Feb 2014 04:15:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE2C92018B for ; Sun, 9 Feb 2014 04:15:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751393AbaBIEPO (ORCPT ); Sat, 8 Feb 2014 23:15:14 -0500 Received: from mail-pd0-f179.google.com ([209.85.192.179]:47372 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751294AbaBIEPN (ORCPT ); Sat, 8 Feb 2014 23:15:13 -0500 Received: by mail-pd0-f179.google.com with SMTP id fp1so4367850pdb.38 for ; Sat, 08 Feb 2014 20:15:13 -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=anoutBblyUMlW12eWd4awk4Xw4Omn5Jof/9fAT3iPF8=; b=iJbtjtyqOOOnfk/eA7zWh92L4ELDiUze3Sa91xl5uH6nx4cG/PrKwsuny+NSIOjikP RSEbvx/N+3J64HqO7TUn0elegGNZ9dO9aYIIQqACUIWOIzCJnYLBTFUbCq8T0tYTDigT DfCq1rLEf273AS4KxcVa0lWn7RTnc1usMm4tnxJuzX+igzIXqTohhG0O3BYSn/ImOALH hKujssMA4L8H9b8J55SKeQa8FTNMYqdA5Qld0XS4GXXU8RIkb1tx2ivneRK9+T6XXus8 mvt8KJgunnoJnVQNwR1NMAk9VVSTsabQf2+0y722yRH6rMVFyDhX3vgpBZO3qpOlGgVo e4KQ== X-Gm-Message-State: ALoCoQktHAZY/QKySpcGii6IXE7Iz1wLDISa1yjXebNdvcYF79x9RhHv89l7dtyiu1RkylSjWvyI X-Received: by 10.66.179.143 with SMTP id dg15mr17764150pac.52.1391919312962; Sat, 08 Feb 2014 20:15:12 -0800 (PST) Received: from [192.168.0.102] (218-164-136-128.dynamic.hinet.net. [218.164.136.128]) by mx.google.com with ESMTPSA id vf7sm28718568pbc.5.2014.02.08.20.15.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 08 Feb 2014 20:15:12 -0800 (PST) Message-ID: <1391919307.26425.2.camel@phoenix> Subject: [PATCH RFT] spi: txx9: Convert to let spi core handle checking transfer speed From: Axel Lin To: Mark Brown Cc: Atsushi Nemoto , linux-spi@vger.kernel.org Date: Sun, 09 Feb 2014 12:15: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.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. Then we can remove the same checking in this driver. Signed-off-by: Axel Lin Reviewed-by: Atsushi Nemoto --- drivers/spi/spi-txx9.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-txx9.c b/drivers/spi/spi-txx9.c index 6191ced..523f13d 100644 --- a/drivers/spi/spi-txx9.c +++ b/drivers/spi/spi-txx9.c @@ -80,7 +80,6 @@ struct txx9spi { void __iomem *membase; int baseclk; struct clk *clk; - u32 max_speed_hz, min_speed_hz; int last_chipselect; int last_chipselect_val; }; @@ -117,9 +116,7 @@ static int txx9spi_setup(struct spi_device *spi) { struct txx9spi *c = spi_master_get_devdata(spi->master); - if (!spi->max_speed_hz - || spi->max_speed_hz > c->max_speed_hz - || spi->max_speed_hz < c->min_speed_hz) + if (!spi->max_speed_hz) return -EINVAL; if (gpio_direction_output(spi->chip_select, @@ -309,15 +306,12 @@ static int txx9spi_transfer(struct spi_device *spi, struct spi_message *m) /* check each transfer's parameters */ list_for_each_entry(t, &m->transfers, transfer_list) { - u32 speed_hz = t->speed_hz ? : spi->max_speed_hz; u8 bits_per_word = t->bits_per_word; if (!t->tx_buf && !t->rx_buf && t->len) return -EINVAL; if (t->len & ((bits_per_word >> 3) - 1)) return -EINVAL; - if (speed_hz < c->min_speed_hz || speed_hz > c->max_speed_hz) - return -EINVAL; } spin_lock_irqsave(&c->lock, flags); @@ -360,8 +354,8 @@ static int txx9spi_probe(struct platform_device *dev) goto exit; } c->baseclk = clk_get_rate(c->clk); - c->min_speed_hz = DIV_ROUND_UP(c->baseclk, SPI_MAX_DIVIDER + 1); - c->max_speed_hz = c->baseclk / (SPI_MIN_DIVIDER + 1); + master->min_speed_hz = DIV_ROUND_UP(c->baseclk, SPI_MAX_DIVIDER + 1); + master->max_speed_hz = c->baseclk / (SPI_MIN_DIVIDER + 1); res = platform_get_resource(dev, IORESOURCE_MEM, 0); if (!res)