Some system designs may have a controllable power supply for
transceiver. Add a regulator for that, which can be turned on
or off in flexcan_transceiver_switch function.
Signed-off-by: Shawn Guo <redacted>
---
drivers/net/can/flexcan.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
From: Mark Brown <hidden> Date: 2012-07-03 13:07:47
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.
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:
quoted
+ 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<----
From: Mark Brown <hidden> Date: 2012-07-03 14:46:47
On Tue, Jul 03, 2012 at 10:18:31PM +0800, Shawn Guo wrote:
On Tue, Jul 03, 2012 at 02:07:47PM +0100, Mark Brown wrote:
quoted
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?
No, I really do mean a fixed voltage regulator. Dummy regulators should
essentially never be used in production.
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);
+
So long as the stack guarantees that you won't get unbalanced calls to
this and...
On Tue, Jul 03, 2012 at 03:46:47PM +0100, Mark Brown wrote:
On Tue, Jul 03, 2012 at 10:18:31PM +0800, Shawn Guo wrote:
quoted
On Tue, Jul 03, 2012 at 02:07:47PM +0100, Mark Brown wrote:
quoted
quoted
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.
quoted
Ah, yes. But when you say "a fixed voltage regulator", you actually
meant dummy regulator, right?
No, I really do mean a fixed voltage regulator. Dummy regulators should
essentially never be used in production.
In that case, my patch may need to stay unchanged. Some systems have
a supply controlled by gpio and we need to have it be a Linux regulator
to switch it, while other systems have the supply non-switchable which
can be reasonably invisible to software. That said, the regulator is
optional and the failure of devm_regulator_get should not make the
driver probe fail.
I guess your suggestion here is to make the regulator mandatory for
the driver, which means those non-switchable supplies have to be
also defined as Linux regulators for every single system. I'm not
sure we want to do that just for saving a regulator pointer check.
quoted
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);
+
So long as the stack guarantees that you won't get unbalanced calls to
this and...
From: Mark Brown <hidden> Date: 2012-07-03 16:56:35
On Tue, Jul 03, 2012 at 11:28:15PM +0800, Shawn Guo wrote:
On Tue, Jul 03, 2012 at 03:46:47PM +0100, Mark Brown wrote:
quoted
No, I really do mean a fixed voltage regulator. Dummy regulators should
essentially never be used in production.
In that case, my patch may need to stay unchanged. Some systems have
a supply controlled by gpio and we need to have it be a Linux regulator
to switch it, while other systems have the supply non-switchable which
can be reasonably invisible to software. That said, the regulator is
optional and the failure of devm_regulator_get should not make the
driver probe fail.
No, really.
I guess your suggestion here is to make the regulator mandatory for
the driver, which means those non-switchable supplies have to be
also defined as Linux regulators for every single system. I'm not
sure we want to do that just for saving a regulator pointer check.
If we go down that route what we need to do is to go through and remove
all error checking for failure to get regulators and make the regulator
API silently handle this since exactly the same thing applies to almost
every supply in the system.
What we shouldn't be doing is open coding this stupidity in every single
regulator API user, that's just a pointless waste of everyone's time.