From patchwork Fri Feb 3 07:44:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 139310 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 24A5CB6EF3 for ; Fri, 3 Feb 2012 18:44:20 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754207Ab2BCHoO (ORCPT ); Fri, 3 Feb 2012 02:44:14 -0500 Received: from metis.ext.pengutronix.de ([92.198.50.35]:43323 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754075Ab2BCHoN (ORCPT ); Fri, 3 Feb 2012 02:44:13 -0500 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1RtDoZ-0000Lu-A9; Fri, 03 Feb 2012 08:44:11 +0100 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.77) (envelope-from ) id 1RtDoW-0003xA-W3; Fri, 03 Feb 2012 08:44:08 +0100 Date: Fri, 3 Feb 2012 08:44:08 +0100 From: Sascha Hauer To: Fabio Estevam Cc: robert.marklund@stericsson.com, netdev@vger.kernel.org, Sascha Hauer , Mark Brown Subject: Re: Regulator support for smsc911x Message-ID: <20120203074408.GD1990@pengutronix.de> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 08:28:13 up 82 days, 15:15, 24 users, load average: 0.00, 0.01, 0.05 User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Feb 03, 2012 at 01:17:23AM -0200, Fabio Estevam wrote: > On Thu, Feb 2, 2012 at 11:02 PM, Fabio Estevam wrote: > > Robert, > > > > Since commit c7e963f6 (net/smsc911x: Add regulator support) I am no > > longer able to use smsc911x driver due to the lack of regulators for > > smsc on mx31_3ds board. > > > > Do you a board example that uses such regulator, so that I can look > > for a reference? > > Ok, I fixed it by enabling CONFIG_REGULATOR_DUMMY on > imx_v6_v7_defconfig, but I am wondering if the patch below would be a > more appropriate fix: > > --- a/drivers/net/ethernet/smsc/Kconfig > +++ b/drivers/net/ethernet/smsc/Kconfig > @@ -102,6 +102,8 @@ config SMSC911X > select NET_CORE > select MII > select PHYLIB > + select REGULATOR > + select REGULATOR_DUMMY > ---help--- > Say Y here if you want support for SMSC LAN911x and LAN921x families > of ethernet controllers. > > Please advise if I should fix it in Kconfig or defconfig, so that I > can submit a patch. The problem with the dummy regulator is that it can hide real problems. If you enable it every device will get a regulator when it requests one. If for some reason for example the initialization order of your devices changes and a device gets probed before the corresponding (real) regulator is registered, then this device will continue with the dummy regulator and probably won't work. We could a) live with this problem and default enable the dummy regulator. We could also b) apply (a fixed version of) the following patch which simplifies registration of a dummy regulator. Still it's a bit annoying to have to fix all users once someone adds regulator support for a driver. Sascha 8<------------------------------------------------ regulator: allow boards to bind to the dummy regulator Signed-off-by: Sascha Hauer --- drivers/regulator/core.c | 19 +++++++++++++++++++ include/linux/regulator/machine.h | 8 ++++++++ 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index d8e6a42..a7a38ba 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1046,6 +1046,25 @@ static void unset_regulator_supplies(struct regulator_dev *rdev) } } +int regulator_add_dummy_supply(struct regulator_consumer_supply *supply, + int num_supplies) +{ + int i, ret; + + for (i = 0; i < num_supplies; i++) { + ret = set_consumer_device_supply(dummy_regulator_rdev, NULL, + supply[i].dev_name, supply[i].supply); + if (ret) + goto err_out; + } + + return 0; +err_out: + /* FIXME: unset device supply */ + return ret; +} +EXPORT_SYMBOL_GPL(regulator_add_dummy_supply); + #define REG_STR_SIZE 64 static struct regulator *create_regulator(struct regulator_dev *rdev, diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index ce3127a..89089cd 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h @@ -192,6 +192,8 @@ int regulator_suspend_finish(void); #ifdef CONFIG_REGULATOR void regulator_has_full_constraints(void); void regulator_use_dummy_regulator(void); +int regulator_add_dummy_supply(struct regulator_consumer_supply *supply, + int num_supplies); #else static inline void regulator_has_full_constraints(void) { @@ -200,6 +202,12 @@ static inline void regulator_has_full_constraints(void) static inline void regulator_use_dummy_regulator(void) { } + +static inline int regulator_add_dummy_supply(struct regulator_consumer_supply *supply, + int num_supplies) +{ + return 0; +} #endif #endif