From patchwork Thu Jan 18 08:15:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Goldschmidt X-Patchwork-Id: 862792 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zMcHB0Hj9z9ryT for ; Thu, 18 Jan 2018 19:16:21 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A823DC21E52; Thu, 18 Jan 2018 08:16:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 78D6DC21E30; Thu, 18 Jan 2018 08:16:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D569DC21E70; Thu, 18 Jan 2018 08:15:55 +0000 (UTC) Received: from mailout.pepperl-fuchs.com (mailout.pepperl-fuchs.com [212.21.166.229]) by lists.denx.de (Postfix) with ESMTPS id DB89FC21E66 for ; Thu, 18 Jan 2018 08:15:50 +0000 (UTC) Received: from PFDE-CAS2.EU.P-F.BIZ (pfde-cas2.eu.p-f.biz [172.24.5.134]) by mailout.pepperl-fuchs.com (Postfix) with ESMTP id A3314819F5; Thu, 18 Jan 2018 09:15:50 +0100 (CET) Received: from localhost.localdomain (172.24.114.233) by PFDE-CAS2.EU.P-F.BIZ (172.24.5.134) with Microsoft SMTP Server (TLS) id 14.3.301.0; Thu, 18 Jan 2018 09:15:50 +0100 From: Simon Goldschmidt To: Simon Glass , Jagan Teki Date: Thu, 18 Jan 2018 09:15:43 +0100 Message-ID: <20180118081543.26412-1-sgoldschmidt@de.pepperl-fuchs.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Originating-IP: [172.24.114.233] X-EXCLAIMER-MD-CONFIG: 1e262833-c6b8-4d86-a546-40bddc43f2e2 Cc: Marek Vasut , u-boot@lists.denx.de Subject: [U-Boot] [PATCH] dm: spi: prevent setting a speed of 0 Hz X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When the device tree is missing a correct spi slave description below the bus, the 'set_speed' callback can be called with 'speed' == 0 Hz. At least with cadence qspi, this leads to a division by zero. Prevent this by initializing speed to 100 kHz in this case, as is done in 'dm_spi_claim_bus'. Signed-off-by: Simon Goldschmidt --- drivers/spi/spi-uclass.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index e06a603ab1..41ecef77db 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -325,6 +325,8 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode, if (!speed) { speed = plat->max_hz; mode = plat->mode; + if (!speed) + speed = 100000; } ret = spi_set_speed_mode(bus, speed, mode); if (ret)