Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1631032ybj; Wed, 6 May 2020 02:14:02 -0700 (PDT) X-Google-Smtp-Source: APiQypJk5ASd2QI6q+3KatkJoX18j1fEWmHBRQO/+smfaCcEPwu/+tEGVEpMN/+yWBgH0/o/YXBn X-Received: by 2002:a17:906:1f16:: with SMTP id w22mr6598431ejj.327.1588756442327; Wed, 06 May 2020 02:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588756442; cv=none; d=google.com; s=arc-20160816; b=Re1mO+2VZc7eIRoHogwHT0AJjk9fQtiiQZfg0DzO6j8dPl2xrRgTVonqWoiWGrHQqP Ezl0b52zIjKpB0KScpQVc3JSqnbFsAbuX8l49Mqbg8tqzq0lLCOySX2Ye0g5p2+AtuZi ljGkxhZwzpEQxwGU686lIQsRPxvQU1ffVwU1ONRTuC8S0sPIWnIJILpou20+Sj7wnM1x Cf/oAVa5Zv3xNtSx1gHYPCGEYfSGANKu2I6jabdQHZXbn40LI9H/liZmGURG2+iB3fik l6aTJ/rze++6qLkQ+1cIMmqmkSr5wtL+tRbdswby4kMzk83PzyU5QjOKsfk1nqOhbm3a PTcg== 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=P+DYjJ1GrlLPWPS5TfKbJgOvt9CYy26/DlrQnU+Di10=; b=BzuyElPASKzLCnWBVd5YbxK3ut7Q16B7lHz881m2j7euH5lXm6WRvWq6uYP3QnjeHL Mg1hHgNOs56WQq9GriSWKojgce7hUOVnYxlRQMUakcbsuAs3kAl7DkX4X/WUiVdq+a66 F/ZR2Jxd/ocnsHSlk2YCNM6KqRIbv0gP9FPAAthcp7GQ5tBGxgkGcIJbIZsZahsFaZwQ ZIt9WiB03MTni6uJ9OY8WLrFj4gLK41vUEsx5kwzmjVRDpZga7o49VmoPMapKHQU4/ou 7gjPMGOE6TZR3lCYPM5HL9gxCDoRCuaumUDka2NVYJ9dmn6jjd/mhtesMIKnd8U6j2Ss 55Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=MjMSF5nr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id i8si765474ejf.197.2020.05.06.02.13.38; Wed, 06 May 2020 02:14:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=MjMSF5nr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728878AbgEFJMS (ORCPT + 99 others); Wed, 6 May 2020 05:12:18 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:13812 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728474AbgEFJMS (ORCPT ); Wed, 6 May 2020 05:12:18 -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 04697EYO001972; Wed, 6 May 2020 11:12:02 +0200 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=P+DYjJ1GrlLPWPS5TfKbJgOvt9CYy26/DlrQnU+Di10=; b=MjMSF5nruLVMYia8JEfsi+B2UkMv4jRp857ZQeXn8Eg5xRmbsvVZQPcxpMo6DObCoH5L EY9CFTbdSKFfWAZxESqwLqZsj6pq8GlAXR4cAP0UmqhseburkeSE2Ga45exZ6hHKq54U tgQ0KmBpkpLCsW5rZIQp5Hkkl2sUvI7hArDAG1XOD0CmH2vJvMirkZEV8HdRgB+CC9N8 Myun6GINA8LSA/SsfjUwkwg266Rpnr9C/WcT/Kd+cmpkwrln3R/swxCOK7rzsJ6ICjFI /PWmxUvxhFMFYU/yb2y64UauSm4wAz1j1o6EqXq/c2WWsnMA0wU+akB5bqr/8442HPVW vA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30rxb254wm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 May 2020 11:12:02 +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 6ED2D10002A; Wed, 6 May 2020 11:12:02 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag6node2.st.com [10.75.127.17]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 563E3222CF7; Wed, 6 May 2020 11:12:02 +0200 (CEST) Received: from localhost (10.75.127.49) by SFHDAG6NODE2.st.com (10.75.127.17) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 6 May 2020 11:12:01 +0200 From: Christophe Kerello To: , , , , , , CC: , , , , , Christophe Kerello Subject: [PATCH v4 01/10] mtd: rawnand: stm32_fmc2: manage all errors cases at probe time Date: Wed, 6 May 2020 11:11:10 +0200 Message-ID: <1588756279-17289-2-git-send-email-christophe.kerello@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1588756279-17289-1-git-send-email-christophe.kerello@st.com> References: <1588756279-17289-1-git-send-email-christophe.kerello@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG6NODE2.st.com (10.75.127.17) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-05-06_03:2020-05-04,2020-05-06 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 --- Changes in v3: - rename labels used on errors drivers/mtd/nand/raw/stm32_fmc2_nand.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c index b6d45cd..50a6377 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_release_dma; /* FMC2 init routine */ stm32_fmc2_init(fmc2); @@ -1997,20 +2001,20 @@ 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_release_dma; ret = mtd_device_register(mtd, NULL, 0); if (ret) - goto err_device_register; + goto err_nand_cleanup; platform_set_drvdata(pdev, fmc2); return 0; -err_device_register: +err_nand_cleanup: nand_cleanup(chip); -err_scan: +err_release_dma: 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