From patchwork Fri Feb 28 10:39:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3739951 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 7F1039F35F for ; Fri, 28 Feb 2014 10:39:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 99B2D2026F for ; Fri, 28 Feb 2014 10:39:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B75542026D for ; Fri, 28 Feb 2014 10:39:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751408AbaB1Kjl (ORCPT ); Fri, 28 Feb 2014 05:39:41 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:35150 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751083AbaB1Kjk (ORCPT ); Fri, 28 Feb 2014 05:39:40 -0500 Received: by mail-pa0-f48.google.com with SMTP id kx10so589080pab.35 for ; Fri, 28 Feb 2014 02:39:39 -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=zMlJeD9XctM9605sPikhFbj1Gytnr4cmnLygOJDO6I0=; b=fkhM3O+u1bF06HoIAqMI6HNV4PqXyCFm6fsrTI0hlKFypEMN6egkzDLCHivMvIrJQZ 6vv+xGKqBxJnDvuCsgZng9ENjsXBTkAJKUTpw6aC4Cw1YDjyjLHHJsQKldF03n4zhE0T a7XmNc2yCYt4BVJmFSjEz1L8FhAU5AjslM1aUQxm18COR44yfpRaY9qwJsKpniuIBDSb Ex0LiHXTC2gFcflds32zecVgIZ5W6N2/9yPVLFv/PRY156rza6aIuwQg77oEDDuawKpE 8eTSJvCemLrbXMjqN53/KFQYeSm7sZt6we1uHYKV29Ijqe4bgI3iRmZnh8SVAYLoKeGG SlvA== X-Gm-Message-State: ALoCoQmkPc9l/tz2n2qtTK5KO4MtEiDBhZFs6aXF/EBZcKcIrbUO0yhEx/Zj5KqzzkMOhChfqxSO X-Received: by 10.66.149.7 with SMTP id tw7mr2751713pab.72.1393583979745; Fri, 28 Feb 2014 02:39:39 -0800 (PST) Received: from [192.168.0.119] (59-115-9-107.dynamic.hinet.net. [59.115.9.107]) by mx.google.com with ESMTPSA id eb5sm10650087pad.22.2014.02.28.02.39.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Feb 2014 02:39:38 -0800 (PST) Message-ID: <1393583973.18537.2.camel@phoenix> Subject: [PATCH RFT] spi: sc18is602: Convert to let spi core validate transfer speed From: Axel Lin To: Mark Brown Cc: Guenter Roeck , linux-spi@vger.kernel.org Date: Fri, 28 Feb 2014 18:39:33 +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=-6.9 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 master->max_speed_hz and master->min_speed_hz then spi core will handle checking transfer speed. So we can remove the same checking in this driver. This patch also remove testing if hz is 0 because spi->max_speed_hz will be default set to master->min_speed_hz if it was not set. So the transfer speed will never set to 0. Signed-off-by: Axel Lin --- drivers/spi/spi-sc18is602.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-sc18is602.c b/drivers/spi/spi-sc18is602.c index 7fba10b..237f2e7 100644 --- a/drivers/spi/spi-sc18is602.c +++ b/drivers/spi/spi-sc18is602.c @@ -183,17 +183,9 @@ static int sc18is602_setup_transfer(struct sc18is602 *hw, u32 hz, u8 mode) static int sc18is602_check_transfer(struct spi_device *spi, struct spi_transfer *t, int tlen) { - uint32_t hz; - if (t && t->len + tlen > SC18IS602_BUFSIZ) return -EINVAL; - hz = spi->max_speed_hz; - if (t && t->speed_hz) - hz = t->speed_hz; - if (hz == 0) - return -EINVAL; - return 0; } @@ -207,14 +199,13 @@ static int sc18is602_transfer_one(struct spi_master *master, hw->tlen = 0; list_for_each_entry(t, &m->transfers, transfer_list) { - u32 hz = t->speed_hz ? : spi->max_speed_hz; bool do_transfer; status = sc18is602_check_transfer(spi, t, hw->tlen); if (status < 0) break; - status = sc18is602_setup_transfer(hw, hz, spi->mode); + status = sc18is602_setup_transfer(hw, t->speed_hz, spi->mode); if (status < 0) break; @@ -305,6 +296,8 @@ static int sc18is602_probe(struct i2c_client *client, master->setup = sc18is602_setup; master->transfer_one_message = sc18is602_transfer_one; master->dev.of_node = np; + master->min_speed_hz = hw->freq / 128; + master->max_speed_hz = hw->freq / 4; error = devm_spi_register_master(dev, master); if (error)