From patchwork Fri Feb 20 17:51:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 5857671 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 04E49BF440 for ; Fri, 20 Feb 2015 17:51:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0B2D2204FC for ; Fri, 20 Feb 2015 17:51:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E4D13204EB for ; Fri, 20 Feb 2015 17:51:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754429AbbBTRvq (ORCPT ); Fri, 20 Feb 2015 12:51:46 -0500 Received: from mail-wi0-f175.google.com ([209.85.212.175]:61549 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754104AbbBTRvp (ORCPT ); Fri, 20 Feb 2015 12:51:45 -0500 Received: by mail-wi0-f175.google.com with SMTP id r20so4666025wiv.2; Fri, 20 Feb 2015 09:51:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=VM2IYbCT5u2iqomr+WLqKuEqFywLRVUB1u6NP8q5YV8=; b=mN1oYt8499sHtM37VwnZcm1oC6BPXe9aNghtKZB2B5pRhQdY/bT/g2HHs1J4DXW/et eatgx5m1zSYHzMe3hDpwHcjF0s9t5u9xpZLJoBeyY4EOb0OAG4xaVWqBhH6ZBGFYxv9G s5iHpgJabcsX2DpkWflYnMAXzdEGvB7OeawlmbE/m8jT2jb4brr/9vve10ThElEtsCsj dPrtqaQxZ/42nNNHbThE/PWxVnRFN/1RYadQCCW6H5vh0iLBmkQPwdoM8GN9akzjRZ5v GYXteJsv6C77bVcej+206wldMDlRnyBSC2qxCOpIfqzsgd1+TtYZ1k5U8A6Eg1kUVzqh r5Gw== X-Received: by 10.180.198.101 with SMTP id jb5mr7591926wic.92.1424454703819; Fri, 20 Feb 2015 09:51:43 -0800 (PST) Received: from tango-charlie.RL.local ([194.72.83.162]) by mx.google.com with ESMTPSA id bd8sm43030459wjc.21.2015.02.20.09.51.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Feb 2015 09:51:42 -0800 (PST) From: Prabhakar Lad To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen Cc: linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Lad, Prabhakar" Subject: [PATCH] fbdev: goldfishfb: use devres api Date: Fri, 20 Feb 2015 17:51:28 +0000 Message-Id: <1424454688-2509-1-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.9.1 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 From: "Lad, Prabhakar" this patch does the following: a> uses devm_kzalloc() instead of kzalloc and cleanup the error path b> uses devm_ioremap() instead of ioremap and cleanup the error path c> uses devm_request_irq() instead of request_irq and cleanup the error path Signed-off-by: Lad, Prabhakar --- Note: This patch is compile tested only and applies on linux-next. drivers/video/fbdev/goldfishfb.c | 61 +++++++++++++++------------------------- 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/drivers/video/fbdev/goldfishfb.c b/drivers/video/fbdev/goldfishfb.c index 7f6c9e6..841514d 100644 --- a/drivers/video/fbdev/goldfishfb.c +++ b/drivers/video/fbdev/goldfishfb.c @@ -188,31 +188,25 @@ static int goldfish_fb_probe(struct platform_device *pdev) u32 width, height; dma_addr_t fbpaddr; - fb = kzalloc(sizeof(*fb), GFP_KERNEL); - if (fb == NULL) { - ret = -ENOMEM; - goto err_fb_alloc_failed; - } + fb = devm_kzalloc(&pdev->dev, sizeof(*fb), GFP_KERNEL); + if (fb == NULL) + return -ENOMEM; + spin_lock_init(&fb->lock); init_waitqueue_head(&fb->wait); platform_set_drvdata(pdev, fb); r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (r == NULL) { - ret = -ENODEV; - goto err_no_io_base; - } - fb->reg_base = ioremap(r->start, PAGE_SIZE); - if (fb->reg_base == NULL) { - ret = -ENOMEM; - goto err_no_io_base; - } + if (r == NULL) + return -ENODEV; + + fb->reg_base = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE); + if (fb->reg_base == NULL) + return -ENOMEM; fb->irq = platform_get_irq(pdev, 0); - if (fb->irq <= 0) { - ret = -ENODEV; - goto err_no_irq; - } + if (fb->irq <= 0) + return -ENODEV; width = readl(fb->reg_base + FB_GET_WIDTH); height = readl(fb->reg_base + FB_GET_HEIGHT); @@ -249,43 +243,34 @@ static int goldfish_fb_probe(struct platform_device *pdev) &fbpaddr, GFP_KERNEL); pr_debug("allocating frame buffer %d * %d, got %p\n", width, height, fb->fb.screen_base); - if (fb->fb.screen_base == NULL) { - ret = -ENOMEM; - goto err_alloc_screen_base_failed; - } + if (fb->fb.screen_base == NULL) + return -ENOMEM; + fb->fb.fix.smem_start = fbpaddr; fb->fb.fix.smem_len = framesize; ret = fb_set_var(&fb->fb, &fb->fb.var); if (ret) - goto err_fb_set_var_failed; + goto error; - ret = request_irq(fb->irq, goldfish_fb_interrupt, IRQF_SHARED, - pdev->name, fb); + ret = devm_request_irq(&pdev->dev, fb->irq, goldfish_fb_interrupt, + IRQF_SHARED, pdev->name, fb); if (ret) - goto err_request_irq_failed; + goto error; writel(FB_INT_BASE_UPDATE_DONE, fb->reg_base + FB_INT_ENABLE); goldfish_fb_pan_display(&fb->fb.var, &fb->fb); /* updates base */ ret = register_framebuffer(&fb->fb); if (ret) - goto err_register_framebuffer_failed; + goto error; + return 0; -err_register_framebuffer_failed: - free_irq(fb->irq, fb); -err_request_irq_failed: -err_fb_set_var_failed: +error: dma_free_coherent(&pdev->dev, framesize, (void *)fb->fb.screen_base, fb->fb.fix.smem_start); -err_alloc_screen_base_failed: -err_no_irq: - iounmap(fb->reg_base); -err_no_io_base: - kfree(fb); -err_fb_alloc_failed: return ret; } @@ -296,11 +281,9 @@ static int goldfish_fb_remove(struct platform_device *pdev) framesize = fb->fb.var.xres_virtual * fb->fb.var.yres_virtual * 2; unregister_framebuffer(&fb->fb); - free_irq(fb->irq, fb); dma_free_coherent(&pdev->dev, framesize, (void *)fb->fb.screen_base, fb->fb.fix.smem_start); - iounmap(fb->reg_base); return 0; }