From patchwork Mon Jan 7 14:23:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13884 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4D1DA23E27 for ; Mon, 7 Jan 2013 14:24:04 +0000 (UTC) Received: from mail-vb0-f43.google.com (mail-vb0-f43.google.com [209.85.212.43]) by fiordland.canonical.com (Postfix) with ESMTP id C8CF4A185A1 for ; Mon, 7 Jan 2013 14:24:03 +0000 (UTC) Received: by mail-vb0-f43.google.com with SMTP id fs19so19669805vbb.30 for ; Mon, 07 Jan 2013 06:24:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :mime-version:content-type:x-gm-message-state; bh=u0PrTt8mqhvSDR8NqMZYYm1jlxSjsgpQ6DOFOqXtGI0=; b=Wndy1C6shx4B6X6+m8ZwA9y1iQXvsP+K2hjOCPdOQibVZfrEMC52KBf2HNpltGPzPT ooDp/3ER94YFGWll0OBYbN5+HN/rLXl/jEUki3Z48kgoqnllwxjLKo8JthcLdCWhpSm3 hvL2RGd66fXX8CjHOAy0KIl9joK5Boa6sby3Cp7QTENiSoBUA2D3H5DZreJH6M64WjDg eYPFOLcjuAozCk1+MGJEJ+FsgAZhJMOGkRiHCuf0tuX6dxXuvsNJi5lQmWPXbAM0cwyq PRP3YkR0/SY1TIRVL6nvV8av99hcXeorrayUIcZXR4AAYbw2q3LjvWMT7mGIwUrGMinI 6gZA== X-Received: by 10.220.238.139 with SMTP id ks11mr81133157vcb.49.1357568643200; Mon, 07 Jan 2013 06:24:03 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp63259veb; Mon, 7 Jan 2013 06:24:02 -0800 (PST) X-Received: by 10.14.174.198 with SMTP id x46mr165762078eel.23.1357568641992; Mon, 07 Jan 2013 06:24:01 -0800 (PST) Received: from eu1sys200aog115.obsmtp.com (eu1sys200aog115.obsmtp.com [207.126.144.139]) by mx.google.com with SMTP id l1si157182214een.73.2013.01.07.06.23.55 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 07 Jan 2013 06:24:01 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.139; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob115.postini.com ([207.126.147.11]) with SMTP ID DSNKUOrael7zJDhT9vLeCxHGgQxpMIvYBXUu@postini.com; Mon, 07 Jan 2013 14:24:01 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 9DE413E; Mon, 7 Jan 2013 14:23:06 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 3104E49; Mon, 7 Jan 2013 08:53:35 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id E5ECDA8093; Mon, 7 Jan 2013 15:23:42 +0100 (CET) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 7 Jan 2013 15:23:47 +0100 From: Linus Walleij To: , Cc: Stephen Warren , Anmar Oueja , Linus Walleij Subject: [PATCH 1/2] pinctrl/nomadik: simplify GPIO probe Date: Mon, 7 Jan 2013 15:23:45 +0100 Message-ID: <1357568625-5979-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQm2AiLOgzwXAYgJo1/Yg5u2RRNDCCPXwhc87pn08x1xrQeImgur80sN5Na5I5ArezcQA4Xh From: Linus Walleij Instead of jumping to a label later in the probe just return with an error code whenever probe() fails. Make sure to remove the gpiochip on irqdomain error now that we're at it. Signed-off-by: Linus Walleij --- drivers/pinctrl/pinctrl-nomadik.c | 52 +++++++++++++-------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c index 0355786..66cce5f 100644 --- a/drivers/pinctrl/pinctrl-nomadik.c +++ b/drivers/pinctrl/pinctrl-nomadik.c @@ -1343,8 +1343,7 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) if (of_property_read_u32(np, "gpio-bank", &dev->id)) { dev_err(&dev->dev, "gpio-bank property not found\n"); - ret = -EINVAL; - goto out; + return -EINVAL; } pdata->first_gpio = dev->id * NMK_GPIO_PER_CHIP; @@ -1352,41 +1351,29 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) } res = platform_get_resource(dev, IORESOURCE_MEM, 0); - if (!res) { - ret = -ENOENT; - goto out; - } + if (!res) + return -ENOENT; irq = platform_get_irq(dev, 0); - if (irq < 0) { - ret = irq; - goto out; - } + if (irq < 0) + return irq; secondary_irq = platform_get_irq(dev, 1); - if (secondary_irq >= 0 && !pdata->get_secondary_status) { - ret = -EINVAL; - goto out; - } + if (secondary_irq >= 0 && !pdata->get_secondary_status) + return -EINVAL; base = devm_request_and_ioremap(&dev->dev, res); - if (!base) { - ret = -ENOMEM; - goto out; - } + if (!base) + return -ENOMEM; clk = devm_clk_get(&dev->dev, NULL); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); - goto out; - } + if (IS_ERR(clk)) + return PTR_ERR(clk); clk_prepare(clk); nmk_chip = devm_kzalloc(&dev->dev, sizeof(*nmk_chip), GFP_KERNEL); - if (!nmk_chip) { - ret = -ENOMEM; - goto out; - } + if (!nmk_chip) + return -ENOMEM; /* * The virt address in nmk_chip->addr is in the nomadik register space, @@ -1420,7 +1407,7 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) ret = gpiochip_add(&nmk_chip->chip); if (ret) - goto out; + return ret; BUG_ON(nmk_chip->bank >= ARRAY_SIZE(nmk_gpio_chips)); @@ -1435,8 +1422,9 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) &nmk_gpio_irq_simple_ops, nmk_chip); if (!nmk_chip->domain) { dev_err(&dev->dev, "failed to create irqdomain\n"); - ret = -ENOSYS; - goto out; + /* Just do this, no matter if it fails */ + ret = gpiochip_remove(&nmk_chip->chip); + return -ENOSYS; } nmk_gpio_init_irq(nmk_chip); @@ -1444,12 +1432,6 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) dev_info(&dev->dev, "at address %p\n", nmk_chip->addr); return 0; - -out: - dev_err(&dev->dev, "Failure %i for GPIO %i-%i\n", ret, - pdata->first_gpio, pdata->first_gpio+31); - - return ret; } static int nmk_get_groups_cnt(struct pinctrl_dev *pctldev)