From patchwork Wed Feb 3 20:15:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 578339 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B9EAE14031B for ; Thu, 4 Feb 2016 07:16:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=i9uRI2Ll; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932720AbcBCUQQ (ORCPT ); Wed, 3 Feb 2016 15:16:16 -0500 Received: from mail-yw0-f193.google.com ([209.85.161.193]:36269 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932456AbcBCUQP (ORCPT ); Wed, 3 Feb 2016 15:16:15 -0500 Received: by mail-yw0-f193.google.com with SMTP id b6so567901ywd.3; Wed, 03 Feb 2016 12:16:14 -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:in-reply-to:references :in-reply-to:references; bh=cV29Synr130cNjMM2KzuqeLke+hBe/TlsfspqbaApCI=; b=i9uRI2LlzzandtG839LQPMjyM/NLgmOGUJxdySEuyLSoICNL3/qRZm9eWjT/z4F37B 6Zj3m5HJzKtaULx/jQ/lYONFTWDzrtys6DozyQ2zcylHBpuQSz9i+LEuSmql6N8rf6tu ZiMLr+whiobFtEnm9eJOIHNz8j5ybb39+27R9SAUiH0Qvn3xBG5HC/oLMPmveN7sFVJk bhMs4gUNNk/oBIIgX5x/mCPTrwixIOY4g/2bpr//C8/5IE3CxHmq0+N9Y4C07cqL8pGC TwcwJhaYVJ9k1s6owyDd5CAm7u5KOXKuntltchcZmyei1GLBxW7zsGcH3syE5qo6RYYn mEMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=cV29Synr130cNjMM2KzuqeLke+hBe/TlsfspqbaApCI=; b=hM0PnzJp+9EUOqosY9X3x1O8esuJH4x3zqztdkJjX04l0WmQJXwp0v/h/wm6BJb7za ds69Mx9mTEqbayWLKaJwDV0djeypO1F6pyNBLFgPW/3Fn59hO9c10ft4E6Nmrlt1Ao7U yZ4vqZF17aRX67gST8b3mBrEnFBsuaF7XZft4hbgFgs08xZDyMo9FOnTNVKZeimNq9x7 BACk6Re31dNaoooAWEHOhWp4YTCOrIvYXIhR46PVEiYTj3kbidVtjRwXdPTGhCGvjKWo uxvemlR52xZn2QJU+7gNXIFDjaorlKBkR2xBW1fV85h9npYmi6vJ7mXvFErlqTdzm6dN cvWw== X-Gm-Message-State: AG10YOSDaBjvibjiP6rT6nlgP2+MSCN8gBkaU9PuTsOFNGcverFHA86sliHWQ/YWol3VxA== X-Received: by 10.13.238.130 with SMTP id x124mr2044404ywe.166.1454530574632; Wed, 03 Feb 2016 12:16:14 -0800 (PST) Received: from localhost (71-47-58-73.res.bhn.net. [71.47.58.73]) by smtp.gmail.com with ESMTPSA id i67sm4403178ywf.34.2016.02.03.12.16.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Feb 2016 12:16:14 -0800 (PST) From: William Breathitt Gray To: linus.walleij@linaro.org, gnurou@gmail.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/7] gpio: 104-idi-48: Use devm_request_region Date: Wed, 3 Feb 2016 15:15:22 -0500 Message-Id: <01cc31083ab67299d18425b6d9a6099479dbb549.1454530144.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.4.10 In-Reply-To: References: In-Reply-To: References: Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org By the time request_region is called in the ACCES 104-IDI-48 GPIO driver, a corresponding device structure has already been allocated. The devm_request_region function should be used to help simplify the cleanup code and reduce the possible points of failure. Signed-off-by: William Breathitt Gray Reviewed-by: Alexandre Courbot --- drivers/gpio/gpio-104-idi-48.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c index 285a075..81c98d5 100644 --- a/drivers/gpio/gpio-104-idi-48.c +++ b/drivers/gpio/gpio-104-idi-48.c @@ -39,7 +39,6 @@ MODULE_PARM_DESC(idi_48_irq, "ACCES 104-IDI-48 interrupt line number"); * @ack_lock: synchronization lock to prevent IRQ handler race conditions * @irq_mask: input bits affected by interrupts * @base: base port address of the GPIO device - * @extent: extent of port address region of the GPIO device * @irq: Interrupt line number * @cos_enb: Change-Of-State IRQ enable boundaries mask */ @@ -49,7 +48,6 @@ struct idi_48_gpio { spinlock_t ack_lock; unsigned char irq_mask[6]; unsigned base; - unsigned extent; unsigned irq; unsigned char cos_enb; }; @@ -227,11 +225,10 @@ static int __init idi_48_probe(struct platform_device *pdev) if (!idi48gpio) return -ENOMEM; - if (!request_region(base, extent, name)) { - dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n", - name, base, base + extent); - err = -EBUSY; - goto err_lock_io_port; + if (!devm_request_region(dev, base, extent, name)) { + dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", + base, base + extent); + return -EBUSY; } idi48gpio->chip.label = name; @@ -243,7 +240,6 @@ static int __init idi_48_probe(struct platform_device *pdev) idi48gpio->chip.direction_input = idi_48_gpio_direction_input; idi48gpio->chip.get = idi_48_gpio_get; idi48gpio->base = base; - idi48gpio->extent = extent; idi48gpio->irq = irq; spin_lock_init(&idi48gpio->lock); @@ -253,7 +249,7 @@ static int __init idi_48_probe(struct platform_device *pdev) err = gpiochip_add_data(&idi48gpio->chip, idi48gpio); if (err) { dev_err(dev, "GPIO registering failed (%d)\n", err); - goto err_gpio_register; + return err; } /* Disable IRQ by default */ @@ -264,24 +260,20 @@ static int __init idi_48_probe(struct platform_device *pdev) handle_edge_irq, IRQ_TYPE_NONE); if (err) { dev_err(dev, "Could not add irqchip (%d)\n", err); - goto err_gpiochip_irqchip_add; + goto err_gpiochip_remove; } err = request_irq(irq, idi_48_irq_handler, IRQF_SHARED, name, idi48gpio); if (err) { dev_err(dev, "IRQ handler registering failed (%d)\n", err); - goto err_request_irq; + goto err_gpiochip_remove; } return 0; -err_request_irq: -err_gpiochip_irqchip_add: +err_gpiochip_remove: gpiochip_remove(&idi48gpio->chip); -err_gpio_register: - release_region(base, extent); -err_lock_io_port: return err; } @@ -291,7 +283,6 @@ static int idi_48_remove(struct platform_device *pdev) free_irq(idi48gpio->irq, idi48gpio); gpiochip_remove(&idi48gpio->chip); - release_region(idi48gpio->base, idi48gpio->extent); return 0; }