From patchwork Sun Feb 9 16:08:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3613681 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 7DBCABF418 for ; Sun, 9 Feb 2014 16:08:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A58A320181 for ; Sun, 9 Feb 2014 16:08:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 975DC2018A for ; Sun, 9 Feb 2014 16:08:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751516AbaBIQIN (ORCPT ); Sun, 9 Feb 2014 11:08:13 -0500 Received: from mail-pb0-f54.google.com ([209.85.160.54]:36455 "EHLO mail-pb0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751424AbaBIQIM (ORCPT ); Sun, 9 Feb 2014 11:08:12 -0500 Received: by mail-pb0-f54.google.com with SMTP id uo5so5213409pbc.41 for ; Sun, 09 Feb 2014 08:08: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=P9SydbCrmY9/1G49kPozKtFxHiupHuCnzTlPkT2PjYM=; b=V+/p+8BeVT7Wv85pTl2j0g8BLOsT1pQLlgQYPjwIgdTg7vCmhmowZWDFHA/HWwC+5p fuIZrRlr+Eik7JS4Ytosbe89xjlbjvsiS/8AyF9HvPsK8MYLwLiroNiKtXTJ2E2PAMuC BuxUNLWyK9+QvTfATEfOz0AGNo/LxcemcoRsl46p2Kn/4GhIyfhYKX9zAtkveL8qPaAT 3hi1EEB0QYTUPimXNsZjHvTGkHP3FT8lBC8UVbR2MkjnjxzHND0omLyDdUkYoh5/9luY 0BXK/caB1v5RGiYbmHzjSxaUs00TY3TeJB+oTkz90RQaWLpAm1mh1zW15cb6TPIUQEMv YXTA== X-Gm-Message-State: ALoCoQmPfgRhgOwUjeehG+XS38ECACf0AmoTH+gpus4ZirLHi8sSZlaBbbaRUe0RvaTor8HO5pLW X-Received: by 10.68.89.162 with SMTP id bp2mr3656240pbb.151.1391962092004; Sun, 09 Feb 2014 08:08: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 oa3sm33662480pbb.15.2014.02.09.08.08.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 09 Feb 2014 08:08:11 -0800 (PST) Message-ID: <1391962085.10294.1.camel@phoenix> Subject: [PATCH] spi: core: Set max_speed_hz of spi_device default to max_speed_hz of controller From: Axel Lin To: Mark Brown Cc: linux-spi@vger.kernel.org Date: Mon, 10 Feb 2014 00:08:05 +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=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 In __spi_validate(), xfer->speed_hz is set to be spi->max_speed_hz if it is not set for this transfer. However, if spi->max_speed_hz is also not set, xfer->speed_hz is 0. Some drivers (e.g. au1550, tegra114, tegra20-sflash, tegra20-slink, etc.) then use below code to avoid setting xfer->speed_hz to 0. /* Set speed to the spi max fequency if spi device has not set */ spi->max_speed_hz = spi->max_speed_hz ? : tspi->spi_max_frequency; Let's handle it in spi core. If spi->max_speed_hz is not set, make it default to spi->master->max_speed_hz. So In __spi_validate() if both xfer->speed_hz and spi->max_speed_hz are not set, xfer->speed_hz will be set to spi->master->max_speed_hz. Signed-off-by: Axel Lin --- drivers/spi/spi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index d51f2a3..1c9ddf1 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1787,6 +1787,9 @@ int spi_setup(struct spi_device *spi) if (!spi->bits_per_word) spi->bits_per_word = 8; + if (!spi->max_speed_hz) + spi->max_speed_hz = spi->master->max_speed_hz; + if (spi->master->setup) status = spi->master->setup(spi);