Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3464421ybg; Fri, 25 Oct 2019 04:38:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyw3Seksn6HoKrsAVD2oHmegPVVSYeUdRbJne3+vP+foIvAyKgE+JtR1RQW1Id1kBHaEuu7 X-Received: by 2002:a17:906:6146:: with SMTP id p6mr3037447ejl.268.1572003492593; Fri, 25 Oct 2019 04:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572003492; cv=none; d=google.com; s=arc-20160816; b=rKDGMeXCBenLZNOXnb/vXBxw4YBfsvrdIEiS6z3thWOk4kvder3gVG1Qk80PGT/+Hw auwJRRWfb4Cg+93Nh4mfSLFsB7z5DWd7PebNXtJU5+nQd+5bn69BBgztyaSUWjtnXiIl KdYNjjNOR77i+gKm/BctZ8SBBLIFUD0d8EWUPMdy8C9F03V3bKEHsD27ILyj/KUJa2Sn nrg0YHEafL03a8Jv4nm3DidJ2ovfRrVYZw6FswTR0ziiTr7ghpETNHuLYpOv2Tex1BcJ 4ipuK78BKtW4uxb4KT/bjRMMQt1awI8QyG2IghhfwXhLSO59RgfW1oFAJhPgcSxUxjcJ YvEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=NTyg2cKVDskIQP5k+lTXj0XW5CLq2Yn3o933I6C84NA=; b=XowgpPXat9zUFiqwnSO8QKaKmYbfEkoe9TVXai/IfRntQYKRMDOv4/Nw8IelXO+jNx jhtVw/FK42t/amN/zYfwabkCvFgx5ioOYPLQW161D1Fy4llsy1oRb8AcpQcUrj4VVH7f YEDY6Tes1JHzywrY/a1Aj2PaZxGEP60nfEDWIVhLolQ346+li7KtleZUGhaK/L2H0p5n Wiy2LvkVydsM9Q2OtKwLEdKh5oUfWN8R1bgAZ4bGGWuonMuuqyxGkOPlSYRO5hY+opXY l6NBp26DO8S8sFxhT2R9aJQKnysvdB+GYHVgN7b5fUj11lF5IwORBjI9Oa0mjqDPQlin 7oJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=EE6ULXMa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1si951182ejb.116.2019.10.25.04.37.48; Fri, 25 Oct 2019 04:38:12 -0700 (PDT) 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; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=EE6ULXMa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502162AbfJXMwP (ORCPT + 99 others); Thu, 24 Oct 2019 08:52:15 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:8508 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731315AbfJXMwP (ORCPT ); Thu, 24 Oct 2019 08:52:15 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9OCpL3a031995; Thu, 24 Oct 2019 14:52:03 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=STMicroelectronics; bh=NTyg2cKVDskIQP5k+lTXj0XW5CLq2Yn3o933I6C84NA=; b=EE6ULXMaQF8YbBV5UrS6beaGs5rVC1yLwC8wbX7WYWmp9CYme0oO/s+Dmh1pici70vGJ Sc4L5iztdNtA0KpVciDpHynRxkRbseq5UJ6rx6kWFgXbFdiYpTcnqOnpxWsgRCvOpIE3 BMrviEj+qesKjJwzdNOVv+1QjEPhKgf/OiPIjNz6iH0ZM1XAQSJ4zBPC/hTnqXZDrarN hNhluXCrYT0rZnPTEWHCHqxzDpRBwqyLcusmgYL6XPJ2uP1qiniTYJzdbOKzeFeJHuZA PEXHk51YMInySfvsEdk3IMDQMyWss1y5Bdftu9uhisPg6O0EN5x7m78ivuV+dB3BYgiE dg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2vt9s51qwu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Oct 2019 14:52:03 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D001710002A; Thu, 24 Oct 2019 14:52:01 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node2.st.com [10.75.127.8]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 68D382BAB98; Thu, 24 Oct 2019 14:52:01 +0200 (CEST) Received: from localhost (10.75.127.48) by SFHDAG3NODE2.st.com (10.75.127.8) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 24 Oct 2019 14:52:01 +0200 From: Alain Volmat To: , CC: , , , , , , Subject: [PATCH] i2c: i2c-stm32f7: report dma error during probe Date: Thu, 24 Oct 2019 14:52:00 +0200 Message-ID: <1571921521-8502-1-git-send-email-alain.volmat@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG8NODE1.st.com (10.75.127.22) To SFHDAG3NODE2.st.com (10.75.127.8) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-24_08:2019-10-23,2019-10-24 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Distinguish between the case where dma information is not provided within the DT and the case of an error during the dma init. Exit the probe with error in case of an error during dma init. Fixes: bb8822cbbc53 ("i2c: i2c-stm32: Add generic DMA API") Signed-off-by: Alain Volmat --- drivers/i2c/busses/i2c-stm32.c | 16 ++++++++-------- drivers/i2c/busses/i2c-stm32f7.c | 9 +++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-stm32.c b/drivers/i2c/busses/i2c-stm32.c index 07d5dfce68d4..1da347e6a358 100644 --- a/drivers/i2c/busses/i2c-stm32.c +++ b/drivers/i2c/busses/i2c-stm32.c @@ -20,13 +20,13 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL); if (!dma) - return NULL; + return ERR_PTR(-ENOMEM); /* Request and configure I2C TX dma channel */ - dma->chan_tx = dma_request_slave_channel(dev, "tx"); - if (!dma->chan_tx) { + dma->chan_tx = dma_request_chan(dev, "tx"); + if (IS_ERR(dma->chan_tx)) { dev_dbg(dev, "can't request DMA tx channel\n"); - ret = -EINVAL; + ret = PTR_ERR(dma->chan_tx); goto fail_al; } @@ -42,10 +42,10 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, } /* Request and configure I2C RX dma channel */ - dma->chan_rx = dma_request_slave_channel(dev, "rx"); - if (!dma->chan_rx) { + dma->chan_rx = dma_request_chan(dev, "rx"); + if (IS_ERR(dma->chan_rx)) { dev_err(dev, "can't request DMA rx channel\n"); - ret = -EINVAL; + ret = PTR_ERR(dma->chan_rx); goto fail_tx; } @@ -75,7 +75,7 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, devm_kfree(dev, dma); dev_info(dev, "can't use DMA\n"); - return NULL; + return ERR_PTR(ret); } void stm32_i2c_dma_free(struct stm32_i2c_dma *dma) diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c index d36cf08461f7..cc8ba8f49ae6 100644 --- a/drivers/i2c/busses/i2c-stm32f7.c +++ b/drivers/i2c/busses/i2c-stm32f7.c @@ -1950,6 +1950,15 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) i2c_dev->dma = stm32_i2c_dma_request(i2c_dev->dev, phy_addr, STM32F7_I2C_TXDR, STM32F7_I2C_RXDR); + if (PTR_ERR(i2c_dev->dma) == -ENODEV) + i2c_dev->dma = NULL; + else if (IS_ERR(i2c_dev->dma)) { + ret = PTR_ERR(i2c_dev->dma); + if (ret != -EPROBE_DEFER) + dev_err(&pdev->dev, + "Failed to request dma error %i\n", ret); + goto clk_free; + } platform_set_drvdata(pdev, i2c_dev); -- 2.7.4