Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17893669ybl; Thu, 2 Jan 2020 14:14:56 -0800 (PST) X-Google-Smtp-Source: APXvYqx5dSvwVkbzz4vt9MBtbHQgnDjJHlJ48btUkkj1R4Jj15xE5zVAZlp0/iqxWcXsWDxzH+hv X-Received: by 2002:a05:6808:6c5:: with SMTP id m5mr2941763oih.106.1578003296829; Thu, 02 Jan 2020 14:14:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578003296; cv=none; d=google.com; s=arc-20160816; b=svUY1IUWRzto/Kna6NZ2ea6NuDog2rIaGPNUdrBTWscKbjn0ZZeZ8giTehervXSzkw am/2cAaNHGMPhYNUbaA7w6G90uKij1/uCSc7HOke2avu7ieNrP4D+PxEsNhuz1hl1Y0j yteWQ6QclgfdePKW11y37iHhrXOFwRHUJfqOUAw8gByC1jGYNZlHDkI+3t7k36FItIvH WZWCVCj/ocL3rWXdaQd5xoAccSN5zEx49q7b9moG7EFuUx7Qb4e3Jgka0mRedPDNz29U B2VVUM2au9+GV44m5nfjFOgeCfTGUEV2gOj2cKOXeTjEGTpUXzDvMl8GUjowR8AGVZdS OVrQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3Tcp9bJyo8+rm4RoAGzUsXhdRiUHH/cLwinFBHCGvMU=; b=WIvJkhA7JRFIlIcm3ctnd6tOnDMH+9WUD59/wWYVQpZX8aqk9jnBf4HTlSIHP1sP3f UoQkOLAreO/eCbBz1F+nwQSO1Q0dxmi04F9zjzJlwqCzx3zVaq1LDTdPslXjs42x8cUQ DsOjD7Qqas2aK0O3tXJDP6SoilLIFWijLvpEJoXS1GCcy/dX/HOgkz3dzOYOHCI43VQO L7VZvtQSF7HVtQH0EAXwINHwamV17ZSpzkWWYidbvo+zh4q6Ysc8r7UuudkLW0ROflT0 0Q5XvFCM76kOMPNuivX4JRmhdC/9V5wAxW9OBNOGIlh+NRRS6rlDO/XbpgA4bnsE8hHe XSyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cK4CpP93; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l14si26978167oii.37.2020.01.02.14.14.45; Thu, 02 Jan 2020 14:14:56 -0800 (PST) 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=@kernel.org header.s=default header.b=cK4CpP93; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727429AbgABWNf (ORCPT + 99 others); Thu, 2 Jan 2020 17:13:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:53340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727386AbgABWNb (ORCPT ); Thu, 2 Jan 2020 17:13:31 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 64EAB22525; Thu, 2 Jan 2020 22:13:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003210; bh=mBhPzEHMmHjCJxgZUXZTiGKdQ5QQBIVVgNcKfxVzItY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cK4CpP93ruPJV5OKVWq1KTsitsKZakI+fPVramxBzaag1d/sbFrqDIeZcJ534STfy ea8R0sofhQubPgw6tyc24m2aY68E1Ywg31xUSx4Ocmq9Ogp9oNde5r/i2D8sEfJ1tW ZWveliDtVj4uwmhXIxzZh4sv7aRUJ0LHD4fb2sVQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alain Volmat , Pierre-Yves MORDRET , Wolfram Sang , Sasha Levin Subject: [PATCH 5.4 058/191] i2c: stm32f7: fix & reorder remove & probe error handling Date: Thu, 2 Jan 2020 23:05:40 +0100 Message-Id: <20200102215836.171338610@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alain Volmat [ Upstream commit 53aaaa5d9b1e95eb40e877fbffa6f964a8394bb7 ] 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 Reviewed-by: Pierre-Yves MORDRET Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- 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 b24e7b937f21..84cfed17ff4f 100644 --- a/drivers/i2c/busses/i2c-stm32f7.c +++ b/drivers/i2c/busses/i2c-stm32f7.c @@ -1985,6 +1985,11 @@ pm_disable: 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); @@ -1995,21 +2000,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.20.1