From patchwork Thu Jan 10 20:52:14 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: 10756865 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 748BB91E for ; Thu, 10 Jan 2019 20:54:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62E132785D for ; Thu, 10 Jan 2019 20:54:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56C7127EED; Thu, 10 Jan 2019 20:54:10 +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 068B42785D for ; Thu, 10 Jan 2019 20:54:09 +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:References:In-Reply-To: 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: List-Owner; bh=yDwpZRNMo3f25v57MQFa0STy954w/ltDURgWn3ybj50=; b=iURo+ITYRua+pC 00k1A3hYyfDhgrs0gL6BCIFtFyQAiUr3jylFBZFix82YDys2xHXW915SfNCkGFDw4YDhMtu8d715s 4+77bQ2OAM6dDwCgSolva21FWQLO2NVt8iNPjpG2QtqxaSl1LnD8fpPlxsfaoj2qTBkOxdhElOuSf e4UP7+BdKDtKMyfyskaLCMA7s6FSfPOBzqewwYLfIQ+WVQxyut1ff3ipOJKExN7yAJ8uy3W2Cd1s8 v5nAa1/5u1O1wmFH4Mrlr4SWysiwzlR9KRwKfvf2Sg1whmV/vASZzDik+Bo8SA3x6G5ZY+bZhmkCM UO2BEvyYSAIYPrQ0doVw==; 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 1ghhL3-0002YJ-JF; Thu, 10 Jan 2019 20:54:05 +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 1ghhKI-0001nF-8x for linux-arm-kernel@lists.infradead.org; Thu, 10 Jan 2019 20:53:21 +0000 Received: by mail-lf1-x142.google.com with SMTP id a16so9310932lfg.3 for ; Thu, 10 Jan 2019 12:53:18 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=pV8kbDyRB/8qZ90lJTc0lEk+FaV2Ra/kqeVF/E8Hnfk=; b=Htf7k0ExehzCaF3zhHh1dRJbDHstaIkx5+nKHbbc/ILqAjuqaUwe3koIB3cNj44gz2 ZwF0a1qw6466nImj6AWCNYVaJdU0eXFGt6hVW2tW/n6Db5HoOaqLFVTWnulK4rMHo6Q8 saKPC9Pv/qlO+joFcR3ASl0LCqDVgoAWDWRhxz8JScyXXxDt5zQbW4LkHBbKBTfSRfam S2rH4mnhsuT5xDuyvYWeSvpj2VL23FZunTRa6t18CsuqH2gu/7q/Igb53u9n5Cqmrj0Y EP5sYVhOQ2c1w4Gwji6GfVl/y+MJwSuyCwubB7fzG44E5g3khbFVV9PhOr6Ab/gnxmvU aybw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=pV8kbDyRB/8qZ90lJTc0lEk+FaV2Ra/kqeVF/E8Hnfk=; b=eXsscKEPFB41p7FTPFG73fUbK+FbV/PeR7d74P/0ox/92D/PqGrmnrLO8+xDESyfFE eL5GHKwPLS6vJMJK3MwQ55w+9oACVnVEI7OcpkZrk2XSqZZ250TW7iZub0XMFPsk5INz IKhDR432PNhaFEwTsaNpiV4NubAFE4a36suf/l569YaF05xChm1dMo+pka500YODTutp PA26oGxzTOiXVQCQegtZX1wx71SuwBuEpl69AVFqQ1YCQkDM+nkddVyMYuj4Wdv2S0yP DVb3mdkRAMEBu5nclBCPACMbsos5hTRSQGC3rAvfK/H/MV9R4LTJIbzH4N4jA/QW4mXA fOlg== X-Gm-Message-State: AJcUukennKvbADvg15JImdiBPuE2bxS5lfHEOSmW3d1Z7r8836QL5RkU cQJFm+0JBZD1URSY2j969Sw= X-Google-Smtp-Source: ALg8bN5+qL67TTptupCRMWOWMH6hxida6ZissbV6ggdz+24+VlshN7ushnka9oUaZ9ltQc93hn1ACg== X-Received: by 2002:a19:d5:: with SMTP id 204mr6311233lfa.116.1547153596596; Thu, 10 Jan 2019 12:53:16 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:5dc1:592c:c674:2869]) by smtp.googlemail.com with ESMTPSA id z7-v6sm15389690lji.42.2019.01.10.12.53.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 12:53:16 -0800 (PST) From: =?utf-8?q?Pawe=C5=82_Chmiel?= To: kgene@kernel.org Subject: [PATCH v2 3/4] cpufreq: s5pv210: Defer probe if getting regulators fail Date: Thu, 10 Jan 2019 21:52:14 +0100 Message-Id: <20190110205215.22030-4-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110205215.22030-1-pawel.mikolaj.chmiel@gmail.com> References: <20190110205215.22030-1-pawel.mikolaj.chmiel@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190110_125318_641293_13C70B2C X-CRM114-Status: GOOD ( 15.38 ) 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: mark.rutland@arm.com, devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org, viresh.kumar@linaro.org, rjw@rjwysocki.net, linux@armlinux.org.uk, krzk@kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, =?utf-8?q?Pawe=C5=82_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 --- Changes from v1: - Fix compilation error - Reorganize code so it's smaller --- drivers/cpufreq/s5pv210-cpufreq.c | 32 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c index f51697f1e0b3..6df95941ba96 100644 --- a/drivers/cpufreq/s5pv210-cpufreq.c +++ b/drivers/cpufreq/s5pv210-cpufreq.c @@ -594,6 +594,25 @@ 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"); + regulator_put(arm_regulator); + return PTR_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", @@ -633,19 +652,6 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev) } } - 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);