From patchwork Thu Dec 12 13:55:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 181491 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp802680och; Thu, 12 Dec 2019 05:56:30 -0800 (PST) X-Google-Smtp-Source: APXvYqy4Baj3dgrS+Vl2A9/7yAK8+egBV0WM97+nl/sj+2ahqNbyzWOCbItC1pKArzHkuNLGnYSH X-Received: by 2002:a9d:7f11:: with SMTP id j17mr8543771otq.281.1576158990490; Thu, 12 Dec 2019 05:56:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576158990; cv=none; d=google.com; s=arc-20160816; b=KDgxqyeUcKhbWGH9Zbai0qgMguVk6sDiA0S5BRj0OmnkA1JOLBsrSTOTbyWPRez/QU ixmocdVj0KBWNh7W4WSxaGS4RpHy0Z56aNVb0OG5QYl94dPOqos755zwgvg/ldac/Zld FXrjzTTeePe2MO0sVXwZCwe5LotYMJrf+K1LCxJn8ed5ud+etV9XUoTHAZ99eifS763Q KF4g/xXro7Vm4ut9t48LjqhtxlaFyamGESNpgYA6jpLmJfKCC3wSzIt8lLtz8MfSqaM5 mJXKIrJ4fQrPcGERJKnCaCo54w5PQEevRxIZImpULGF8bbl4SIzMNXBij4JV6mJrZDnB AN8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GufpDqc/JsjNnk5yJpyjIjNCslz2RxoV+SAcmiZ8xk8=; b=VaWYW9Hd+leCkmZgTNiGQ6KpUepDiZnXOiLJQJWHi/NVcV8J3SsanZ9GMxzWpaRRoK 42hFWlkPjMnj++lHUOKS3hwunhtg0UP0XQAUi17FNgfvfL2bFquxunzTvL01vsukICfE DLJI5oDLbhpSe/lUZr6LKetf7MSfYEWj3Q9JiGcz0yUTwEBiFilZt8l+HsJSIDF8uoCl 5/BgHuHHVeLFAqHlZwuv/hv3KUgEnWTvRGmtQ8eI3Ho+6XlXWnapBr6bhkk8akRfmuDN nDpiutGHJkMq2MhZ6zQuhVtSS27q4ajpYi7LHO7eClUlU3GjNHcnVM1bnudsy+X6XQs5 oyyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Nz6TLqNe; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u4si3136096oig.200.2019.12.12.05.56.30; Thu, 12 Dec 2019 05:56:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-spi-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=@ti.com header.s=ti-com-17Q1 header.b=Nz6TLqNe; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729619AbfLLN42 (ORCPT + 2 others); Thu, 12 Dec 2019 08:56:28 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:36308 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729642AbfLLN41 (ORCPT ); Thu, 12 Dec 2019 08:56:27 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id xBCDuGqo009067; Thu, 12 Dec 2019 07:56:16 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1576158976; bh=GufpDqc/JsjNnk5yJpyjIjNCslz2RxoV+SAcmiZ8xk8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Nz6TLqNez/VlFzVcmNAVmLTW+ivYsv/Hnj3n02im4EkIY3qdHIbhPWbNfp77t4onc nvjel4ZQAzU15S50IvRb0YyiWzLLU12uNlbRzATwx3XJR7NYh16KY/DMfS63M05i82 TeM1akRUu76tlP4PvOR/ARz4t4F3VF8Znw5rA+Ys= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xBCDuFKS019946 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 12 Dec 2019 07:56:16 -0600 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Thu, 12 Dec 2019 07:56:15 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Thu, 12 Dec 2019 07:56:15 -0600 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBCDtdqY048444; Thu, 12 Dec 2019 07:56:11 -0600 From: Peter Ujfalusi To: , , , , , , , , , CC: , , , , , Subject: [PATCH 8/9] spi: stm32-qspi: Use dma_request_chan() instead dma_request_slave_channel() Date: Thu, 12 Dec 2019 15:55:49 +0200 Message-ID: <20191212135550.4634-9-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191212135550.4634-1-peter.ujfalusi@ti.com> References: <20191212135550.4634-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org dma_request_slave_channel() is a wrapper on top of dma_request_chan() eating up the error code. By using dma_request_chan() directly the driver can support deferred probing against DMA. Signed-off-by: Peter Ujfalusi --- drivers/spi/spi-stm32-qspi.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c index 4e726929bb4f..4ef569b47aa6 100644 --- a/drivers/spi/spi-stm32-qspi.c +++ b/drivers/spi/spi-stm32-qspi.c @@ -470,10 +470,11 @@ static int stm32_qspi_setup(struct spi_device *spi) return 0; } -static void stm32_qspi_dma_setup(struct stm32_qspi *qspi) +static int stm32_qspi_dma_setup(struct stm32_qspi *qspi) { struct dma_slave_config dma_cfg; struct device *dev = qspi->dev; + int ret = 0; memset(&dma_cfg, 0, sizeof(dma_cfg)); @@ -484,8 +485,13 @@ static void stm32_qspi_dma_setup(struct stm32_qspi *qspi) dma_cfg.src_maxburst = 4; dma_cfg.dst_maxburst = 4; - qspi->dma_chrx = dma_request_slave_channel(dev, "rx"); - if (qspi->dma_chrx) { + qspi->dma_chrx = dma_request_chan(dev, "rx"); + if (IS_ERR(qspi->dma_chrx)) { + ret = PTR_ERR(qspi->dma_chrx); + qspi->dma_chrx = NULL; + if (ret == -EPROBE_DEFER) + goto out; + } else { if (dmaengine_slave_config(qspi->dma_chrx, &dma_cfg)) { dev_err(dev, "dma rx config failed\n"); dma_release_channel(qspi->dma_chrx); @@ -493,8 +499,11 @@ static void stm32_qspi_dma_setup(struct stm32_qspi *qspi) } } - qspi->dma_chtx = dma_request_slave_channel(dev, "tx"); - if (qspi->dma_chtx) { + qspi->dma_chtx = dma_request_chan(dev, "tx"); + if (IS_ERR(qspi->dma_chtx)) { + ret = PTR_ERR(qspi->dma_chtx); + qspi->dma_chtx = NULL; + } else { if (dmaengine_slave_config(qspi->dma_chtx, &dma_cfg)) { dev_err(dev, "dma tx config failed\n"); dma_release_channel(qspi->dma_chtx); @@ -502,7 +511,13 @@ static void stm32_qspi_dma_setup(struct stm32_qspi *qspi) } } +out: init_completion(&qspi->dma_completion); + + if (ret != -EPROBE_DEFER) + ret = 0; + + return ret; } static void stm32_qspi_dma_free(struct stm32_qspi *qspi) @@ -608,7 +623,10 @@ static int stm32_qspi_probe(struct platform_device *pdev) qspi->dev = dev; platform_set_drvdata(pdev, qspi); - stm32_qspi_dma_setup(qspi); + ret = stm32_qspi_dma_setup(qspi); + if (ret) + goto err; + mutex_init(&qspi->lock); ctrl->mode_bits = SPI_RX_DUAL | SPI_RX_QUAD