From patchwork Sun Jan 13 19:57:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Chmiel?= X-Patchwork-Id: 10761403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 978C9746 for ; Sun, 13 Jan 2019 19:58:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B2A228AAE for ; Sun, 13 Jan 2019 19:58:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EC8E28AB0; Sun, 13 Jan 2019 19:58:06 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1A17F28AAE for ; Sun, 13 Jan 2019 19:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=IKPzXE7bq6YjB6cc6dhuWfvjyzGhA5aYeNdGWkptiZ4=; b=P6ka2bAXRMiF5M 8BRZWM8HKs9g+X6zBgWec2bmnY61RiL6NGBx5Nlt+MHQ7zXhGXtmYHAV5mx8odw8+NzNvRse6K4mO bU8Gu23MOFhvJGxS7/0VSbiTXJ65Ubr6h5FmFDmk0+zRspw1h+G/QMED9hRprsxiSRvga+6P57Gmg lxWHZ7R/Kco5aw7Ev76XuIY4NA0cM2lyGPVKB/BUy4aQ7ajSeHbiS34Cf+fg6q2im2bWkJJyr9i7q DtYPC9XzmCM5qETYmUeuX76VjZ4/bLx6LOX5Dx71Xu0MoK/UsGt4FKuBdi8vDKlAVpWZJrh1o2E/1 +z21HA2b7sYmjUppOs7g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1giltT-0006Gp-TB; Sun, 13 Jan 2019 19:58:03 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1giltQ-0006GR-UQ for linux-arm-kernel@lists.infradead.org; Sun, 13 Jan 2019 19:58:02 +0000 Received: by mail-lf1-x142.google.com with SMTP id c16so14165095lfj.8 for ; Sun, 13 Jan 2019 11:58:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bFXW5esP1qyBjm7dno9fSDhMNRBkGYcMnaFJwnRT22g=; b=i/Roh39YbMiqa1az+3XQH5GBrXp8Vqh+6ewCUAWo+UHSjvXIi2yUlFXdY9YNBgWYhW eiO6mYgkvpswKpd9Gs1Jai4VLsX51zNLqRmvjIADXxyvL8I6zOthzjau2g8iX86J7bl2 0jsQeWHc4dnHpBq6xVcr3UI0MVLLhgblbUH9MnMOoG3fc5QhViIEQUKvJER/HWZMSu+Y LEfzd6/F4V6SUxAzQ05bZxIjsS0LCazZRBEY20WnqBPOKToEc627sIhugXLm2J3BjmWl 8PnAwa821urEs0K/XNVGtQCb5H2L2QjyewheFgHgDQWdyBX7JQ2UgqZ1/IqGDf9DY1Ay FHnQ== 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:mime-version :content-transfer-encoding; bh=bFXW5esP1qyBjm7dno9fSDhMNRBkGYcMnaFJwnRT22g=; b=fyQt4+0Du/5jbCcggDCoCaiBJtMJfzON5rOjBcUkPYDdZawdFyzi92wqju/dMW2XiI Ohz48kaEzSePcG6+Ba9dZv82fEj8WieJyMb0bL8t9/I78OrlTjM1x7vF9nIgopY2mTSF AAAXh1pjYVKXg8vQUhQjXF8CzvrMTNAv8eTzcS3skx1ujlcGh35Ek8Jn+cAfiaIpcROo wOsY1wHaSuZO7bYygCPrGfsPBVp3yMIgOeYC/0QdZEGcoFChsEIPD7C5c/PvAQBOO89e cjnumaqFUJ5ypLZtp0K+2ijR5EuOrKpujXrsbmnWtGIonfJiYbc13Nb2p+FlxnVCSQEL f/Vw== X-Gm-Message-State: AJcUukdn8QqZa2pcsB5EpX7d1KSmwbLysjIXdoLpEDRp26jTfuwSxMVG jqqZkPSEwCYY7OS0KVb8Xk8= X-Google-Smtp-Source: ALg8bN5U+PN5/aIg1CEXUH+saRACDLlkJv34dKzI8/1IPsGyTPGNSXjpdKtSpHna2biSnNDjNe/sJw== X-Received: by 2002:a19:7d42:: with SMTP id y63mr11329886lfc.47.1547409478957; Sun, 13 Jan 2019 11:57:58 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:607a:1b80:a32f:5413]) by smtp.googlemail.com with ESMTPSA id q67sm15988569lfe.19.2019.01.13.11.57.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Jan 2019 11:57:58 -0800 (PST) From: =?utf-8?q?Pawe=C5=82_Chmiel?= To: kgene@kernel.org Subject: [PATCH v4] cpufreq: s5pv210: Defer probe if getting regulators fail Date: Sun, 13 Jan 2019 20:57:54 +0100 Message-Id: <20190113195754.30525-1-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190113_115800_983559_9AEF0489 X-CRM114-Status: GOOD ( 16.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org, viresh.kumar@linaro.org, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, krzk@kernel.org, linux-arm-kernel@lists.infradead.org, =?utf-8?q?Pawe=C5=82?= =?utf-8?q?_Chmiel?= Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP There is possibility, that when probing driver, regulators are not yet initialized. In this case we should return EPROBE_DEFER and wait till they're initialized, since they're required currently for cpufreq driver to work. Also move regulator initialization code at beginning of probe, so we can defer as fast as posibble. Signed-off-by: Paweł Chmiel Reviewed-by: Krzysztof Kozlowski --- Changes from v3: - Zero dmc_base pointers after unmapping them - If getting vddarm regulator fails just return, no need to do goto jump which would do the same Changes from v2: - Handle all error paths in probe Changes from v1: - Fix compilation error - Reorganize code so it's smaller --- drivers/cpufreq/s5pv210-cpufreq.c | 67 ++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c index f51697f1e0b3..c7b7d1e65b08 100644 --- a/drivers/cpufreq/s5pv210-cpufreq.c +++ b/drivers/cpufreq/s5pv210-cpufreq.c @@ -584,7 +584,7 @@ static struct notifier_block s5pv210_cpufreq_reboot_notifier = { static int s5pv210_cpufreq_probe(struct platform_device *pdev) { struct device_node *np; - int id; + int id, result = 0; /* * HACK: This is a temporary workaround to get access to clock @@ -594,18 +594,39 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev) * this whole driver as soon as S5PV210 gets migrated to use * cpufreq-dt driver. */ + arm_regulator = regulator_get(NULL, "vddarm"); + if (IS_ERR(arm_regulator)) { + if (PTR_ERR(arm_regulator) == -EPROBE_DEFER) + pr_debug("vddarm regulator not ready, defer\n"); + else + pr_err("failed to get regulator vddarm\n"); + return PTR_ERR(arm_regulator); + } + + int_regulator = regulator_get(NULL, "vddint"); + if (IS_ERR(int_regulator)) { + if (PTR_ERR(int_regulator) == -EPROBE_DEFER) + pr_debug("vddint regulator not ready, defer\n"); + else + pr_err("failed to get regulator vddint\n"); + result = PTR_ERR(int_regulator); + goto err_int_regulator; + } + np = of_find_compatible_node(NULL, NULL, "samsung,s5pv210-clock"); if (!np) { pr_err("%s: failed to find clock controller DT node\n", __func__); - return -ENODEV; + result = -ENODEV; + goto err_clock; } clk_base = of_iomap(np, 0); of_node_put(np); if (!clk_base) { pr_err("%s: failed to map clock registers\n", __func__); - return -EFAULT; + result = -EFAULT; + goto err_clock; } for_each_compatible_node(np, NULL, "samsung,s5pv210-dmc") { @@ -614,7 +635,8 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev) pr_err("%s: failed to get alias of dmc node '%pOFn'\n", __func__, np); of_node_put(np); - return id; + result = id; + goto err_clk_base; } dmc_base[id] = of_iomap(np, 0); @@ -622,33 +644,40 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev) pr_err("%s: failed to map dmc%d registers\n", __func__, id); of_node_put(np); - return -EFAULT; + result = -EFAULT; + goto err_dmc; } } for (id = 0; id < ARRAY_SIZE(dmc_base); ++id) { if (!dmc_base[id]) { pr_err("%s: failed to find dmc%d node\n", __func__, id); - return -ENODEV; + result = -ENODEV; + goto err_dmc; } } - arm_regulator = regulator_get(NULL, "vddarm"); - if (IS_ERR(arm_regulator)) { - pr_err("failed to get regulator vddarm\n"); - return PTR_ERR(arm_regulator); - } - - int_regulator = regulator_get(NULL, "vddint"); - if (IS_ERR(int_regulator)) { - pr_err("failed to get regulator vddint\n"); - regulator_put(arm_regulator); - return PTR_ERR(int_regulator); - } - register_reboot_notifier(&s5pv210_cpufreq_reboot_notifier); return cpufreq_register_driver(&s5pv210_driver); + +err_dmc: + for (id = 0; id < ARRAY_SIZE(dmc_base); ++id) + if (dmc_base[id]) { + iounmap(dmc_base[id]); + dmc_base[id] = NULL; + } + +err_clk_base: + iounmap(clk_base); + +err_clock: + regulator_put(int_regulator); + +err_int_regulator: + regulator_put(arm_regulator); + + return result; } static struct platform_driver s5pv210_cpufreq_platdrv = {