netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Mamonov <pmamonov@gmail.com>
To: andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com
Cc: netdev@vger.kernel.org, Peter Mamonov <pmamonov@gmail.com>
Subject: [PATCH RFC] net/phy: fix Marvell PHYs probe failure when HWMON and THERMAL_OF are enabled
Date: Thu, 19 Sep 2019 00:38:37 +0300	[thread overview]
Message-ID: <20190918213837.24585-1-pmamonov@gmail.com> (raw)

Hello,

Some time ago I've discovered that probe functions of certain Marvell PHYs 
fail if both HWMON and THERMAL_OF config options are enabled. The root 
cause of this problem is a lack of an OF node for a PHY's built-in 
temperature sensor.  However I consider adding this OF node to be a bit 
excessive solution. Am I wrong? Below you will find a one line patch which 
fixes the problem. I've sent it to the releveant maintainers three weeks 
ago without any feedback yet. Could you, please, take a look at the problem 
and give your considerations on how to fix it properly?

Regards,
Peter

thermal: make thermal_zone_of_sensor_register return -ENODEV
 if a sensor OF node is missing

When devm_thermal_zone_of_sensor_register() is called from
hwmon_thermal_add_sensor() it is possible that the relevant sensor is
missing an OF node. In this case thermal_zone_of_sensor_register() returns
-EINVAL which causes hwmon_thermal_add_sensor() to fail as well. This patch
changes relevant return code of thermal_zone_of_sensor_register() to
-ENODEV, which is tolerated by hwmon_thermal_add_sensor().

Here is a particular case of such behaviour: the Marvell ethernet PHYs
driver registers hwmon device for the built-in temperature sensor (see
drivers/net/phy/marvell.c). Since the sensor doesn't have associated OF
node devm_hwmon_device_register() returns error which ultimately causes
failure of the PHY driver's probe function.

Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
 drivers/thermal/of-thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index dc5093be553e..34b0cc173f4a 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -493,7 +493,7 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data,
 
 	if (!dev || !dev->of_node) {
 		of_node_put(np);
-		return ERR_PTR(-EINVAL);
+		return ERR_PTR(-ENODEV);
 	}
 
 	sensor_np = of_node_get(dev->of_node);
-- 
2.23.0


             reply	other threads:[~2019-09-18 21:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18 21:38 Peter Mamonov [this message]
2019-09-19  2:50 ` [PATCH RFC] net/phy: fix Marvell PHYs probe failure when HWMON and THERMAL_OF are enabled Andrew Lunn
2019-09-19  8:10   ` Peter Mamonov
2019-09-19 13:52     ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190918213837.24585-1-pmamonov@gmail.com \
    --to=pmamonov@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).