Thread (14 messages) flat view 14 messages, 3 authors, 2021-04-13

Re: [PATCH net-next 1/5] net: phy: marvell: refactor HWMON OOP style

From: Andrew Lunn <andrew@lunn.ch>
Date: 2021-04-13 14:36:39

+static int marvell_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
+			      u32 attr, int channel, long *temp)
 {
 	struct phy_device *phydev = dev_get_drvdata(dev);
-	int err;
+	const struct marvell_hwmon_ops *ops = to_marvell_hwmon_ops(phydev);
+	int err = -EOPNOTSUPP;
 
 	switch (attr) {
 	case hwmon_temp_input:
-		err = m88e6390_get_temp(phydev, temp);
+		if (ops->get_temp)
+			err = ops->get_temp(phydev, temp);
+		break;
+	case hwmon_temp_crit:
+		if (ops->get_temp_critical)
+			err = ops->get_temp_critical(phydev, temp);
+		break;
+	case hwmon_temp_max_alarm:
+		if (ops->get_temp_alarm)
+			err = ops->get_temp_alarm(phydev, temp);
 		break;
 	default:
-		return -EOPNOTSUPP;
+		fallthrough;
+	}
Does the default clause actually service any purpose?

And it is not falling through, it is falling out :-)

    Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help