From patchwork Sat Mar 4 16:23:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 9604115 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 BE039602B4 for ; Sat, 4 Mar 2017 16:31:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFBA328478 for ; Sat, 4 Mar 2017 16:31:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2E6A28555; Sat, 4 Mar 2017 16:31:17 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 4FB7A28478 for ; Sat, 4 Mar 2017 16:31:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752107AbdCDQbK (ORCPT ); Sat, 4 Mar 2017 11:31:10 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:36387 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752538AbdCDQbI (ORCPT ); Sat, 4 Mar 2017 11:31:08 -0500 Received: by mail-wm0-f49.google.com with SMTP id n11so35539586wma.1 for ; Sat, 04 Mar 2017 08:31:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WX76gLbnA9LSDPz7svBmAuFSC6agmJlYm1PE26WA1w0=; b=QNWFep+ZBEdy27MzMHQj4bQw1+2X0aczrb5vC3j+bJTSec2aFkyJ6TgTtG0VSELFsx EKraZCenCqPP2whX06otGJP/1vOkB84dyDEHHye+JRLscaCF6I3qCBU6QfM5oGBVuIOP VmcDRhqWoksLHAvuZHbWoNWgQCv3XPxmtqqte7qrGy3b/x16tLUFhvgUVsYhf16Ezv+Z 0shbTng6N5CAXjNDYYv8VdaW4af2Vrq/iEqhmGZ99hJum8esep5Igqp8PwF+pi7Wdkzc WpT+viTDEa265SoLnIPexwguvH8I+mkqAQM6i31l80xKFhR2fbPJrJJsDeGvs2Y6gnYE T/iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WX76gLbnA9LSDPz7svBmAuFSC6agmJlYm1PE26WA1w0=; b=uGR2Tf47jKIXEYMlyY+oha0g1TmWHtrdP2gcXg8yoFcJrzka8x6PaSJSaqjzxAXTkk yS36AG27FCfALts8UAYD7hvq/A+1DNZTE479TNuVtnY5K8T3ZO6JqVNOv4Yj7BfuuCpS YwZ3FoMBR+mbgefIO3k7gz/SojPhWW+N+LyDtsCQ2nvS6rFiDYeRmCls/A7/u84XCFni gC5H5GBFFZzZ4oJZ/XauJev4r4lEHFYYcyq3YTpOORVazbFrqp77bE6HGyGK8PhLK5BI HW7tAxFFk/oPwrTGZTdacw+HeQsDE6h0Hl4cYMxxtafEJGea1V6KxSwqe/PTd+evJowV 44xg== X-Gm-Message-State: AMke39m6yNWI51NLEWFhqTTn6YWGjid2+Dbcv/isZnZhl6zVXgyIJyKLSSo2hloUs49I2+cS X-Received: by 10.28.68.69 with SMTP id r66mr7130001wma.115.1488644647413; Sat, 04 Mar 2017 08:24:07 -0800 (PST) Received: from bgdev-debian.lan (jua06-1-82-242-157-225.fbx.proxad.net. [82.242.157.225]) by smtp.gmail.com with ESMTPSA id b17sm7545753wma.33.2017.03.04.08.24.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 04 Mar 2017 08:24:06 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Alexandre Courbot , Bamvor Jian Zhang , Grygorii Strashko , Santosh Shilimkar , Kevin Hilman , Robert Jarzmik Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, Thomas Gleixner , Marc Zyngier , Bartosz Golaszewski Subject: [PATCH 05/12] gpio: ml-ioh: use resource management for irqs Date: Sat, 4 Mar 2017 17:23:33 +0100 Message-Id: <1488644620-11488-6-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1488644620-11488-1-git-send-email-bgolaszewski@baylibre.com> References: <1488644620-11488-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device resource managed variants of irq_alloc_descs() and request_irq() and remove the code manually freeing irq resources. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-ml-ioh.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c index 796a5a4..78896a8 100644 --- a/drivers/gpio/gpio-ml-ioh.c +++ b/drivers/gpio/gpio-ml-ioh.c @@ -459,41 +459,31 @@ static int ioh_gpio_probe(struct pci_dev *pdev, chip = chip_save; for (j = 0; j < 8; j++, chip++) { - irq_base = irq_alloc_descs(-1, IOH_IRQ_BASE, num_ports[j], - NUMA_NO_NODE); + irq_base = devm_irq_alloc_descs(&pdev->dev, -1, IOH_IRQ_BASE, + num_ports[j], NUMA_NO_NODE); if (irq_base < 0) { dev_warn(&pdev->dev, "ml_ioh_gpio: Failed to get IRQ base num\n"); - chip->irq_base = -1; ret = irq_base; - goto err_irq_alloc_descs; + goto err_gpiochip_add; } chip->irq_base = irq_base; ioh_gpio_alloc_generic_chip(chip, irq_base, num_ports[j]); } chip = chip_save; - ret = request_irq(pdev->irq, ioh_gpio_handler, - IRQF_SHARED, KBUILD_MODNAME, chip); + ret = devm_request_irq(&pdev->dev, pdev->irq, ioh_gpio_handler, + IRQF_SHARED, KBUILD_MODNAME, chip); if (ret != 0) { dev_err(&pdev->dev, "%s request_irq failed\n", __func__); - goto err_request_irq; + goto err_gpiochip_add; } pci_set_drvdata(pdev, chip); return 0; -err_request_irq: - chip = chip_save; -err_irq_alloc_descs: - while (--j >= 0) { - chip--; - irq_free_descs(chip->irq_base, num_ports[j]); - } - - chip = chip_save; err_gpiochip_add: while (--i >= 0) { chip--; @@ -524,12 +514,8 @@ static void ioh_gpio_remove(struct pci_dev *pdev) chip_save = chip; - free_irq(pdev->irq, chip); - - for (i = 0; i < 8; i++, chip++) { - irq_free_descs(chip->irq_base, num_ports[i]); + for (i = 0; i < 8; i++, chip++) gpiochip_remove(&chip->gpio); - } chip = chip_save; pci_iounmap(pdev, chip->base);