From patchwork Mon Aug 4 14:43:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pramod Gurav X-Patchwork-Id: 4670581 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D75C79F375 for ; Mon, 4 Aug 2014 14:46:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E5CC020142 for ; Mon, 4 Aug 2014 14:46:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 928952013A for ; Mon, 4 Aug 2014 14:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752620AbaHDOqc (ORCPT ); Mon, 4 Aug 2014 10:46:32 -0400 Received: from smtp89.ord1c.emailsrvr.com ([108.166.43.89]:38585 "EHLO smtp89.ord1c.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752616AbaHDOqb (ORCPT ); Mon, 4 Aug 2014 10:46:31 -0400 X-Greylist: delayed 365 seconds by postgrey-1.27 at vger.kernel.org; Mon, 04 Aug 2014 10:46:31 EDT Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp12.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 4547F80C4C; Mon, 4 Aug 2014 10:40:26 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp12.relay.ord1c.emailsrvr.com (Authenticated sender: pramod.gurav-AT-smartplayin.com) with ESMTPSA id 86BA880B6C; Mon, 4 Aug 2014 10:40:23 -0400 (EDT) X-Sender-Id: pramod.gurav@smartplayin.com Received: from SPINITLTDL00278.smartplayin.local ([UNAVAILABLE]. [220.227.185.53]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA) by 0.0.0.0:465 (trex/5.2.10); Mon, 04 Aug 2014 14:40:26 GMT From: Pramod Gurav To: linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pramod Gurav , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , Stephen Boyd , Jingoo Han , Rob Clark Subject: [PATCH] msm: msm_fb: Add remove function for platform driver for clean unloading Date: Mon, 4 Aug 2014 20:13:53 +0530 Message-Id: <1407163433-13528-1-git-send-email-pramod.gurav@smartplayin.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This adds a remove function to platform driver structure so that resources are released when driver is unloaded. Moved kzalloc to use managed resource and adds a return check if failed. CC: Jean-Christophe Plagniol-Villard CC: Tomi Valkeinen CC: Stephen Boyd CC: Jingoo Han CC: Rob Clark Signed-off-by: Pramod Gurav --- drivers/video/fbdev/msm/msm_fb.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/msm/msm_fb.c b/drivers/video/fbdev/msm/msm_fb.c index 1374803..ac277e2 100644 --- a/drivers/video/fbdev/msm/msm_fb.c +++ b/drivers/video/fbdev/msm/msm_fb.c @@ -553,6 +553,7 @@ static int msmfb_probe(struct platform_device *pdev) fb = framebuffer_alloc(sizeof(struct msmfb_info), &pdev->dev); if (!fb) return -ENOMEM; + msmfb = fb->par; msmfb->fb = fb; msmfb->panel = panel; @@ -569,8 +570,13 @@ static int msmfb_probe(struct platform_device *pdev) mutex_init(&msmfb->panel_init_lock); init_waitqueue_head(&msmfb->frame_wq); INIT_WORK(&msmfb->resume_work, power_on_panel); - msmfb->black = kzalloc(msmfb->fb->var.bits_per_pixel*msmfb->xres, - GFP_KERNEL); + msmfb->black = devm_kzalloc(&pdev->dev, + msmfb->fb->var.bits_per_pixel*msmfb->xres, + GFP_KERNEL); + if (!msmfb->black) { + ret = -ENOMEM; + goto error_register_framebuffer; + } printk(KERN_INFO "msmfb_probe() installing %d x %d panel\n", msmfb->xres, msmfb->yres); @@ -589,6 +595,8 @@ static int msmfb_probe(struct platform_device *pdev) msmfb->sleeping = WAKING; + platform_set_drvdata(pdev, msmfb); + return 0; error_register_framebuffer: @@ -598,13 +606,27 @@ error_setup_fbmem: return ret; } +static int msmfb_remove(struct platform_device *pdev) +{ + struct msmfb_info *msmfb = NULL; + + msmfb = platform_get_drvdata(pdev); + if (msmfb) { + unregister_framebuffer(msmfb->fb); + iounmap(msmfb->fb->screen_base); + framebuffer_release(msmfb->fb); + } + + return 0; +} + static struct platform_driver msm_panel_driver = { /* need to write remove */ .probe = msmfb_probe, + .remove = msmfb_remove, .driver = {.name = "msm_panel"}, }; - static int msmfb_add_mdp_device(struct device *dev, struct class_interface *class_intf) {