From patchwork Thu Apr 6 08:23:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 1765921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4PsZKW14J3z1yY8 for ; Thu, 6 Apr 2023 18:24:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235849AbjDFIYL (ORCPT ); Thu, 6 Apr 2023 04:24:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235795AbjDFIYK (ORCPT ); Thu, 6 Apr 2023 04:24:10 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60C417A9A for ; Thu, 6 Apr 2023 01:24:08 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pkKuT-0006zt-8j; Thu, 06 Apr 2023 10:23:57 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pkKuR-009L2f-71; Thu, 06 Apr 2023 10:23:55 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pkKuQ-00AzQf-G5; Thu, 06 Apr 2023 10:23:54 +0200 Date: Thu, 6 Apr 2023 10:23:54 +0200 From: Uwe =?utf-8?q?Kleine-K=C3=B6nig?= To: Wolfram Sang , Tony Lindgren , Andreas Kemnade , Aaro Koskinen , Janusz Krzysztofik , Vignesh R , linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, kernel@pengutronix.de, "Rafael J. Wysocki" , linux-pm@vger.kernel.org Subject: [PATCH] i2c: omap: Improve error reporting for problems during .remove() Message-ID: <20230406082354.jwchbl5ir6p4gjw7@pengutronix.de> References: <20230402105518.2512541-1-u.kleine-koenig@pengutronix.de> <20230402225001.75a32147@aktux> <20230403054837.6lxyzznzntvw2drg@pengutronix.de> <20230403060404.GX7501@atomide.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-i2c@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org If pm_runtime_get() fails in .remove() the driver used to return the error to the driver core. The only effect of this (compared to returning zero) is a generic warning that the error value is ignored. So emit a better warning and return zero to suppress the generic (and little helpful) message. Also disable runtime PM in the error case. This prepares changing platform device remove callbacks to return void. Signed-off-by: Uwe Kleine-König Reviewed-by: Tony Lindgren --- On Thu, Apr 06, 2023 at 08:44:33AM +0200, Wolfram Sang wrote: > > > > So if there is some clk handling necessary before the register access, > > > I'm not aware where it's hidden. Is there some bus or omap specific code > > > that ensures clk handling? > > > > I think the missing part is that the runtime PM calls in the i2c driver > > cause the parent ti-sysc interconnect target module device to get enabled > > and clocked before accessing the i2c registers. > > So, this patch is not needed? The patch as is is wrong. For my quest to drop the return value of platform driver's remove callbacks, I need this patch instead: drivers/i2c/busses/i2c-omap.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6 diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index f9ae520aed22..2b4e2be51318 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -1525,14 +1525,17 @@ static int omap_i2c_remove(struct platform_device *pdev) int ret; i2c_del_adapter(&omap->adapter); - ret = pm_runtime_resume_and_get(&pdev->dev); + + ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) - return ret; + dev_err(omap->dev, "Failed to resume hardware, skip disable\n"); + else + omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0); - omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0); pm_runtime_dont_use_autosuspend(&pdev->dev); pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); + return 0; }