Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4113635ybg; Fri, 25 Oct 2019 13:32:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3eUb2Ikg3sXYeRhGcqHtxV7PGXkMScUCwzVWCUEb9IRcj03VPvjcIa24GvIfJw1NB1bq+ X-Received: by 2002:a17:906:22c8:: with SMTP id q8mr5260218eja.19.1572035557284; Fri, 25 Oct 2019 13:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572035557; cv=none; d=google.com; s=arc-20160816; b=ihgSlIi6L2vJXKWmICJMI4V7aCoBQoS+woXJKfIkO9kj1JGVSWBK4IqDol93ugdGx6 YqOPb0ZkHmfHpfcoL0/eRy3Ydhd0e2E6t4ZbZUSS5qzAtyhL0PZbl0j5BdYGZ24w9g3F FR5ROgbgQwItTj/wp9NZe57x0YADfJKw6vgKmuI1OYs+91tqIsUlEfJvvVdSew6j9nkC FhRmrsqqznkPO+B4BmHMINANA+wYccHfXrCiPaGHpQNTgOo2QnDB988rjFmat39bG8zi 5ZRMMgGuZ9odF37Cgz8lIaZFck7TixNdfzmiRoMMNgRIIMEUrB+H2jJfc4vCfV48Oxhb X0Tw== 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=6Ht0zZxdeBCxT8SIBqaJnpSGpFwNjqaDeglBn/VrO3w=; b=XkS5q6ow2204tEzAnPP+CsJoLIpsLZgvH0UYaUDIu1afTOaVfFfvbxr1NUclIk4jAU BkLvD7nMla/y/1ucohvf7ty1U8EPFaWoGyZj2MYUHjtNmziz5V+7MUW+MMR3+UCNHLaa a9DN+r17Ff7VrTE8wzHfccha0JH/IhBRDsByzTXcGJR2Rqlkzfh6ahrFD296BBhruFuk W4N6vBMjOvpO+srVJYw4/bKP7bysoz42UjgW4wy8Ob+L42MFLANXgx0PM02Wyw9fB/JX Houmz+O+ndmYK3SEQ58r8tKg5C1sDBGK6gN2xFHO1YHiqZJ44opJE6GytK/8DHxzqZT9 Rz0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=0BIlOeQS; 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 11si2398954edv.422.2019.10.25.13.32.13; Fri, 25 Oct 2019 13:32:37 -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=0BIlOeQS; 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 S2395218AbfJYOEl (ORCPT + 99 others); Fri, 25 Oct 2019 10:04:41 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:36329 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395206AbfJYOEi (ORCPT ); Fri, 25 Oct 2019 10:04:38 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9PDuBtP028321; Fri, 25 Oct 2019 16:04:26 +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=6Ht0zZxdeBCxT8SIBqaJnpSGpFwNjqaDeglBn/VrO3w=; b=0BIlOeQSsfPknWnAKmzTKfZ1WxZOkuAIOg7bvNrhnz03goBTWB/ZKl/fARBIcXwySHb7 rUa2rmTeWjDAvlteKeaNh3+rS323DdXO4YKTYgsy/GIR+7EGEqgIbrseqF1Vnyj5BfP9 DrMDAiqEiXqeHL6bvBka3MXKoWwiCmliaHP2H2UAU+14Swr2iYmhSMu84FF8ZdnPWDsw vthdwaU+05MCs7wEUKfmZzomEgXkTtsuXPTB/+inaJUOECbERcWCGNwpvq86ge4EpwKL 1ytaduFZxRFR7t1mtK0GVAfGpKmN0bAfCHJdZK/JcBy9YzanWqSwcGVexr30U41PJHBg aA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2vt9s2058n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Oct 2019 16:04:26 +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 5A93C100034; Fri, 25 Oct 2019 16:04:25 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node2.st.com [10.75.127.8]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 4D3822C38A2; Fri, 25 Oct 2019 16:04:25 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG3NODE2.st.com (10.75.127.8) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 25 Oct 2019 16:04:24 +0200 From: Alain Volmat To: , CC: , , , , , , Subject: [PATCH] i2c: i2c-stm32f7: fix & reorder remove & probe error handling Date: Fri, 25 Oct 2019 16:04:24 +0200 Message-ID: <1572012264-31996-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.47] X-ClientProxiedBy: SFHDAG3NODE3.st.com (10.75.127.9) 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-25_08:2019-10-25,2019-10-25 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add missing dma channels free calls in case of error during probe and reorder the remove function so that dma channels are freed after the i2c adapter is deleted. Overall, reorder the remove function so that probe error handling order and remove function order are same. Fixes: 7ecc8cfde553 ("i2c: i2c-stm32f7: Add DMA support") Signed-off-by: Alain Volmat --- drivers/i2c/busses/i2c-stm32f7.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c index d36cf08461f7..f8ef203dabfc 100644 --- a/drivers/i2c/busses/i2c-stm32f7.c +++ b/drivers/i2c/busses/i2c-stm32f7.c @@ -1980,6 +1980,11 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) pm_runtime_set_suspended(i2c_dev->dev); pm_runtime_dont_use_autosuspend(i2c_dev->dev); + if (i2c_dev->dma) { + stm32_i2c_dma_free(i2c_dev->dma); + i2c_dev->dma = NULL; + } + clk_free: clk_disable_unprepare(i2c_dev->clk); @@ -1990,21 +1995,21 @@ static int stm32f7_i2c_remove(struct platform_device *pdev) { struct stm32f7_i2c_dev *i2c_dev = platform_get_drvdata(pdev); - if (i2c_dev->dma) { - stm32_i2c_dma_free(i2c_dev->dma); - i2c_dev->dma = NULL; - } - i2c_del_adapter(&i2c_dev->adap); pm_runtime_get_sync(i2c_dev->dev); - clk_disable_unprepare(i2c_dev->clk); - pm_runtime_put_noidle(i2c_dev->dev); pm_runtime_disable(i2c_dev->dev); pm_runtime_set_suspended(i2c_dev->dev); pm_runtime_dont_use_autosuspend(i2c_dev->dev); + if (i2c_dev->dma) { + stm32_i2c_dma_free(i2c_dev->dma); + i2c_dev->dma = NULL; + } + + clk_disable_unprepare(i2c_dev->clk); + return 0; } -- 2.7.4