From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D644C83005 for ; Mon, 12 Jun 2023 10:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234467AbjFLKrW (ORCPT ); Mon, 12 Jun 2023 06:47:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbjFLKrJ (ORCPT ); Mon, 12 Jun 2023 06:47:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BEC659FF for ; Mon, 12 Jun 2023 03:31:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1B9BA623E1 for ; Mon, 12 Jun 2023 10:31:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E210C433D2; Mon, 12 Jun 2023 10:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1686565904; bh=9alBJ066ZQaUM7Z5J0Oxo3TQMox0Ft6lg9LI57asbTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bYK91ob66vTXoMO4iYEeczMkyNZ218QzM0xC5ab9zl326BPsUhQ5oJLAnzLbzXhUn XllnXWw0pS+KYI57k6GEftdLsQIM1dUlQS3gVaaWfwtkh0AjFHjiKQeLVM6E9uifFr pL0WreTg+q7E0XLyy3vO42WEX+eCYW9yNdoFMF4U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Andi Shyti , Wolfram Sang , Sasha Levin Subject: [PATCH 5.4 35/45] i2c: sprd: Delete i2c adapter in .removes error path Date: Mon, 12 Jun 2023 12:26:29 +0200 Message-ID: <20230612101656.090598007@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230612101654.644983109@linuxfoundation.org> References: <20230612101654.644983109@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Uwe Kleine-König [ Upstream commit ca0aa17f2db3468fd017038d23a78e17388e2f67 ] If pm runtime resume fails the .remove callback used to exit early. This resulted in an error message by the driver core but the device gets removed anyhow. This lets the registered i2c adapter stay around with an unbound parent device. So only skip clk disabling if resume failed, but do delete the adapter. Fixes: 8b9ec0719834 ("i2c: Add Spreadtrum I2C controller driver") Signed-off-by: Uwe Kleine-König Reviewed-by: Andi Shyti Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-sprd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c index 92ba0183fd8a0..ef0dc06a3778e 100644 --- a/drivers/i2c/busses/i2c-sprd.c +++ b/drivers/i2c/busses/i2c-sprd.c @@ -577,12 +577,14 @@ static int sprd_i2c_remove(struct platform_device *pdev) struct sprd_i2c *i2c_dev = platform_get_drvdata(pdev); int ret; - ret = pm_runtime_resume_and_get(i2c_dev->dev); + ret = pm_runtime_get_sync(i2c_dev->dev); if (ret < 0) - return ret; + dev_err(&pdev->dev, "Failed to resume device (%pe)\n", ERR_PTR(ret)); i2c_del_adapter(&i2c_dev->adap); - clk_disable_unprepare(i2c_dev->clk); + + if (ret >= 0) + clk_disable_unprepare(i2c_dev->clk); pm_runtime_put_noidle(i2c_dev->dev); pm_runtime_disable(i2c_dev->dev); -- 2.39.2