[PATCH v1 4/7] device property: fwnode_get_phy_mode: Change API to solve int/unit warnings

From: Calvin Johnson
Date: Fri Jan 31 2020 - 10:35:48 EST


From: Calvin Johnson <calvin.johnson@xxxxxxxxxxx>

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@xxxxxxxxxxx>
---

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