From patchwork Wed Sep 7 09:09:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 9318681 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 970346077F for ; Wed, 7 Sep 2016 09:09:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CD2A2919E for ; Wed, 7 Sep 2016 09:09:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81152291A0; Wed, 7 Sep 2016 09:09:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA5DA2919E for ; Wed, 7 Sep 2016 09:09:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752424AbcIGJJl (ORCPT ); Wed, 7 Sep 2016 05:09:41 -0400 Received: from mirror2.csie.ntu.edu.tw ([140.112.30.76]:53102 "EHLO wens.csie.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751003AbcIGJJj (ORCPT ); Wed, 7 Sep 2016 05:09:39 -0400 Received: by wens.csie.org (Postfix, from userid 1000) id 798A75F8FE; Wed, 7 Sep 2016 17:09:36 +0800 (CST) From: Chen-Yu Tsai To: Hans de Goede , Jean-Christophe Plagniol-Villard , Tomi Valkeinen Cc: Chen-Yu Tsai , linux-fbdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] simplefb: Disable and release clocks and regulators in destroy callback Date: Wed, 7 Sep 2016 17:09:19 +0800 Message-Id: <20160907090919.27187-1-wens@csie.org> X-Mailer: git-send-email 2.9.3 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP simplefb gets unregister when a proper framebuffer driver comes in and kicks it out. However the claimed clocks and regulators stay enabled as they are only released in the platform device remove function, which in theory would never get called. Move the clock/regulator cleanup into the framebuffer destroy callback, which gets called as part of the framebuffer unregister process. Note this introduces asymmetry in how the resources are claimed and released. Signed-off-by: Chen-Yu Tsai Reviewed-by: Hans de Goede --- drivers/video/fbdev/simplefb.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c index e9cf19977285..3620d10a0d00 100644 --- a/drivers/video/fbdev/simplefb.c +++ b/drivers/video/fbdev/simplefb.c @@ -74,8 +74,14 @@ static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, return 0; } +struct simplefb_par; +static void simplefb_clocks_destroy(struct simplefb_par *par); +static void simplefb_regulators_destroy(struct simplefb_par *par); + static void simplefb_destroy(struct fb_info *info) { + simplefb_regulators_destroy(info->par); + simplefb_clocks_destroy(info->par); if (info->screen_base) iounmap(info->screen_base); } @@ -487,11 +493,8 @@ error_fb_release: static int simplefb_remove(struct platform_device *pdev) { struct fb_info *info = platform_get_drvdata(pdev); - struct simplefb_par *par = info->par; unregister_framebuffer(info); - simplefb_regulators_destroy(par); - simplefb_clocks_destroy(par); framebuffer_release(info); return 0;