From patchwork Sun Oct 4 12:23:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Chou X-Patchwork-Id: 526107 X-Patchwork-Delegate: thomas@wytron.com.tw Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 111231402B6 for ; Sun, 4 Oct 2015 23:24:09 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 37CCD4B833; Sun, 4 Oct 2015 14:24:07 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rTSJW-vwZIBg; Sun, 4 Oct 2015 14:24:06 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5E7A84B826; Sun, 4 Oct 2015 14:24:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8B93A4B826 for ; Sun, 4 Oct 2015 14:24:02 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IrQWts7tfbbc for ; Sun, 4 Oct 2015 14:24:02 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from www.wytron.com.tw (220-134-43-68.HINET-IP.hinet.net [220.134.43.68]) by theia.denx.de (Postfix) with ESMTP id 185464B813 for ; Sun, 4 Oct 2015 14:23:57 +0200 (CEST) Received: from localhost.localdomain (unknown [192.168.1.250]) by www.wytron.com.tw (Postfix) with ESMTP id 9EADAD00300; Sun, 4 Oct 2015 20:23:55 +0800 (CST) From: Thomas Chou To: u-boot@lists.denx.de Date: Sun, 4 Oct 2015 20:23:08 +0800 Message-Id: <1443961388-15585-1-git-send-email-thomas@wytron.com.tw> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1442907681-14489-1-git-send-email-thomas@wytron.com.tw> References: <1442907681-14489-1-git-send-email-thomas@wytron.com.tw> Cc: Marek Vasut , clsee@altera.com, Jagan Teki , lftan@altera.com Subject: [U-Boot] [PATCH v2] spi: ignore set speed and mode if not available X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Some cores, such as Altera SPI and QuadSPI, can not change speed and mode at runtime. Ignore the operation which is not available. Signed-off-by: Thomas Chou Acked-by: Marek Vasut Reviewed-by: Jagan Teki Reviewed-by: Simon Glass --- v2 add comments as Simon sugggested. drivers/spi/spi-uclass.c | 7 ++----- include/spi.h | 5 +++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index d666272..50e3553 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -21,13 +21,12 @@ DECLARE_GLOBAL_DATA_PTR; static int spi_set_speed_mode(struct udevice *bus, int speed, int mode) { struct dm_spi_ops *ops; - int ret; + int ret = 0; ops = spi_get_ops(bus); + /* missing get_speed() and set_mode() methods are OK */ if (ops->set_speed) ret = ops->set_speed(bus, speed); - else - ret = -EINVAL; if (ret) { printf("Cannot set speed (err=%d)\n", ret); return ret; @@ -35,8 +34,6 @@ static int spi_set_speed_mode(struct udevice *bus, int speed, int mode) if (ops->set_mode) ret = ops->set_mode(bus, mode); - else - ret = -EINVAL; if (ret) { printf("Cannot set mode (err=%d)\n", ret); return ret; diff --git a/include/spi.h b/include/spi.h index 51fdfd6..a418509 100644 --- a/include/spi.h +++ b/include/spi.h @@ -451,6 +451,9 @@ struct dm_spi_ops { /** * Set transfer speed. * This sets a new speed to be applied for next spi_xfer(). + * + * It is optional in the case where the hardware does not support it. + * * @bus: The SPI bus * @hz: The transfer speed * @return 0 if OK, -ve on error @@ -463,6 +466,8 @@ struct dm_spi_ops { * It is unclear if we want to set speed and mode together instead * of separately. * + * It is optional in the case where the hardware does not support it. + * * @bus: The SPI bus * @mode: Requested SPI mode (SPI_... flags) * @return 0 if OK, -ve on error