From patchwork Tue Jul 3 14:18:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 1151151 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 3DCF7DFF72 for ; Tue, 3 Jul 2012 14:22:43 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Sm3vR-0000rx-7y; Tue, 03 Jul 2012 14:17:57 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Sm3vM-0000rj-7L for linux-arm-kernel@lists.infradead.org; Tue, 03 Jul 2012 14:17:52 +0000 Received: by pbbrq13 with SMTP id rq13so10502670pbb.36 for ; Tue, 03 Jul 2012 07:17:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent :x-gm-message-state; bh=PxgPDRd+2vdWhbV9mFhJbw0/sDRBk7VDhybexlxLOlo=; b=SpjilpbC8oOnC5SmLF1VM9zrtFb+UjYHG+Pqn9EfIsQ7WJEDNuKay8+DeEcuNpQFoY e0onWCzU9okyNbbO0qPTcGappEKfMPTUXB1PNP5CXgaQ7oPwCSZkPW/vvYx6yRhobXUk BNQtftPLHqZHfGv1Z7vncglYEgFYOlp5cC6Vj4vUdfpiStKM1pVfVpCP9BEwTMyiIEU1 waWwSCoQSHR385jZcAutYS2Ej1sl5pWWbqam52jACJ19Kjnv6B0zwfwH18fxBQbV3yr5 CJQhaIX+Su5OkxpUdUDJr5IqYVkrZNrv+D+ECt32JJvixcb3Qv1nmyVjAEezw/hnXcOz 6q5g== Received: by 10.68.238.166 with SMTP id vl6mr7468313pbc.96.1341325068776; Tue, 03 Jul 2012 07:17:48 -0700 (PDT) Received: from S2101-09.ap.freescale.net ([114.216.233.161]) by mx.google.com with ESMTPS id pn5sm15644385pbb.74.2012.07.03.07.17.43 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jul 2012 07:17:47 -0700 (PDT) Date: Tue, 3 Jul 2012 22:18:31 +0800 From: Shawn Guo To: Mark Brown Subject: Re: [PATCH] can: flexcan: add a regulator for transceiver Message-ID: <20120703141829.GG22705@S2101-09.ap.freescale.net> References: <1341319571-27763-1-git-send-email-shawn.guo@linaro.org> <20120703130747.GD25995@sirena.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120703130747.GD25995@sirena.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQlGGK5Ckf/2vh4OxHjF7yIpz29E6OJuVgmeaN6sTLJ0iSxJ/9Bjjge48H3wgCgHS217AJJG X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Marc Kleine-Budde , linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On Tue, Jul 03, 2012 at 02:07:47PM +0100, Mark Brown wrote: > On Tue, Jul 03, 2012 at 08:46:11PM +0800, Shawn Guo wrote: > > > + if (priv->reg_xcvr) { > > + if (on) > > + regulator_enable(priv->reg_xcvr); > > + else > > + regulator_disable(priv->reg_xcvr); > > + } > > No, the regulator API will stub itself out if not enabled, and if the > supply is fixed then a fixed voltage regulator will do the job. We > shouldn't be open coding this stuff in individual users. Ah, yes. But when you say "a fixed voltage regulator", you actually meant dummy regulator, right? So the patch will becomes the following. Regards, Shawn ---8<---- diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 81d4741..c521aa4 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -36,6 +36,7 @@ #include #include #include +#include #define DRV_NAME "flexcan" @@ -179,6 +180,7 @@ struct flexcan_priv { u32 reg_ctrl_default; struct clk *clk; + struct regulator *reg_xcvr; struct flexcan_platform_data *pdata; }; @@ -224,6 +226,11 @@ static inline void flexcan_write(u32 val, void __iomem *addr) */ static void flexcan_transceiver_switch(const struct flexcan_priv *priv, int on) { + if (on) + regulator_enable(priv->reg_xcvr); + else + regulator_disable(priv->reg_xcvr); + if (priv->pdata && priv->pdata->transceiver_switch) priv->pdata->transceiver_switch(on); } @@ -997,6 +1004,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev) priv->base = base; priv->dev = dev; priv->clk = clk; + priv->reg_xcvr = devm_regulator_get(&pdev->dev, "xcvr"); priv->pdata = pdev->dev.platform_data; netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT);