lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 31 Jan 2020 21:04:37 +0530
From:   Calvin Johnson <calvin.johnson@....com>
To:     linux.cj@...il.com, Jon Nettleton <jon@...id-run.com>,
        linux@...linux.org.uk, Makarand Pawagi <makarand.pawagi@....com>,
        cristian.sovaiala@....com, laurentiu.tudor@....com,
        ioana.ciornei@....com, V.Sethi@....com, pankaj.bansal@....com,
        "Rajesh V . Bikkina" <rajesh.bikkina@....com>
Cc:     Calvin Johnson <calvin.johnson@....nxp.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Antoine Tenart <antoine.tenart@...tlin.com>,
        "David S. Miller" <davem@...emloft.net>,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Matteo Croce <mcroce@...hat.com>,
        Maxime Chevallier <maxime.chevallier@...tlin.com>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Russell King <rmk+kernel@...linux.org.uk>,
        Sakari Ailus <sakari.ailus@...ux.intel.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: [PATCH v1 4/7] device property: fwnode_get_phy_mode: Change API to solve int/unit warnings

From: Calvin Johnson <calvin.johnson@....nxp.com>

API fwnode_get_phy_mode is modified to follow the changes made by
Commit 0c65b2b90d13c1 ("net: of_get_phy_mode: Change API to solve
int/unit warnings").

Signed-off-by: Calvin Johnson <calvin.johnson@....nxp.com>
---

 drivers/base/property.c                       | 22 ++++++++++++++-----
 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   |  7 +++---
 include/linux/property.h                      |  4 +++-
 3 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 511f6d7acdfe..fdb79033d58f 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -830,16 +830,20 @@ EXPORT_SYMBOL_GPL(device_get_dma_attr);
 /**
  * fwnode_get_phy_mode - Get phy mode for given firmware node
  * @fwnode:	Pointer to the given node
+ * @interface: Pointer to the result
  *
  * The function gets phy interface string from property 'phy-mode' or
- * 'phy-connection-type', and return its index in phy_modes table, or errno in
- * error case.
+ * 'phy-connection-type'. The index in phy_modes table is set in
+ * interface and 0 returned. In case of error interface is set to
+ * PHY_INTERFACE_MODE_NA and an errno is returned, e.g. -ENODEV.
  */
-int fwnode_get_phy_mode(struct fwnode_handle *fwnode)
+int fwnode_get_phy_mode(struct fwnode_handle *fwnode, phy_interface_t *interface)
 {
 	const char *pm;
 	int err, i;
 
+	*interface = PHY_INTERFACE_MODE_NA;
+
 	err = fwnode_property_read_string(fwnode, "phy-mode", &pm);
 	if (err < 0)
 		err = fwnode_property_read_string(fwnode,
@@ -848,8 +852,10 @@ int fwnode_get_phy_mode(struct fwnode_handle *fwnode)
 		return err;
 
 	for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++)
-		if (!strcasecmp(pm, phy_modes(i)))
+		if (!strcasecmp(pm, phy_modes(i))) {
+			*interface = i;
 			return i;
+		}
 
 	return -ENODEV;
 }
@@ -865,7 +871,13 @@ EXPORT_SYMBOL_GPL(fwnode_get_phy_mode);
  */
 int device_get_phy_mode(struct device *dev)
 {
-	return fwnode_get_phy_mode(dev_fwnode(dev));
+	int ret;
+	phy_interface_t phy_mode;
+
+	ret = fwnode_get_phy_mode(dev_fwnode(dev), &phy_mode);
+	if (!ret)
+		ret = phy_mode;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(device_get_phy_mode);
 
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 14e372cda7f4..00a0350f4da7 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -5209,7 +5209,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
 	unsigned long flags = 0;
 	bool has_tx_irqs;
 	u32 id;
-	int phy_mode;
+	phy_interface_t phy_mode;
 	int err, i;
 
 	has_tx_irqs = mvpp2_port_has_irqs(priv, port_node, &flags);
@@ -5226,10 +5226,9 @@ static int mvpp2_port_probe(struct platform_device *pdev,
 	if (!dev)
 		return -ENOMEM;
 
-	phy_mode = fwnode_get_phy_mode(port_fwnode);
-	if (phy_mode < 0) {
+	err = fwnode_get_phy_mode(port_fwnode, &phy_mode);
+	if (err < 0) {
 		dev_err(&pdev->dev, "incorrect phy mode\n");
-		err = phy_mode;
 		goto err_free_netdev;
 	}
 
diff --git a/include/linux/property.h b/include/linux/property.h
index 48335288c2a9..1998f502d2ed 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -13,6 +13,7 @@
 #include <linux/bits.h>
 #include <linux/fwnode.h>
 #include <linux/types.h>
+#include <linux/phy.h>
 
 struct device;
 
@@ -332,7 +333,8 @@ int device_get_phy_mode(struct device *dev);
 
 void *device_get_mac_address(struct device *dev, char *addr, int alen);
 
-int fwnode_get_phy_mode(struct fwnode_handle *fwnode);
+int fwnode_get_phy_mode(struct fwnode_handle *fwnode,
+			phy_interface_t *interface);
 void *fwnode_get_mac_address(struct fwnode_handle *fwnode,
 			     char *addr, int alen);
 struct fwnode_handle *fwnode_graph_get_next_endpoint(
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ