From patchwork Wed Apr 9 11:48:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 28081 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D709D202DD for ; Wed, 9 Apr 2014 11:48:59 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id c1sf6365262igq.10 for ; Wed, 09 Apr 2014 04:48:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=+7b2NauT/KHNDETDeRZF9J2IPbNfIlt5Su+B+rKbz+Q=; b=gSKjEoAZPQXtFP4bU3ESUWo43o7zrDOYp4ZO2qkQkYizvTqPMMZ3RDeZiQxSrxBNJR x0P4ruZp+OQVVX7nP6ZdeVoJgE1qkpoewOTOemAZ3ZQkq6aC2lWkzuezpj3FHZWp4jZj TsbrOEUP8e9/qVJ0HzLcW6qguFdA0Oxd3Z7LkxgJwADuDGeDx/fsEEUhEkkElHGZaYrn P+x2PIJtmN14mYwH5YCgEhe71wsipi3a5HR7F1ngf6cADoNBvhyP7qkwV1Fm+/WBP4wY jWUnrDdA/QfGQivRHAaGCM8JiAIADDjkOFydpEBouUMjgygCbQgrAp6WG+UL7azyDrLR zLTg== X-Gm-Message-State: ALoCoQmqMKiC9vdXORLeFvLr3evZ6K0g45tdGzwb+USbUWp5hN21dDZwyAmlaWM9CKpTJA5D4Vdr X-Received: by 10.182.60.37 with SMTP id e5mr4706061obr.30.1397044139076; Wed, 09 Apr 2014 04:48:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.46.33 with SMTP id j30ls596372qga.67.gmail; Wed, 09 Apr 2014 04:48:58 -0700 (PDT) X-Received: by 10.220.237.146 with SMTP id ko18mr85691vcb.49.1397044138881; Wed, 09 Apr 2014 04:48:58 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id sn5si95187vdc.101.2014.04.09.04.48.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Apr 2014 04:48:58 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jw12so2022268veb.9 for ; Wed, 09 Apr 2014 04:48:58 -0700 (PDT) X-Received: by 10.52.51.197 with SMTP id m5mr7137586vdo.9.1397044138799; Wed, 09 Apr 2014 04:48:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp322856vcv; Wed, 9 Apr 2014 04:48:58 -0700 (PDT) X-Received: by 10.67.14.231 with SMTP id fj7mr11257681pad.115.1397044137967; Wed, 09 Apr 2014 04:48:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bs8si380087pad.53.2014.04.09.04.48.57; Wed, 09 Apr 2014 04:48:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932589AbaDILs5 (ORCPT + 1 other); Wed, 9 Apr 2014 07:48:57 -0400 Received: from mail-wg0-f45.google.com ([74.125.82.45]:35029 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932482AbaDILs4 (ORCPT ); Wed, 9 Apr 2014 07:48:56 -0400 Received: by mail-wg0-f45.google.com with SMTP id l18so2315781wgh.28 for ; Wed, 09 Apr 2014 04:48:55 -0700 (PDT) X-Received: by 10.180.10.66 with SMTP id g2mr36785756wib.5.1397044135604; Wed, 09 Apr 2014 04:48:55 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id di9sm3890388wid.6.2014.04.09.04.48.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Apr 2014 04:48:54 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Alexandre Courbot , Linus Walleij Subject: [PATCH 2/4] gpio: tc3589x: use managed resources Date: Wed, 9 Apr 2014 13:48:51 +0200 Message-Id: <1397044131-19262-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-gpio@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Grab state container and irq using the devm_* functions and save some lines of hairy clean-up code. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tc3589x.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c index 1019320984d7..113e50cb1f59 100644 --- a/drivers/gpio/gpio-tc3589x.c +++ b/drivers/gpio/gpio-tc3589x.c @@ -329,7 +329,8 @@ static int tc3589x_gpio_probe(struct platform_device *pdev) if (irq < 0) return irq; - tc3589x_gpio = kzalloc(sizeof(struct tc3589x_gpio), GFP_KERNEL); + tc3589x_gpio = devm_kzalloc(&pdev->dev, sizeof(struct tc3589x_gpio), + GFP_KERNEL); if (!tc3589x_gpio) return -ENOMEM; @@ -354,23 +355,25 @@ static int tc3589x_gpio_probe(struct platform_device *pdev) ret = tc3589x_set_bits(tc3589x, TC3589x_RSTCTRL, TC3589x_RSTCTRL_GPIRST, 0); if (ret < 0) - goto out_free; + return ret; ret = tc3589x_gpio_irq_init(tc3589x_gpio, np); if (ret) - goto out_free; + return ret; - ret = request_threaded_irq(irq, NULL, tc3589x_gpio_irq, IRQF_ONESHOT, - "tc3589x-gpio", tc3589x_gpio); + ret = devm_request_threaded_irq(&pdev->dev, + irq, NULL, tc3589x_gpio_irq, + IRQF_ONESHOT, "tc3589x-gpio", + tc3589x_gpio); if (ret) { dev_err(&pdev->dev, "unable to get irq: %d\n", ret); - goto out_free; + return ret; } ret = gpiochip_add(&tc3589x_gpio->chip); if (ret) { dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); - goto out_freeirq; + return ret; } if (pdata && pdata->setup) @@ -379,12 +382,6 @@ static int tc3589x_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, tc3589x_gpio); return 0; - -out_freeirq: - free_irq(irq, tc3589x_gpio); -out_free: - kfree(tc3589x_gpio); - return ret; } static int tc3589x_gpio_remove(struct platform_device *pdev) @@ -392,7 +389,6 @@ static int tc3589x_gpio_remove(struct platform_device *pdev) struct tc3589x_gpio *tc3589x_gpio = platform_get_drvdata(pdev); struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; struct tc3589x_gpio_platform_data *pdata = tc3589x->pdata->gpio; - int irq = platform_get_irq(pdev, 0); int ret; if (pdata && pdata->remove) @@ -405,10 +401,6 @@ static int tc3589x_gpio_remove(struct platform_device *pdev) return ret; } - free_irq(irq, tc3589x_gpio); - - kfree(tc3589x_gpio); - return 0; }