mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Calvin Johnson <calvin.johnson@nxp.com>
To: linux.cj@gmail.com, Jon Nettleton <jon@solid-run.com>,
	linux@armlinux.org.uk, Makarand Pawagi <makarand.pawagi@nxp.com>,
	cristian.sovaiala@nxp.com, laurentiu.tudor@nxp.com,
	ioana.ciornei@nxp.com, V.Sethi@nxp.com, pankaj.bansal@nxp.com,
	"Rajesh V . Bikkina" <rajesh.bikkina@nxp.com>
Cc: Calvin Johnson <calvin.johnson@oss.nxp.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Antoine Tenart <antoine.tenart@bootlin.com>,
	"David S. Miller" <davem@davemloft.net>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Matteo Croce <mcroce@redhat.com>,
	Maxime Chevallier <maxime.chevallier@bootlin.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH v1 4/7] device property: fwnode_get_phy_mode: Change API to solve int/unit warnings
Date: Fri, 31 Jan 2020 21:04:37 +0530	[thread overview]
Message-ID: <20200131153440.20870-5-calvin.johnson@nxp.com> (raw)
In-Reply-To: <20200131153440.20870-1-calvin.johnson@nxp.com>

From: Calvin Johnson <calvin.johnson@oss.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@oss.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


  parent reply	other threads:[~2020-01-31 15:35 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31 15:34 [PATCH v1 0/7] ACPI support for xgmac_mdio and dpaa2-mac drivers Calvin Johnson
2020-01-31 15:34 ` [PATCH v1 1/7] mdio_bus: Introduce fwnode MDIO helpers Calvin Johnson
2020-01-31 16:28   ` Andrew Lunn
2020-02-05  7:11     ` [EXT] " Calvin Johnson (OSS)
2020-02-03  9:49   ` kbuild test robot
2020-02-05 14:17   ` Jeremy Linton
2020-02-07  9:42     ` [EXT] " Calvin Johnson (OSS)
2020-03-17 11:36   ` Calvin Johnson
2020-03-17 14:04     ` Andrew Lunn
2020-03-18  6:03       ` Calvin Johnson
2020-01-31 15:34 ` [PATCH v1 2/7] mdio_bus: modify fwnode phy related functions Calvin Johnson
2020-01-31 15:34 ` [PATCH v1 3/7] net/fsl: add ACPI support for mdio bus Calvin Johnson
2020-01-31 16:08   ` Andy Shevchenko
2020-02-04  7:18     ` Calvin Johnson (OSS)
2020-02-04 11:17       ` Andy Shevchenko
2020-02-03  3:44   ` Florian Fainelli
2020-02-04 18:46     ` Calvin Johnson
2020-01-31 15:34 ` Calvin Johnson [this message]
2020-01-31 15:55   ` [PATCH v1 4/7] device property: fwnode_get_phy_mode: Change API to solve int/unit warnings Andy Shevchenko
2020-02-03  9:13     ` Calvin Johnson (OSS)
2020-02-03  9:22       ` Andy Shevchenko
2020-02-03  2:32   ` kbuild test robot
2020-02-03  8:41   ` kbuild test robot
2020-01-31 15:34 ` [PATCH v1 5/7] device property: Introduce fwnode_phy_is_fixed_link() Calvin Johnson
2020-01-31 15:57   ` Andy Shevchenko
2020-02-03  9:21     ` Calvin Johnson (OSS)
2020-01-31 15:34 ` [PATCH v1 6/7] net: phylink: Introduce phylink_fwnode_phy_connect() Calvin Johnson
2020-02-03 18:21   ` kbuild test robot
2020-02-03 18:41   ` Russell King - ARM Linux admin
2020-02-03 18:43     ` Russell King - ARM Linux admin
2020-02-05 11:33     ` [EXT] " Calvin Johnson (OSS)
2020-01-31 15:34 ` [PATCH v1 7/7] dpaa2-eth: Add ACPI support for DPAA2 MAC driver Calvin Johnson
2020-02-03 18:02 ` [PATCH v1 0/7] ACPI support for xgmac_mdio and dpaa2-mac drivers Florian Fainelli
2020-02-05  8:31   ` [EXT] " Calvin Johnson (OSS)

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=20200131153440.20870-5-calvin.johnson@nxp.com \
    --to=calvin.johnson@nxp.com \
    --cc=V.Sethi@nxp.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=antoine.tenart@bootlin.com \
    --cc=calvin.johnson@oss.nxp.com \
    --cc=cristian.sovaiala@nxp.com \
    --cc=davem@davemloft.net \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=jon@solid-run.com \
    --cc=laurentiu.tudor@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux.cj@gmail.com \
    --cc=linux@armlinux.org.uk \
    --cc=makarand.pawagi@nxp.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mcroce@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pankaj.bansal@nxp.com \
    --cc=rafael@kernel.org \
    --cc=rajesh.bikkina@nxp.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®