From patchwork Sun Jun 24 18:14:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10484725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F38CB603B5 for ; Sun, 24 Jun 2018 18:14:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E15BB28724 for ; Sun, 24 Jun 2018 18:14:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5F43287FF; Sun, 24 Jun 2018 18:14:42 +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=-2.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE12828724 for ; Sun, 24 Jun 2018 18:14:41 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id BE3352676E3; Sun, 24 Jun 2018 20:14:39 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 89FAC26770A; Sun, 24 Jun 2018 20:14:36 +0200 (CEST) Received: from mail-lf0-f68.google.com (mail-lf0-f68.google.com [209.85.215.68]) by alsa0.perex.cz (Postfix) with ESMTP id EB7E2267611 for ; Sun, 24 Jun 2018 20:14:33 +0200 (CEST) Received: by mail-lf0-f68.google.com with SMTP id v17-v6so5684662lfe.13 for ; Sun, 24 Jun 2018 11:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=qYdXgGdymscMzna58pIG2G67+erNmrOJHfk9CjKMqYM=; b=JqyWI1ZE8l7haJGZV4Ca2iDyvAAqAW6sYD+5W3C969vcO+daJI5gWLY6Nj6NAnx72z WlEGjJzrxqdCWEz/hKxQn2RuxhbC2ANNY7mnpWsMbKgbhwK9bPuuchhiLlwngj0F6KzS Qoq9Mt3sX6MgVEhFKCH9jqa4+Dv3dlUdgTy2Ja5g1hEXOzNuWvg7d1WbhD0+AMMhBMQj xX2QUpmfm3mLcpaade+YqOvN7meSqq0r3bizYydf5ZzHVbb44N1PaKPGoVprtQSbnmM+ AmUhluDRijHT8zWvKZqLkfduSeWeY88CRSW5Bp7/rbAYQ1BxcJEfaITdJTm6gbKuS3Ul qYwA== 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; bh=qYdXgGdymscMzna58pIG2G67+erNmrOJHfk9CjKMqYM=; b=jEBfCnb/Xw5qhXNIzxBU1pfwrprjzS4zPu4+km5PjJlk8XaioXOVWiAR5K3ko6I+oL TG3fSLv5+uwqbQraP5gOCDKzQ3Zs5fuIuLDKbqX+ByyxJf4nnHyjYOhK0+V5TReEAvVm NOIfieDMsSsESHRKFD3DPKGqwB4HIWZV1/0O57DIQZEVsPRebpyfzqQae5cs+cDZ6kbA rDYoJb++eGa3nN6xExgzXx1cfD3DaNlTCDe+dBAQrB3Icxv0XNBtEQCpUCSKCdYN5DWq Pf2J3Uy3086kCvuk7YdJdpC2rT4+M8FfNzeE7oaUwge5zz3nkCKUvktaJW5wvCwJ6AtS oXjw== X-Gm-Message-State: APt69E3oCdTJ0MSdziphTNG0nKu4AccdSTWbDsudQQGv7YIlTcmo4s68 ynDZLs+PmE19wq8dVJ2BnOk= X-Google-Smtp-Source: ADUXVKJP2cUntjeciG9Nz/+dHWcsuiDp6c8BGoixbz1X9HUcSfBRSFfnQzZrsJMLwATymihYG6igDQ== X-Received: by 2002:a19:e9d7:: with SMTP id j84-v6mr3875450lfk.115.1529864073238; Sun, 24 Jun 2018 11:14:33 -0700 (PDT) Received: from localhost.localdomain (apn-31-0-33-209.dynamic.gprs.plus.pl. [31.0.33.209]) by smtp.gmail.com with ESMTPSA id h82-v6sm2761433lfg.51.2018.06.24.11.14.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Jun 2018 11:14:32 -0700 (PDT) From: Janusz Krzysztofik To: Mark Brown , Liam Girdwood Date: Sun, 24 Jun 2018 20:14:41 +0200 Message-Id: <20180624181441.6975-1-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 Cc: alsa-devel@alsa-project.org, linux-omap@vger.kernel.org, Kuninori Morimoto , Janusz Krzysztofik , linux-kernel@vger.kernel.org, Takashi Iwai , Bhumika Goyal Subject: [alsa-devel] [PATCH] ASoC: cx20442: Don't ignore regulator_get() errors. X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP In its current shape, the driver just ignores errors returned by regulator_get() at component_probe(). This doesn't hurt on Amstrad Delta board as long as it registers the codec device at late_initcall, when the regulator which depends on basic-mmio-gpio device (probed as late as at dev_initcall) is already available. Otherwise the driver may end up trying to control a codec which is not powered up. Remove that dependency on initialization order by handling the error. If the regulator is not yet available and -ENODEV is returned, convert it to -EPROBE_DEFER to get another chance. Signed-off-by: Janusz Krzysztofik --- Created and tested on linux-4.18-rc1 sound/soc/codecs/cx20442.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c index 07dd33b09596..ab174b5114dc 100644 --- a/sound/soc/codecs/cx20442.c +++ b/sound/soc/codecs/cx20442.c @@ -362,8 +362,27 @@ static int cx20442_component_probe(struct snd_soc_component *component) return -ENOMEM; cx20442->por = regulator_get(component->dev, "POR"); - if (IS_ERR(cx20442->por)) - dev_warn(component->dev, "failed to get the regulator"); + if (IS_ERR(cx20442->por)) { + int err = PTR_ERR(cx20442->por); + + dev_warn(component->dev, "failed to get POR supply (%d)", err); + /* + * When running on a non-dt platform and requested regulator + * is not available, regulator_get() never returns + * -EPROBE_DEFER as it is not able to justify if the regulator + * may still appear later. On the other hand, the board can + * still set full constraints flag at late_initcall in order + * to instruct regulator_get() to return a dummy one if + * sufficient. Hence, if we get -ENODEV here, let's convert + * it to -EPROBE_DEFER and wait for the board to decide or + * let Deferred Probe infrastructure handle this error. + */ + if (err == -ENODEV) + err = -EPROBE_DEFER; + kfree(cx20442); + return err; + } + cx20442->tty = NULL; snd_soc_component_set_drvdata(component, cx20442);