From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932876AbbGUPIm (ORCPT ); Tue, 21 Jul 2015 11:08:42 -0400 Received: from arcturus.kleine-koenig.org ([78.47.169.190]:47587 "EHLO arcturus.kleine-koenig.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932517AbbGUPIk (ORCPT ); Tue, 21 Jul 2015 11:08:40 -0400 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Greg Kroah-Hartman , Mark Brown Cc: linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH] base/platform: assert that dev_pm_domain callbacks are called unconditionally Date: Tue, 21 Jul 2015 17:08:35 +0200 Message-Id: <1437491315-2370-1-git-send-email-uwe@kleine-koenig.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <20150721144100.GU11162@sirena.org.uk> References: <20150721144100.GU11162@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a platform driver doesn't provide a .remove callback the function platform_drv_remove isn't called and so the call to dev_pm_domain_attach called at probe time isn't paired by dev_pm_domain_detach at remove time. To fix this (and similar issues if different callbacks are missing) hook up the driver callbacks unconditionally and make them aware that the platform callbacks might be missing. Signed-off-by: Uwe Kleine-König --- Hello, I didn't see any breakage without this patch, but it looks wrong the way it is. Best regards Uwe drivers/base/platform.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 063f0ab15259..62debf4a1348 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -517,7 +517,7 @@ static int platform_drv_probe(struct device *_dev) return ret; ret = dev_pm_domain_attach(_dev, true); - if (ret != -EPROBE_DEFER) { + if (ret != -EPROBE_DEFER && drv->probe) { ret = drv->probe(dev); if (ret) dev_pm_domain_detach(_dev, true); @@ -542,7 +542,8 @@ static int platform_drv_remove(struct device *_dev) struct platform_device *dev = to_platform_device(_dev); int ret; - ret = drv->remove(dev); + if (drv->remove) + ret = drv->remove(dev); dev_pm_domain_detach(_dev, true); return ret; @@ -553,7 +554,8 @@ static void platform_drv_shutdown(struct device *_dev) struct platform_driver *drv = to_platform_driver(_dev->driver); struct platform_device *dev = to_platform_device(_dev); - drv->shutdown(dev); + if (drv->shutdown) + drv->shutdown(dev); dev_pm_domain_detach(_dev, true); } @@ -567,12 +569,9 @@ int __platform_driver_register(struct platform_driver *drv, { drv->driver.owner = owner; drv->driver.bus = &platform_bus_type; - if (drv->probe) - drv->driver.probe = platform_drv_probe; - if (drv->remove) - drv->driver.remove = platform_drv_remove; - if (drv->shutdown) - drv->driver.shutdown = platform_drv_shutdown; + drv->driver.probe = platform_drv_probe; + drv->driver.remove = platform_drv_remove; + drv->driver.shutdown = platform_drv_shutdown; return driver_register(&drv->driver); } -- 2.1.4