From patchwork Thu Oct 29 21:19:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 7521151 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0B98B9F37F for ; Thu, 29 Oct 2015 21:23:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 22B8F2063D for ; Thu, 29 Oct 2015 21:23:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2337D20630 for ; Thu, 29 Oct 2015 21:23:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758098AbbJ2VXk (ORCPT ); Thu, 29 Oct 2015 17:23:40 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:36632 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757914AbbJ2VXi (ORCPT ); Thu, 29 Oct 2015 17:23:38 -0400 Received: by wmec75 with SMTP id c75so33074496wme.1 for ; Thu, 29 Oct 2015 14:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-type:content-transfer-encoding; bh=C4FJpFuXZWpH7vTafF9s82O43mDnFo8JVvJYjTHXYVI=; b=mJzGXcdD+I+8Cda9i0Dn/CwSQdj6OenS9uMOgs0/G4IMkqwlBQcrVAANX12OM09ngt +YtJn+AhdlxWZagL1Hsqp8Lq/rs0pTcZMBUzSAdf/XSCbQ8oRc9EdbbTsqS1Se9vanFh cZ4qaWrjM1ccZbf1FJDaMiEQVX8wJhPOp9m8MZSebjDnYStRS+hn8zSGVMHU9B/potMg IX2DwHjJb7UeN+X1eAgcs7Yrgyv4pKUVfAzwaoj3a0WjW8tTP3IQ3VRKkQ+U8EhUybJV aNf5CxGv7aGGSLWBc2C1F3WGzy6MWv/i9fMaO6e+5dKdFdblABYFsWGdpicCAHmjvD6g TPKQ== X-Received: by 10.28.23.206 with SMTP id 197mr6754838wmx.88.1446153817463; Thu, 29 Oct 2015 14:23:37 -0700 (PDT) Received: from ?IPv6:2003:62:5f55:ba00:14ec:a654:7de1:4720? (p200300625F55BA0014ECA6547DE14720.dip0.t-ipconnect.de. [2003:62:5f55:ba00:14ec:a654:7de1:4720]) by smtp.googlemail.com with ESMTPSA id he3sm3680846wjc.48.2015.10.29.14.23.36 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 29 Oct 2015 14:23:37 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH 3/9] media: rc: nuvoton-cir: switch resource handling to devm functions To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org Message-ID: <56328D68.9050906@gmail.com> Date: Thu, 29 Oct 2015 22:19:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.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=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 Switch to managed resource handling using the devm_ functions. Signed-off-by: Heiner Kallweit --- drivers/media/rc/nuvoton-cir.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index 4d8e12f..a382e17 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c @@ -971,7 +971,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) struct rc_dev *rdev; int ret = -ENOMEM; - nvt = kzalloc(sizeof(struct nvt_dev), GFP_KERNEL); + nvt = devm_kzalloc(&pdev->dev, sizeof(struct nvt_dev), GFP_KERNEL); if (!nvt) return ret; @@ -1071,21 +1071,22 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) ret = -EBUSY; /* now claim resources */ - if (!request_region(nvt->cir_addr, + if (!devm_request_region(&pdev->dev, nvt->cir_addr, CIR_IOREG_LENGTH, NVT_DRIVER_NAME)) goto exit_unregister_device; - if (request_irq(nvt->cir_irq, nvt_cir_isr, IRQF_SHARED, - NVT_DRIVER_NAME, (void *)nvt)) - goto exit_release_cir_addr; + if (devm_request_irq(&pdev->dev, nvt->cir_irq, nvt_cir_isr, + IRQF_SHARED, NVT_DRIVER_NAME, (void *)nvt)) + goto exit_unregister_device; - if (!request_region(nvt->cir_wake_addr, + if (!devm_request_region(&pdev->dev, nvt->cir_wake_addr, CIR_IOREG_LENGTH, NVT_DRIVER_NAME)) - goto exit_free_irq; + goto exit_unregister_device; - if (request_irq(nvt->cir_wake_irq, nvt_cir_wake_isr, IRQF_SHARED, - NVT_DRIVER_NAME, (void *)nvt)) - goto exit_release_cir_wake_addr; + if (devm_request_irq(&pdev->dev, nvt->cir_wake_irq, + nvt_cir_wake_isr, IRQF_SHARED, + NVT_DRIVER_NAME, (void *)nvt)) + goto exit_unregister_device; device_init_wakeup(&pdev->dev, true); @@ -1097,18 +1098,11 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) return 0; -exit_release_cir_wake_addr: - release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH); -exit_free_irq: - free_irq(nvt->cir_irq, nvt); -exit_release_cir_addr: - release_region(nvt->cir_addr, CIR_IOREG_LENGTH); exit_unregister_device: rc_unregister_device(rdev); rdev = NULL; exit_free_dev_rdev: rc_free_device(rdev); - kfree(nvt); return ret; } @@ -1126,15 +1120,7 @@ static void nvt_remove(struct pnp_dev *pdev) nvt_enable_wake(nvt); spin_unlock_irqrestore(&nvt->nvt_lock, flags); - /* free resources */ - free_irq(nvt->cir_irq, nvt); - free_irq(nvt->cir_wake_irq, nvt); - release_region(nvt->cir_addr, CIR_IOREG_LENGTH); - release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH); - rc_unregister_device(nvt->rdev); - - kfree(nvt); } static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)