From patchwork Sun Oct 18 11:23:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 7429831 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7523E9F37F for ; Sun, 18 Oct 2015 11:26:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B5DB20709 for ; Sun, 18 Oct 2015 11:26:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4BA1620700 for ; Sun, 18 Oct 2015 11:26:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752382AbbJRL0v (ORCPT ); Sun, 18 Oct 2015 07:26:51 -0400 Received: from mout.web.de ([212.227.17.11]:54393 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752356AbbJRL0v (ORCPT ); Sun, 18 Oct 2015 07:26:51 -0400 Received: from [192.168.178.85] ([91.50.218.222]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0LgpJ4-1aJ2iM1xFm-00oDI4; Sun, 18 Oct 2015 13:26:48 +0200 From: Heiner Kallweit Subject: [PATCH 2/2] cpufreq: imx: fix regulator_get_optional error handling To: "Rafael J. Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org Message-ID: <56238131.7010907@web.de> Date: Sun, 18 Oct 2015 13:23:29 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:JIsdWlRbIM7j1U9Zg4MSyU0uXrN/4qbOs+90clxM7P5wBNOChV/ pQLtVh09buP8wGgnAIGYlEv89De5c0ql6lz83jvB33oqxvav23lMh3yUFaE25/Q07VXlAlr hY0rVjYT73kwQh+/vd72catVBp9X1lBMLGxMVySt7Pxv8aPxJLJ5E8WzwaYB4zojMxY1YJA zt/aof1UKnkjl/8dFxBHw== X-UI-Out-Filterresults: notjunk:1; V01:K0:1ZxLrfHsbDQ=:h/lMeXKZsyDR1LHzipJWN9 km1zvn6dJeFVdJlB+zsfM8iqphmbwjpmlWG/xRdWALc0WaB4Zw/VGcp1EmypivfHa7mIGVIMU ad4Yxyj3MK3oFKbdi8bLaMhckgojiRBR/LNV1L8NA7gSzPZdpZjOa0mQi80S3Fylpzffq4Dna hlb3LX+3UZB0GkRrKPN6IFq23CaMvotff6JeLzrOZC12HSt5HjWEybmflwTWXqXF0DE9FBESI KCdggckUWLoHFZqInH5uJP81Z6eCIW9RB91y0Adrh7CqLI0KZUNW5fLfg49W6sO3/UNk2k8vf KFAr/9ARCWdU/8J8c8df5mhaoazZ9O6v+7DlPqYWGFKyRbAtRHC2oHzyBcwLf6EGg6RBM6pZ6 b16fIv5+u3Sb9VbzU9yueRX2s7OWBI5VGEvUH+I0HEVVFojx8peYoK6PxpTBdcR5G982NBiDQ LzSM5vmCTv165Mqurf0jn2iMKov1FKeqwwfxXQCe13RfnkB9oRlivSusGHzaghIJkRMmGUm1t aiupdPVfdmW3Q/fqPnP5c3WThZwdcR5NKy8fQNeIMwdUR+6BMXZaXGIl+yHjkWh6knGX4xgTS DgHr1iu7Q3eoMW8ktThiQUSMT5ugV04l4eMT2uBtHQAeYNcCRS39vuFyeyOqXI51c7OLW8Zb5 QQGbEQpmfUwz5V+PlR38zRWa8QkJjM/BR1m7bRj1UreNzQbf3obP97Ru+t5Y9jHACEZ/zeyjv LbF8zGXTZS7GYZ+F3MDTEOqdBP7U5eS7NwiOg4oXY9bETr/TwkhSxVTMq4wRMwHzTPVPHoj+v Ws+s4fM Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 Properly handle the case that regulator_get_optional returns -EPROBE_DEFER and ignore other errors. Signed-off-by: Heiner Kallweit --- drivers/cpufreq/imx6q-cpufreq.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 0bb33dc..67dc81c 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -67,7 +67,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) /* scaling up? scale voltage before frequency */ if (new_freq > old_freq) { - if (!IS_ERR(pu_reg)) { + if (pu_reg) { ret = regulator_set_voltage_tol(pu_reg, imx6_soc_volt[index], 0); if (ret) { dev_err(cpu_dev, "failed to scale vddpu up: %d\n", ret); @@ -124,7 +124,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) dev_warn(cpu_dev, "failed to scale vddsoc down: %d\n", ret); ret = 0; } - if (!IS_ERR(pu_reg)) { + if (pu_reg) { ret = regulator_set_voltage_tol(pu_reg, imx6_soc_volt[index], 0); if (ret) { dev_warn(cpu_dev, "failed to scale vddpu down: %d\n", ret); @@ -195,6 +195,13 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) } pu_reg = regulator_get_optional(cpu_dev, "pu"); + if (IS_ERR(pu_reg)) { + if (PTR_ERR(pu_reg) == -EPROBE_DEFER) { + ret = -EPROBE_DEFER; + goto put_reg; + } else + pu_reg = NULL; + } soc_reg = regulator_get(cpu_dev, "soc"); if (IS_ERR(soc_reg)) { @@ -285,7 +292,7 @@ soc_opp_out: ret = regulator_set_voltage_time(soc_reg, imx6_soc_volt[0], imx6_soc_volt[num - 1]); if (ret > 0) transition_latency += ret * 1000; - if (!IS_ERR(pu_reg)) { + if (pu_reg) { ret = regulator_set_voltage_time(pu_reg, imx6_soc_volt[0], imx6_soc_volt[num - 1]); if (ret > 0) transition_latency += ret * 1000; @@ -325,7 +332,7 @@ out_free_opp: put_reg: if (!IS_ERR(arm_reg)) regulator_put(arm_reg); - if (!IS_ERR(pu_reg)) + if (!IS_ERR_OR_NULL(pu_reg)) regulator_put(pu_reg); if (!IS_ERR(soc_reg)) regulator_put(soc_reg); @@ -351,7 +358,7 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev) if (free_opp) of_free_opp_table(cpu_dev); regulator_put(arm_reg); - if (!IS_ERR(pu_reg)) + if (pu_reg) regulator_put(pu_reg); regulator_put(soc_reg); clk_put(arm_clk);