From patchwork Thu Dec 10 11:10:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 7818241 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 27D34BEEE1 for ; Thu, 10 Dec 2015 11:12:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4AF64205B3 for ; Thu, 10 Dec 2015 11:12:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E216205AA for ; Thu, 10 Dec 2015 11:12:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a6z7X-0006CT-Fq; Thu, 10 Dec 2015 11:10:47 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a6z7T-0005wO-W9 for linux-arm-kernel@lists.infradead.org; Thu, 10 Dec 2015 11:10:44 +0000 Received: by wmww144 with SMTP id w144so19715445wmw.0 for ; Thu, 10 Dec 2015 03:10:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=JlDskNwHiqthrQxURoxnKQc1lR8E6IHi6CW/lPc0MXg=; b=oIQxPeQlVrzoAJjPdfL4f13z4Oo6vteu7lh1TPlAZKY8kQDldUFIg3az72Qs9mDX1A obxGP2IwIlhkLcJyPfGwzMDMmb10ov2KVu0KbX35AJ3FNhsWoLqu7ggCt/It69BgPW93 7A3ziRoCOZLLfVQe0fBJWdwTD0Rk/dT28T2xpO5nHG5nOZfkCMRivZuh9D/QFQNSZChR OQgyRf1NO/ihOq6g621PAs0NqPRzmY+iwlbTwgvpG6w6RRtTzgfhiflTIsxS+QUFSdXs KiQpalbbCfWw29ZMyXT2cBTEXtJIO2270TdyF9XV+ZR+hIBNsWhHwmmt+rmpId9OGVoc rfhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=JlDskNwHiqthrQxURoxnKQc1lR8E6IHi6CW/lPc0MXg=; b=KyIK9LpCsjGuq8bCVI/pLxl1L/KqN61Mf98764w5twb5Hv8tfxPtXhoCHzEvcEvCky JGdiFDYfLK8/cbt3YD4HfvCodxvnwKQN9X/TihBF3b4HJoCw2QXwd2oBzt02myh21x4m XcOIqoKPWACoeyrXEa8zgkWTTnIMl2ccBXdQsLnvtY99zLwOes/LauOBU/GwoIysMkCt ibiJpvsKdeenn2Nx2xeVl/F1ijl2Y8Wzf6r9u84ZUMbXCiTcUA8k8xaIF1Qhx/kWu96R fPNHvVHAyD2NQYcKjBD6eXiQ+5ALnVOvVx6QZNb+nK1Px7vjbM50LYXPMqMhWbZcWhlT Hg3g== X-Gm-Message-State: ALoCoQmwizZBn3MV1aYmkCsopdKM8KRpZoFLQQ7lxhifX/6ESPHnm5LEztao8aeLHUZpgQhSmj+wltcTKlj4WFujCdvFlo6bsA== X-Received: by 10.28.232.136 with SMTP id f8mr43394415wmi.1.1449745821943; Thu, 10 Dec 2015 03:10:21 -0800 (PST) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id c194sm12339001wmd.13.2015.12.10.03.10.20 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 10 Dec 2015 03:10:20 -0800 (PST) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Subject: [PATCH] gpio: zynq: Do PM initialization earlier to support gpio hogs Date: Thu, 10 Dec 2015 12:10:12 +0100 Message-Id: X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151210_031044_222899_A2C208F4 X-CRM114-Status: GOOD ( 14.65 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Courbot , Peter Crosthwaite , Josh Cartwright , Linus Walleij , linux-gpio@vger.kernel.org, Rob Herring , linux-arm-kernel@lists.infradead.org, Steffen Trumtrar , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 GPIO hogs registration is call at the end of gpiochip_add() function. Calling sequence is: gpiochip_add -> of_gpiochip_add -> of_gpiochip_scan_hogs -> gpiod_hog -> gpiochip_request_own_desc -> __gpiod_request -> chip->request -> zynq_gpio_request which calls pm_runtime_get_sync() which returns -13 because PM is not initialized yet. Initialize PM before gpiochip_add is called to fix this issue. Signed-off-by: Michal Simek Signed-off-by: Soren Brinkmann --- drivers/gpio/gpio-zynq.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c index 00306e70a420..a0cabd17c9d0 100644 --- a/drivers/gpio/gpio-zynq.c +++ b/drivers/gpio/gpio-zynq.c @@ -710,23 +710,23 @@ static int zynq_gpio_probe(struct platform_device *pdev) chip->base = -1; chip->ngpio = gpio->p_data->ngpio; - /* Enable GPIO clock */ + /* Retrieve GPIO clock */ gpio->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(gpio->clk)) { dev_err(&pdev->dev, "input clock not found.\n"); return PTR_ERR(gpio->clk); } - ret = clk_prepare_enable(gpio->clk); - if (ret) { - dev_err(&pdev->dev, "Unable to enable clock.\n"); + + pm_runtime_enable(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); + if (ret < 0) return ret; - } /* report a bug if gpio chip registration fails */ ret = gpiochip_add(chip); if (ret) { dev_err(&pdev->dev, "Failed to add gpio chip\n"); - goto err_disable_clk; + goto err_pm_put; } /* disable interrupts for all banks */ @@ -744,15 +744,14 @@ static int zynq_gpio_probe(struct platform_device *pdev) gpiochip_set_chained_irqchip(chip, &zynq_gpio_edge_irqchip, gpio->irq, zynq_gpio_irqhandler); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); + pm_runtime_put(&pdev->dev); return 0; err_rm_gpiochip: gpiochip_remove(chip); -err_disable_clk: - clk_disable_unprepare(gpio->clk); +err_pm_put: + pm_runtime_put(&pdev->dev); return ret; }