From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7A3BC04FF3 for ; Mon, 24 May 2021 22:09:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FB1961425 for ; Mon, 24 May 2021 22:09:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FB1961425 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dgl+D76l2sCUh/vKr0S0LLEwD5QGwIpaioec4bKUUMA=; b=c4aTlL/rMzC11n kk+wOL3oY6qO6ukQTEjZZnMnp7LxJXphtCZHLdZZRtB99qbiVh+bdr81pcN+tWIunNgI8n2jTefdQ 2rssSfEsA5Kv/LttQKSTFulH4qlBZv0EuzinZDuvq4SMDCtkAWwpQaaKiU219b/I/uLwTk3zKqYdF ZPbg6xgRFHctsSOtl4Y7MLmKUZiRRxgaHRSNm5R9pKdfuxizEeibQdN5F2CroazVR/K51GoYXS50u Hc64NrMQqhAh17k0xSrL1nIYuSLmecucTim/lVO+iCXP4BJfexeRReW+9BqqWXUSCqS5qiuVuY3oZ O4cyNkSGK7BxibCiJilw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1llIjN-0023IH-Aa; Mon, 24 May 2021 22:07:26 +0000 Received: from mail-ua1-x92d.google.com ([2607:f8b0:4864:20::92d]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1llB8E-000yMK-Vp for linux-arm-kernel@lists.infradead.org; Mon, 24 May 2021 14:00:36 +0000 Received: by mail-ua1-x92d.google.com with SMTP id x1so8842883uau.1 for ; Mon, 24 May 2021 07:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bhZvYF2rrfsZa6Xf7+GPLv45uKVXrZPOlQNANCKECQI=; b=QFwnDovX8FbineGyWDzBEnowUBB99r0szO6EctLouJ+VM2LiCGRhsvhsWGG63bQ38u L8737OQdQqtbmzB2DOFHbAMHFz4mbgFynB6Hr6LEPzS2NlZebCoksFMUbpIrF5cEwx7B T/9TaMS4c84GbC8mE2fvp1gao9RKc70VhhCRbiSPgOwHjT4x4MyLQ3y1AeJYjQvkEDI3 hTtFD7vvnj9PNncgtHBXpOzlA5KQG9P4JKmzwSe61ZYFSHnEWhrel6yZkKW/kbqSnTbg QZOdLzAcRz1zB3xj9RzYvlmwEpHqCOREpVzye076+kpjJ8eDCQmKr6UsQZJa1pqzWEHI lPEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bhZvYF2rrfsZa6Xf7+GPLv45uKVXrZPOlQNANCKECQI=; b=h+b+E0JWZiZ//dZ6Ond99hwsGdSzyNzIfLV7Ne5a9mIyML2Of9xfwpkq/MN6C8RU6e FU3KKLhBs7KTYgIccxOcssMXzWPbIcrUBXD2pgGVF22+21wPSAnKm7Q0MHzAeVZtn6sO I3ggBYql2VVIVTT3hLEATep8/7RuzyNDiQFxq8ibM936MocnD4vztOTW3tArhRSFXIBP 0knpWMfuP4lrLxABnJSou7cdO8MwmPy6n0vrYzt8Nb7ZOTByqPAbSpQ2mn/V986hf2PJ itzUdZ/PJuldzc80uet5GNWNVzDQUX2MuTAzet2b7kkfIBFrXGEXbERSqdKarEWnSQgU GjVQ== X-Gm-Message-State: AOAM531WBh2SDLGcnEraoMF1k4Qhg9CeS61/JeiQgzkk5jt1QBTJ4N05 Cbv93KkamCjFlRYEVbkm6fjj85MTQ/0oT2l8g+avUg== X-Google-Smtp-Source: ABdhPJyTkuNIXW/4VTeu46rTAPJNrdcFFBw/FDfMkyZ8gV3dDP2TWej1nRS1wo4Y1zZF3ITB+QVUCzn16nazwshQD3Y= X-Received: by 2002:a9f:24b4:: with SMTP id 49mr12816796uar.100.1621864832999; Mon, 24 May 2021 07:00:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ulf Hansson Date: Mon, 24 May 2021 15:59:56 +0200 Message-ID: Subject: Re: [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed To: Christophe JAILLET Cc: Shawn Guo , Sascha Hauer , Sascha Hauer , Fabio Estevam , dl-linux-imx , Wolfram Sang , Doug Anderson , Rui Miguel Silva , Chris Ball , Linux ARM , linux-mmc , Linux Kernel Mailing List , kernel-janitors@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210524_070035_055127_A5EA215F X-CRM114-Status: GOOD ( 21.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 21 May 2021 at 14:36, Christophe JAILLET wrote: > > The 'reg_vmmc' regulator is never disabled. Neither in the error handling > of the probe, nor in the remove function. > > Add a managed action to do the required clean-up before a 'regulator_put()' > call. > > Fixes: 4dc5a79f1350 ("mmc: mxs-mmc: enable regulator for mmc slot") > Signed-off-by: Christophe JAILLET > --- > drivers/mmc/host/mxs-mmc.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c > index 947581de7860..b043d53dd728 100644 > --- a/drivers/mmc/host/mxs-mmc.c > +++ b/drivers/mmc/host/mxs-mmc.c > @@ -552,6 +552,13 @@ static const struct of_device_id mxs_mmc_dt_ids[] = { > }; > MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids); > > +static void regulator_disable_action(void *_data) > +{ > + struct regulator *regulator = _data; > + > + regulator_disable(regulator); > +} > + > static int mxs_mmc_probe(struct platform_device *pdev) > { > struct device_node *np = pdev->dev.of_node; > @@ -591,6 +598,10 @@ static int mxs_mmc_probe(struct platform_device *pdev) > "Failed to enable vmmc regulator: %d\n", ret); > goto out_mmc_free; > } > + ret = devm_add_action_or_reset(&pdev->dev, > + regulator_disable_action, reg_vmmc); > + if (ret) > + goto out_mmc_free; Even if this improves the behaviour, there is a standardized way for how we deal with regulators for mmc. 1. Call mmc_regulator_get_supply() during probe to fetch the optional regulator. If a regulator is found a corresponding OCR mask, in host->ocr_avail is assigned. 2. In the ->set_ios() callback, invoke mmc_regulator_set_ocr(). This will also set the correct voltage-level and turn on/off the regulator, depending on the requested OCR/voltage-level. > } > > ssp->clk = devm_clk_get(&pdev->dev, NULL); > -- > 2.30.2 > Kind regards Uffe _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel