Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3803270ybb; Mon, 23 Mar 2020 08:01:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvwfAK55sqmyzcN9dl+NFmwWYOWhfAMs9VfyQRQozwbuKpX4NRMuBteWU7H5LCF0qVRpxZn X-Received: by 2002:a05:6830:60a:: with SMTP id w10mr19002689oti.292.1584975663956; Mon, 23 Mar 2020 08:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584975663; cv=none; d=google.com; s=arc-20160816; b=ie4zAX8hxQmr9i9dGpLzG7BxikXSakyko4J/durxZQhjee9ijADtMH6njLACOrPJ84 ImZnvhmfJHyyHWI+JcoAFBr6Y7m3Q9z/JTxgc4rVK2iegVNR8BawRF958+sUu7mUHNJN +0pwecgFpi4goL6wxlMl9w3ccj+2Iss/CvEcRZ5VnWFFCaETyDaKmQUXijJM/ILu3hPX oi16+pCzFm9UbeeMcnC7NHA6oSXhW2Aqd+GtUvFux3lhS93wLqi/eLbEcPS85kQm+COy vGeSLMEFLWha0TElD0dcnvKCwIug7rLZu1cAJP34rWBxnDv1D1WMTDhjGODSZNNSrTgf o2nA== 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:dkim-signature; bh=ysOQdhxkH/yrY5LkPt2G2khgQ9eVt+ECxotn643GF5M=; b=y0KI+s38dUoPlo4/XCOEh3UrO5L7AfGUgLHlybCDlrXPB6O363AK9scX+2s8gy6EVh fckG4j1eFU2vpK15OwQxzlXIjxaI2PczhXv89QwEfowhJ+q3p6k/yr4bvz6J76U22NWQ eioNzvXcXA2zc0LwQrhr/by01gD7mo7ABnTuFug5E0+vYirf4bnVEZP81qXODoxe0NQX t8kQbxllgHcL/R6Ex66eDq5CYU790bIMjteCFbZWlyqbytLyGnYDNoJYz2181lJUkO4s tuNffD9y+UOxAwZB82F77WHriQiu2w/engBapxIzpg20y4KE0FYX4rPGD9PaDKLhwaE4 S5Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b="B16F/CHd"; 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 a19si7038252oic.227.2020.03.23.08.00.45; Mon, 23 Mar 2020 08:01:03 -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="B16F/CHd"; 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 S1727233AbgCWPAL (ORCPT + 99 others); Mon, 23 Mar 2020 11:00:11 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:44980 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727102AbgCWPAJ (ORCPT ); Mon, 23 Mar 2020 11:00:09 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02NEbTUQ023758; Mon, 23 Mar 2020 15:59:49 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=ysOQdhxkH/yrY5LkPt2G2khgQ9eVt+ECxotn643GF5M=; b=B16F/CHdNyswVzRywnIeeovif5AJAUv2DjDTpWzfcW0A9UJWf9xa/K5/UR7KnY7tqnZz E2Vll6E3RKJtW0NefQr/M/cESh8cDDkbCis7MFguIMzWgidDmdg5L/Lz2RyoQ0s+jD7W nMuUKvGWYqrofzNFZ3iMdGIGMhr1exYCKIq5HJoCFBiQDcjn+Y4rma2csUZs3BcdT8zy YaVKTCxfXWhqNYc1AUvbLvKtbez4JtzibhICwe+u1GLUj2no2xLbmKlRNxc0x9qfAcgI vxhmiMd+T34iT/jpXCYcRdzmSExc4JHYpHoKlUEqCmczR9CZHmqyrzwdJ3OeJzfU7gLf JQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2yw995ajd0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Mar 2020 15:59:49 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9B96410003A; Mon, 23 Mar 2020 15:59:44 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag6node2.st.com [10.75.127.17]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 8C5FD21E69C; Mon, 23 Mar 2020 15:59:44 +0100 (CET) Received: from localhost (10.75.127.46) by SFHDAG6NODE2.st.com (10.75.127.17) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 23 Mar 2020 15:59:43 +0100 From: Christophe Kerello To: , , , , , , CC: , , , , Christophe Kerello Subject: [04/12] mtd: rawnand: stm32_fmc2: manage all errors cases at probe time Date: Mon, 23 Mar 2020 15:58:44 +0100 Message-ID: <1584975532-8038-5-git-send-email-christophe.kerello@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1584975532-8038-1-git-send-email-christophe.kerello@st.com> References: <1584975532-8038-1-git-send-email-christophe.kerello@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) To SFHDAG6NODE2.st.com (10.75.127.17) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-23_05:2020-03-21,2020-03-23 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch defers its probe when the expected reset control is not yet ready. This patch also handles properly all errors cases at probe time. Signed-off-by: Christophe Kerello --- drivers/mtd/nand/raw/stm32_fmc2_nand.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c index b6d45cd..0a96797 100644 --- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c +++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c @@ -1967,7 +1967,11 @@ static int stm32_fmc2_probe(struct platform_device *pdev) } rstc = devm_reset_control_get(dev, NULL); - if (!IS_ERR(rstc)) { + if (IS_ERR(rstc)) { + ret = PTR_ERR(rstc); + if (ret == -EPROBE_DEFER) + goto err_clk_disable; + } else { reset_control_assert(rstc); reset_control_deassert(rstc); } @@ -1975,7 +1979,7 @@ static int stm32_fmc2_probe(struct platform_device *pdev) /* DMA setup */ ret = stm32_fmc2_dma_setup(fmc2); if (ret) - return ret; + goto err_dma_setup; /* FMC2 init routine */ stm32_fmc2_init(fmc2); @@ -1997,7 +2001,7 @@ static int stm32_fmc2_probe(struct platform_device *pdev) /* Scan to find existence of the device */ ret = nand_scan(chip, nand->ncs); if (ret) - goto err_scan; + goto err_dma_setup; ret = mtd_device_register(mtd, NULL, 0); if (ret) @@ -2010,7 +2014,7 @@ static int stm32_fmc2_probe(struct platform_device *pdev) err_device_register: nand_cleanup(chip); -err_scan: +err_dma_setup: if (fmc2->dma_ecc_ch) dma_release_channel(fmc2->dma_ecc_ch); if (fmc2->dma_tx_ch) @@ -2021,6 +2025,7 @@ static int stm32_fmc2_probe(struct platform_device *pdev) sg_free_table(&fmc2->dma_data_sg); sg_free_table(&fmc2->dma_ecc_sg); +err_clk_disable: clk_disable_unprepare(fmc2->clk); return ret; -- 1.9.1