Received: by 10.223.185.116 with SMTP id b49csp657248wrg; Fri, 23 Feb 2018 04:53:03 -0800 (PST) X-Google-Smtp-Source: AH8x225hMgJzBHV67KpwXTNTTaAFN85F0Jx01SYGrbKaedt/TwrZa7z3uZR8dI4IPXfZteoKZtYK X-Received: by 2002:a17:902:9686:: with SMTP id n6-v6mr1606993plp.333.1519390382875; Fri, 23 Feb 2018 04:53:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519390382; cv=none; d=google.com; s=arc-20160816; b=I0AIvC/47xSESLVzwcgZ+FaN6SKwbdXVtZaBan2THM6Eb9rLGVHuK8ERajIFEDbDMi Ig0dmddnBrSJ8yLfhbnEyOeFQz8IQ/elBbXxNGskkse1TX84O7rLEZTERfYzFla5OQ8e kNuv6WZULnnK3xwxxtn3/cy6dc/LsTR7a9EUADhFoq5JM9YLFooxPcKrD6j60KfaQLk8 GF/4jjzNfdYsNhDJTFzVDKxVaVo4CgJNmOqiFoazQg/E2V+SnTK0Pfv3C6SGTvH49nRp y/OR7Q3tTPRGk0nyk3zi58tmYXBNO9e0KdsAsjTEx1O3/IlIyp4kra6LwfNm7w4qO1xC beqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=Y71BfyycKiTHuQd+dgLodX/KQwhz4SPDbodqsLN7lDg=; b=htqG3FdheqPNtEDiGobLMTW/e9XfaNjTFF7colYRkL0Go6QcDAfdqmh6aHq/AsUbjs Rz7EbmeVrss0mXWHGXNKZmyVmyvZtpizKDc5xbtTOgtX1DJH5IjiYNJUjBZxtuM6tlud zU3wCWdgTXLTX91KTX0/R2FGcH7ryqx2Q6lqYLe5O1li9wimYeDIbajo630UNNBMT4as 7ZSzNrwXCv9McXHtz/sFWJuLy3aeCXfwwlI7ET68IEkiLqFy8rJYMwhk/isyXiwhMx9Y PgHRKyZXC5r7+giDneIvSJR4dt3z4KAgw54ZwAJeGlrBdVHMJQf+y7KqUSgVA9vNM1H1 9OHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si1496404pgn.571.2018.02.23.04.52.47; Fri, 23 Feb 2018 04:53:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751542AbeBWMwG (ORCPT + 99 others); Fri, 23 Feb 2018 07:52:06 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:11127 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751404AbeBWMwC (ORCPT ); Fri, 23 Feb 2018 07:52:02 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w1NCmetj017163; Fri, 23 Feb 2018 13:51:24 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2g9bqd2227-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 23 Feb 2018 13:51:23 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6ABF031; Fri, 23 Feb 2018 12:51:23 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 52F554DB7; Fri, 23 Feb 2018 12:51:23 +0000 (GMT) Received: from localhost (10.75.127.45) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 23 Feb 2018 13:51:22 +0100 From: Fabrice Gasnier To: CC: , , , , , , , , , , Subject: [PATCH 7/7] iio: adc: stm32-dfsdm: add check on spi-max-frequency Date: Fri, 23 Feb 2018 13:51:01 +0100 Message-ID: <1519390261-25453-8-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519390261-25453-1-git-send-email-fabrice.gasnier@st.com> References: <1519390261-25453-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG3NODE3.st.com (10.75.127.9) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-23_04:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org spi-max-frequency is requested for SPI master mode (only), to tune output clock. It may happen requested frequency isn't reachable. Add explicit check, so probe fails with error in this case. Otherwise, output clock may simply be silently turned off (conversions fail). Signed-off-by: Fabrice Gasnier --- drivers/iio/adc/stm32-dfsdm-core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c index e50efdc..1d0d823 100644 --- a/drivers/iio/adc/stm32-dfsdm-core.c +++ b/drivers/iio/adc/stm32-dfsdm-core.c @@ -227,6 +227,11 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev, } priv->spi_clk_out_div = div_u64_rem(clk_freq, spi_freq, &rem) - 1; + if (!priv->spi_clk_out_div) { + /* spi_clk_out_div == 0 means ckout is OFF */ + dev_err(&pdev->dev, "spi-max-frequency not achievable\n"); + return -EINVAL; + } priv->dfsdm.spi_master_freq = spi_freq; if (rem) { -- 1.9.1