linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] net: phy: switch to using fwnode_gpiod_get_index
@ 2019-10-04 23:13 Dmitry Torokhov
  2019-10-04 23:13 ` [PATCH 1/3] net: phylink: switch to using fwnode_gpiod_get_index() Dmitry Torokhov
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2019-10-04 23:13 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, linux-kernel, Andrew Lunn, Florian Fainelli,
	Heiner Kallweit, Russell King

This series switches phy drivers form using fwnode_get_named_gpiod() and
gpiod_get_from_of_node() that are scheduled to be removed in favor
of fwnode_gpiod_get_index() that behaves more like standard
gpiod_get_index() and will potentially handle secondary software
nodes in cases we need to augment platform firmware.

This depends on the new code that can be bound in
ib-fwnode-gpiod-get-index immutable branch of Linus' Walleij tree:

        git pull git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git ib-fwnode-gpiod-get-index

I hope that it would be possible to pull in this immutable branch and
not wait until after 5.5 merge window.


Dmitry Torokhov (3):
  net: phylink: switch to using fwnode_gpiod_get_index()
  net: phy: fixed_phy: fix use-after-free when checking link GPIO
  net: phy: fixed_phy: switch to using fwnode_gpiod_get_index

 drivers/net/phy/fixed_phy.c | 11 ++++-------
 drivers/net/phy/phylink.c   |  4 ++--
 2 files changed, 6 insertions(+), 9 deletions(-)

-- 
2.23.0.581.g78d2f28ef7-goog


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/3] net: phylink: switch to using fwnode_gpiod_get_index()
  2019-10-04 23:13 [PATCH 0/3] net: phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
@ 2019-10-04 23:13 ` Dmitry Torokhov
  2019-10-05  5:00   ` kbuild test robot
  2019-10-05  5:33   ` kbuild test robot
  2019-10-04 23:13 ` [PATCH 2/3] net: phy: fixed_phy: fix use-after-free when checking link GPIO Dmitry Torokhov
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2019-10-04 23:13 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, linux-kernel, Andy Shevchenko, Andrew Lunn,
	Florian Fainelli, Heiner Kallweit, Russell King

Instead of fwnode_get_named_gpiod() that I plan to hide away, let's use
the new fwnode_gpiod_get_index() that mimics gpiod_get_index(), but
works with arbitrary firmware node.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

 drivers/net/phy/phylink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index a5a57ca94c1a..c34ca644d47e 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -168,8 +168,8 @@ static int phylink_parse_fixedlink(struct phylink *pl,
 			pl->link_config.pause |= MLO_PAUSE_ASYM;
 
 		if (ret == 0) {
-			desc = fwnode_get_named_gpiod(fixed_node, "link-gpios",
-						      0, GPIOD_IN, "?");
+			desc = fwnode_gpiod_get_index(fixed_node, "link", 0,
+						      GPIOD_IN, "?");
 
 			if (!IS_ERR(desc))
 				pl->link_gpio = desc;
-- 
2.23.0.581.g78d2f28ef7-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/3] net: phy: fixed_phy: fix use-after-free when checking link GPIO
  2019-10-04 23:13 [PATCH 0/3] net: phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
  2019-10-04 23:13 ` [PATCH 1/3] net: phylink: switch to using fwnode_gpiod_get_index() Dmitry Torokhov
@ 2019-10-04 23:13 ` Dmitry Torokhov
  2019-10-04 23:13 ` [PATCH 3/3] net: phy: fixed_phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2019-10-04 23:13 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, linux-kernel, Andrew Lunn, Florian Fainelli, Heiner Kallweit

If we fail to locate GPIO for any reason other than deferral or
not-found-GPIO, we try to print device tree node info, however if might
be freed already as we called of_node_put() on it.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

 drivers/net/phy/fixed_phy.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index 7c5265fd2b94..4190f9ed5313 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -212,16 +212,13 @@ static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np)
 	 */
 	gpiod = gpiod_get_from_of_node(fixed_link_node, "link-gpios", 0,
 				       GPIOD_IN, "mdio");
-	of_node_put(fixed_link_node);
-	if (IS_ERR(gpiod)) {
-		if (PTR_ERR(gpiod) == -EPROBE_DEFER)
-			return gpiod;
-
+	if (IS_ERR(gpiod) && PTR_ERR(gpiod) != -EPROBE_DEFER) {
 		if (PTR_ERR(gpiod) != -ENOENT)
 			pr_err("error getting GPIO for fixed link %pOF, proceed without\n",
 			       fixed_link_node);
 		gpiod = NULL;
 	}
+	of_node_put(fixed_link_node);
 
 	return gpiod;
 }
-- 
2.23.0.581.g78d2f28ef7-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/3] net: phy: fixed_phy: switch to using fwnode_gpiod_get_index
  2019-10-04 23:13 [PATCH 0/3] net: phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
  2019-10-04 23:13 ` [PATCH 1/3] net: phylink: switch to using fwnode_gpiod_get_index() Dmitry Torokhov
  2019-10-04 23:13 ` [PATCH 2/3] net: phy: fixed_phy: fix use-after-free when checking link GPIO Dmitry Torokhov
@ 2019-10-04 23:13 ` Dmitry Torokhov
  2019-10-05  5:14   ` kbuild test robot
  2019-10-05  5:38   ` kbuild test robot
  2019-10-05 22:51 ` [PATCH 0/3] net: phy: " David Miller
  2019-10-11 20:42 ` Dmitry Torokhov
  4 siblings, 2 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2019-10-04 23:13 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, linux-kernel, Andrew Lunn, Florian Fainelli, Heiner Kallweit

gpiod_get_from_of_node() is being retired in favor of
[devm_]fwnode_gpiod_get_index(), that behaves similar to
[devm_]gpiod_get_index(), but can work with arbitrary firmware node. It
will also be able to support secondary software nodes.

Let's switch this driver over.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

---

 drivers/net/phy/fixed_phy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index 4190f9ed5313..73a72ff0fb16 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -210,8 +210,8 @@ static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np)
 	 * Linux device associated with it, we simply have obtain
 	 * the GPIO descriptor from the device tree like this.
 	 */
-	gpiod = gpiod_get_from_of_node(fixed_link_node, "link-gpios", 0,
-				       GPIOD_IN, "mdio");
+	gpiod = fwnode_gpiod_get_index(of_fwnode_handle(fixed_link_node),
+				       "link-gpios", 0, GPIOD_IN, "mdio");
 	if (IS_ERR(gpiod) && PTR_ERR(gpiod) != -EPROBE_DEFER) {
 		if (PTR_ERR(gpiod) != -ENOENT)
 			pr_err("error getting GPIO for fixed link %pOF, proceed without\n",
-- 
2.23.0.581.g78d2f28ef7-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] net: phylink: switch to using fwnode_gpiod_get_index()
  2019-10-04 23:13 ` [PATCH 1/3] net: phylink: switch to using fwnode_gpiod_get_index() Dmitry Torokhov
@ 2019-10-05  5:00   ` kbuild test robot
  2019-10-05  5:33   ` kbuild test robot
  1 sibling, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2019-10-05  5:00 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: kbuild-all, David S . Miller, netdev, linux-kernel,
	Andy Shevchenko, Andrew Lunn, Florian Fainelli, Heiner Kallweit,
	Russell King

[-- Attachment #1: Type: text/plain, Size: 5157 bytes --]

Hi Dmitry,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]
[cannot apply to v5.4-rc1 next-20191004]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dmitry-Torokhov/net-phy-switch-to-using-fwnode_gpiod_get_index/20191005-083613
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   drivers/net/phy/phylink.c: In function 'phylink_parse_fixedlink':
>> drivers/net/phy/phylink.c:171:11: error: implicit declaration of function 'fwnode_gpiod_get_index'; did you mean 'devm_gpiod_get_index'? [-Werror=implicit-function-declaration]
       desc = fwnode_gpiod_get_index(fixed_node, "link", 0,
              ^~~~~~~~~~~~~~~~~~~~~~
              devm_gpiod_get_index
>> drivers/net/phy/phylink.c:171:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       desc = fwnode_gpiod_get_index(fixed_node, "link", 0,
            ^
   cc1: some warnings being treated as errors

vim +171 drivers/net/phy/phylink.c

   143	
   144	static int phylink_parse_fixedlink(struct phylink *pl,
   145					   struct fwnode_handle *fwnode)
   146	{
   147		struct fwnode_handle *fixed_node;
   148		const struct phy_setting *s;
   149		struct gpio_desc *desc;
   150		u32 speed;
   151		int ret;
   152	
   153		fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link");
   154		if (fixed_node) {
   155			ret = fwnode_property_read_u32(fixed_node, "speed", &speed);
   156	
   157			pl->link_config.speed = speed;
   158			pl->link_config.duplex = DUPLEX_HALF;
   159	
   160			if (fwnode_property_read_bool(fixed_node, "full-duplex"))
   161				pl->link_config.duplex = DUPLEX_FULL;
   162	
   163			/* We treat the "pause" and "asym-pause" terminology as
   164			 * defining the link partner's ability. */
   165			if (fwnode_property_read_bool(fixed_node, "pause"))
   166				pl->link_config.pause |= MLO_PAUSE_SYM;
   167			if (fwnode_property_read_bool(fixed_node, "asym-pause"))
   168				pl->link_config.pause |= MLO_PAUSE_ASYM;
   169	
   170			if (ret == 0) {
 > 171				desc = fwnode_gpiod_get_index(fixed_node, "link", 0,
   172							      GPIOD_IN, "?");
   173	
   174				if (!IS_ERR(desc))
   175					pl->link_gpio = desc;
   176				else if (desc == ERR_PTR(-EPROBE_DEFER))
   177					ret = -EPROBE_DEFER;
   178			}
   179			fwnode_handle_put(fixed_node);
   180	
   181			if (ret)
   182				return ret;
   183		} else {
   184			u32 prop[5];
   185	
   186			ret = fwnode_property_read_u32_array(fwnode, "fixed-link",
   187							     NULL, 0);
   188			if (ret != ARRAY_SIZE(prop)) {
   189				phylink_err(pl, "broken fixed-link?\n");
   190				return -EINVAL;
   191			}
   192	
   193			ret = fwnode_property_read_u32_array(fwnode, "fixed-link",
   194							     prop, ARRAY_SIZE(prop));
   195			if (!ret) {
   196				pl->link_config.duplex = prop[1] ?
   197							DUPLEX_FULL : DUPLEX_HALF;
   198				pl->link_config.speed = prop[2];
   199				if (prop[3])
   200					pl->link_config.pause |= MLO_PAUSE_SYM;
   201				if (prop[4])
   202					pl->link_config.pause |= MLO_PAUSE_ASYM;
   203			}
   204		}
   205	
   206		if (pl->link_config.speed > SPEED_1000 &&
   207		    pl->link_config.duplex != DUPLEX_FULL)
   208			phylink_warn(pl, "fixed link specifies half duplex for %dMbps link?\n",
   209				     pl->link_config.speed);
   210	
   211		bitmap_fill(pl->supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
   212		linkmode_copy(pl->link_config.advertising, pl->supported);
   213		phylink_validate(pl, pl->supported, &pl->link_config);
   214	
   215		s = phy_lookup_setting(pl->link_config.speed, pl->link_config.duplex,
   216				       pl->supported, true);
   217		linkmode_zero(pl->supported);
   218		phylink_set(pl->supported, MII);
   219		phylink_set(pl->supported, Pause);
   220		phylink_set(pl->supported, Asym_Pause);
   221		if (s) {
   222			__set_bit(s->bit, pl->supported);
   223		} else {
   224			phylink_warn(pl, "fixed link %s duplex %dMbps not recognised\n",
   225				     pl->link_config.duplex == DUPLEX_FULL ? "full" : "half",
   226				     pl->link_config.speed);
   227		}
   228	
   229		linkmode_and(pl->link_config.advertising, pl->link_config.advertising,
   230			     pl->supported);
   231	
   232		pl->link_config.link = 1;
   233		pl->link_config.an_complete = 1;
   234	
   235		return 0;
   236	}
   237	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 52227 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] net: phy: fixed_phy: switch to using fwnode_gpiod_get_index
  2019-10-04 23:13 ` [PATCH 3/3] net: phy: fixed_phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
@ 2019-10-05  5:14   ` kbuild test robot
  2019-10-05  5:38   ` kbuild test robot
  1 sibling, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2019-10-05  5:14 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: kbuild-all, David S . Miller, netdev, linux-kernel, Andrew Lunn,
	Florian Fainelli, Heiner Kallweit

[-- Attachment #1: Type: text/plain, Size: 3032 bytes --]

Hi Dmitry,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]
[cannot apply to v5.4-rc1 next-20191004]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dmitry-Torokhov/net-phy-switch-to-using-fwnode_gpiod_get_index/20191005-083613
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   drivers/net/phy/fixed_phy.c: In function 'fixed_phy_get_gpiod':
>> drivers/net/phy/fixed_phy.c:213:10: error: implicit declaration of function 'fwnode_gpiod_get_index'; did you mean 'devm_gpiod_get_index'? [-Werror=implicit-function-declaration]
     gpiod = fwnode_gpiod_get_index(of_fwnode_handle(fixed_link_node),
             ^~~~~~~~~~~~~~~~~~~~~~
             devm_gpiod_get_index
>> drivers/net/phy/fixed_phy.c:213:8: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     gpiod = fwnode_gpiod_get_index(of_fwnode_handle(fixed_link_node),
           ^
   cc1: some warnings being treated as errors

vim +213 drivers/net/phy/fixed_phy.c

   194	
   195	#ifdef CONFIG_OF_GPIO
   196	static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np)
   197	{
   198		struct device_node *fixed_link_node;
   199		struct gpio_desc *gpiod;
   200	
   201		if (!np)
   202			return NULL;
   203	
   204		fixed_link_node = of_get_child_by_name(np, "fixed-link");
   205		if (!fixed_link_node)
   206			return NULL;
   207	
   208		/*
   209		 * As the fixed link is just a device tree node without any
   210		 * Linux device associated with it, we simply have obtain
   211		 * the GPIO descriptor from the device tree like this.
   212		 */
 > 213		gpiod = fwnode_gpiod_get_index(of_fwnode_handle(fixed_link_node),
   214					       "link-gpios", 0, GPIOD_IN, "mdio");
   215		if (IS_ERR(gpiod) && PTR_ERR(gpiod) != -EPROBE_DEFER) {
   216			if (PTR_ERR(gpiod) != -ENOENT)
   217				pr_err("error getting GPIO for fixed link %pOF, proceed without\n",
   218				       fixed_link_node);
   219			gpiod = NULL;
   220		}
   221		of_node_put(fixed_link_node);
   222	
   223		return gpiod;
   224	}
   225	#else
   226	static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np)
   227	{
   228		return NULL;
   229	}
   230	#endif
   231	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 52227 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] net: phylink: switch to using fwnode_gpiod_get_index()
  2019-10-04 23:13 ` [PATCH 1/3] net: phylink: switch to using fwnode_gpiod_get_index() Dmitry Torokhov
  2019-10-05  5:00   ` kbuild test robot
@ 2019-10-05  5:33   ` kbuild test robot
  1 sibling, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2019-10-05  5:33 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: kbuild-all, David S . Miller, netdev, linux-kernel,
	Andy Shevchenko, Andrew Lunn, Florian Fainelli, Heiner Kallweit,
	Russell King

[-- Attachment #1: Type: text/plain, Size: 5202 bytes --]

Hi Dmitry,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[cannot apply to v5.4-rc1 next-20191004]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dmitry-Torokhov/net-phy-switch-to-using-fwnode_gpiod_get_index/20191005-083613
config: nds32-allyesconfig (attached as .config)
compiler: nds32le-linux-gcc (GCC) 8.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=nds32 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/net/phy/phylink.c: In function 'phylink_parse_fixedlink':
   drivers/net/phy/phylink.c:171:11: error: implicit declaration of function 'fwnode_gpiod_get_index'; did you mean 'devm_gpiod_get_index'? [-Werror=implicit-function-declaration]
       desc = fwnode_gpiod_get_index(fixed_node, "link", 0,
              ^~~~~~~~~~~~~~~~~~~~~~
              devm_gpiod_get_index
>> drivers/net/phy/phylink.c:171:9: warning: assignment to 'struct gpio_desc *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
       desc = fwnode_gpiod_get_index(fixed_node, "link", 0,
            ^
   cc1: some warnings being treated as errors

vim +171 drivers/net/phy/phylink.c

   143	
   144	static int phylink_parse_fixedlink(struct phylink *pl,
   145					   struct fwnode_handle *fwnode)
   146	{
   147		struct fwnode_handle *fixed_node;
   148		const struct phy_setting *s;
   149		struct gpio_desc *desc;
   150		u32 speed;
   151		int ret;
   152	
   153		fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link");
   154		if (fixed_node) {
   155			ret = fwnode_property_read_u32(fixed_node, "speed", &speed);
   156	
   157			pl->link_config.speed = speed;
   158			pl->link_config.duplex = DUPLEX_HALF;
   159	
   160			if (fwnode_property_read_bool(fixed_node, "full-duplex"))
   161				pl->link_config.duplex = DUPLEX_FULL;
   162	
   163			/* We treat the "pause" and "asym-pause" terminology as
   164			 * defining the link partner's ability. */
   165			if (fwnode_property_read_bool(fixed_node, "pause"))
   166				pl->link_config.pause |= MLO_PAUSE_SYM;
   167			if (fwnode_property_read_bool(fixed_node, "asym-pause"))
   168				pl->link_config.pause |= MLO_PAUSE_ASYM;
   169	
   170			if (ret == 0) {
 > 171				desc = fwnode_gpiod_get_index(fixed_node, "link", 0,
   172							      GPIOD_IN, "?");
   173	
   174				if (!IS_ERR(desc))
   175					pl->link_gpio = desc;
   176				else if (desc == ERR_PTR(-EPROBE_DEFER))
   177					ret = -EPROBE_DEFER;
   178			}
   179			fwnode_handle_put(fixed_node);
   180	
   181			if (ret)
   182				return ret;
   183		} else {
   184			u32 prop[5];
   185	
   186			ret = fwnode_property_read_u32_array(fwnode, "fixed-link",
   187							     NULL, 0);
   188			if (ret != ARRAY_SIZE(prop)) {
   189				phylink_err(pl, "broken fixed-link?\n");
   190				return -EINVAL;
   191			}
   192	
   193			ret = fwnode_property_read_u32_array(fwnode, "fixed-link",
   194							     prop, ARRAY_SIZE(prop));
   195			if (!ret) {
   196				pl->link_config.duplex = prop[1] ?
   197							DUPLEX_FULL : DUPLEX_HALF;
   198				pl->link_config.speed = prop[2];
   199				if (prop[3])
   200					pl->link_config.pause |= MLO_PAUSE_SYM;
   201				if (prop[4])
   202					pl->link_config.pause |= MLO_PAUSE_ASYM;
   203			}
   204		}
   205	
   206		if (pl->link_config.speed > SPEED_1000 &&
   207		    pl->link_config.duplex != DUPLEX_FULL)
   208			phylink_warn(pl, "fixed link specifies half duplex for %dMbps link?\n",
   209				     pl->link_config.speed);
   210	
   211		bitmap_fill(pl->supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
   212		linkmode_copy(pl->link_config.advertising, pl->supported);
   213		phylink_validate(pl, pl->supported, &pl->link_config);
   214	
   215		s = phy_lookup_setting(pl->link_config.speed, pl->link_config.duplex,
   216				       pl->supported, true);
   217		linkmode_zero(pl->supported);
   218		phylink_set(pl->supported, MII);
   219		phylink_set(pl->supported, Pause);
   220		phylink_set(pl->supported, Asym_Pause);
   221		if (s) {
   222			__set_bit(s->bit, pl->supported);
   223		} else {
   224			phylink_warn(pl, "fixed link %s duplex %dMbps not recognised\n",
   225				     pl->link_config.duplex == DUPLEX_FULL ? "full" : "half",
   226				     pl->link_config.speed);
   227		}
   228	
   229		linkmode_and(pl->link_config.advertising, pl->link_config.advertising,
   230			     pl->supported);
   231	
   232		pl->link_config.link = 1;
   233		pl->link_config.an_complete = 1;
   234	
   235		return 0;
   236	}
   237	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 53263 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] net: phy: fixed_phy: switch to using fwnode_gpiod_get_index
  2019-10-04 23:13 ` [PATCH 3/3] net: phy: fixed_phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
  2019-10-05  5:14   ` kbuild test robot
@ 2019-10-05  5:38   ` kbuild test robot
  1 sibling, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2019-10-05  5:38 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: kbuild-all, David S . Miller, netdev, linux-kernel, Andrew Lunn,
	Florian Fainelli, Heiner Kallweit

[-- Attachment #1: Type: text/plain, Size: 3077 bytes --]

Hi Dmitry,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[cannot apply to v5.4-rc1 next-20191004]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dmitry-Torokhov/net-phy-switch-to-using-fwnode_gpiod_get_index/20191005-083613
config: nds32-allyesconfig (attached as .config)
compiler: nds32le-linux-gcc (GCC) 8.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=nds32 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/net/phy/fixed_phy.c: In function 'fixed_phy_get_gpiod':
   drivers/net/phy/fixed_phy.c:213:10: error: implicit declaration of function 'fwnode_gpiod_get_index'; did you mean 'devm_gpiod_get_index'? [-Werror=implicit-function-declaration]
     gpiod = fwnode_gpiod_get_index(of_fwnode_handle(fixed_link_node),
             ^~~~~~~~~~~~~~~~~~~~~~
             devm_gpiod_get_index
>> drivers/net/phy/fixed_phy.c:213:8: warning: assignment to 'struct gpio_desc *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     gpiod = fwnode_gpiod_get_index(of_fwnode_handle(fixed_link_node),
           ^
   cc1: some warnings being treated as errors

vim +213 drivers/net/phy/fixed_phy.c

   194	
   195	#ifdef CONFIG_OF_GPIO
   196	static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np)
   197	{
   198		struct device_node *fixed_link_node;
   199		struct gpio_desc *gpiod;
   200	
   201		if (!np)
   202			return NULL;
   203	
   204		fixed_link_node = of_get_child_by_name(np, "fixed-link");
   205		if (!fixed_link_node)
   206			return NULL;
   207	
   208		/*
   209		 * As the fixed link is just a device tree node without any
   210		 * Linux device associated with it, we simply have obtain
   211		 * the GPIO descriptor from the device tree like this.
   212		 */
 > 213		gpiod = fwnode_gpiod_get_index(of_fwnode_handle(fixed_link_node),
   214					       "link-gpios", 0, GPIOD_IN, "mdio");
   215		if (IS_ERR(gpiod) && PTR_ERR(gpiod) != -EPROBE_DEFER) {
   216			if (PTR_ERR(gpiod) != -ENOENT)
   217				pr_err("error getting GPIO for fixed link %pOF, proceed without\n",
   218				       fixed_link_node);
   219			gpiod = NULL;
   220		}
   221		of_node_put(fixed_link_node);
   222	
   223		return gpiod;
   224	}
   225	#else
   226	static struct gpio_desc *fixed_phy_get_gpiod(struct device_node *np)
   227	{
   228		return NULL;
   229	}
   230	#endif
   231	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 53263 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] net: phy: switch to using fwnode_gpiod_get_index
  2019-10-04 23:13 [PATCH 0/3] net: phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
                   ` (2 preceding siblings ...)
  2019-10-04 23:13 ` [PATCH 3/3] net: phy: fixed_phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
@ 2019-10-05 22:51 ` David Miller
  2019-10-11 20:42 ` Dmitry Torokhov
  4 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2019-10-05 22:51 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: netdev, linux-kernel, andrew, f.fainelli, hkallweit1, linux

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Fri,  4 Oct 2019 16:13:53 -0700

> This series switches phy drivers form using fwnode_get_named_gpiod() and
> gpiod_get_from_of_node() that are scheduled to be removed in favor
> of fwnode_gpiod_get_index() that behaves more like standard
> gpiod_get_index() and will potentially handle secondary software
> nodes in cases we need to augment platform firmware.
> 
> This depends on the new code that can be bound in
> ib-fwnode-gpiod-get-index immutable branch of Linus' Walleij tree:
> 
>         git pull git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git ib-fwnode-gpiod-get-index
> 
> I hope that it would be possible to pull in this immutable branch and
> not wait until after 5.5 merge window.

For series:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] net: phy: switch to using fwnode_gpiod_get_index
  2019-10-04 23:13 [PATCH 0/3] net: phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
                   ` (3 preceding siblings ...)
  2019-10-05 22:51 ` [PATCH 0/3] net: phy: " David Miller
@ 2019-10-11 20:42 ` Dmitry Torokhov
  2019-10-11 21:05   ` David Miller
  4 siblings, 1 reply; 12+ messages in thread
From: Dmitry Torokhov @ 2019-10-11 20:42 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, linux-kernel, Andrew Lunn, Florian Fainelli,
	Heiner Kallweit, Russell King

Hi David,

On Fri, Oct 04, 2019 at 04:13:53PM -0700, Dmitry Torokhov wrote:
> This series switches phy drivers form using fwnode_get_named_gpiod() and
> gpiod_get_from_of_node() that are scheduled to be removed in favor
> of fwnode_gpiod_get_index() that behaves more like standard
> gpiod_get_index() and will potentially handle secondary software
> nodes in cases we need to augment platform firmware.
> 
> This depends on the new code that can be bound in
> ib-fwnode-gpiod-get-index immutable branch of Linus' Walleij tree:
> 
>         git pull git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git ib-fwnode-gpiod-get-index
> 
> I hope that it would be possible to pull in this immutable branch and
> not wait until after 5.5 merge window.

I see that the patches are marked as "Not applicable" in the netdev
patchwork. Does this mean that you decided against pulling this
immutable branch, or you dropped them because of kbuild complaints (that
happened because it could not figure out how to apply the patches)?

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] net: phy: switch to using fwnode_gpiod_get_index
  2019-10-11 20:42 ` Dmitry Torokhov
@ 2019-10-11 21:05   ` David Miller
  2019-10-14 16:32     ` Dmitry Torokhov
  0 siblings, 1 reply; 12+ messages in thread
From: David Miller @ 2019-10-11 21:05 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: netdev, linux-kernel, andrew, f.fainelli, hkallweit1, linux

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Fri, 11 Oct 2019 13:42:42 -0700

> I see that the patches are marked as "Not applicable" in the netdev
> patchwork. Does this mean that you decided against pulling this
> immutable branch, or you dropped them because of kbuild complaints (that
> happened because it could not figure out how to apply the patches)?

I can't, because the dependencies don't exist in my tree.

So submit this into the tree that will have the dependencies.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] net: phy: switch to using fwnode_gpiod_get_index
  2019-10-11 21:05   ` David Miller
@ 2019-10-14 16:32     ` Dmitry Torokhov
  0 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2019-10-14 16:32 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel, andrew, f.fainelli, hkallweit1, linux

On Fri, Oct 11, 2019 at 02:05:40PM -0700, David Miller wrote:
> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Date: Fri, 11 Oct 2019 13:42:42 -0700
> 
> > I see that the patches are marked as "Not applicable" in the netdev
> > patchwork. Does this mean that you decided against pulling this
> > immutable branch, or you dropped them because of kbuild complaints (that
> > happened because it could not figure out how to apply the patches)?
> 
> I can't, because the dependencies don't exist in my tree.
> 
> So submit this into the tree that will have the dependencies.

Argh, Gmail decided to stuff your original ACK and this reply in spam so
I completely missed it and just fished them out of my spam folder, sorry
about that.

OK, I'll add your ACKs and forward to Linus Walleij then. I should have
had him on the original emails...

Thanks!

-- 
Dmitry

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-10-14 16:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 23:13 [PATCH 0/3] net: phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
2019-10-04 23:13 ` [PATCH 1/3] net: phylink: switch to using fwnode_gpiod_get_index() Dmitry Torokhov
2019-10-05  5:00   ` kbuild test robot
2019-10-05  5:33   ` kbuild test robot
2019-10-04 23:13 ` [PATCH 2/3] net: phy: fixed_phy: fix use-after-free when checking link GPIO Dmitry Torokhov
2019-10-04 23:13 ` [PATCH 3/3] net: phy: fixed_phy: switch to using fwnode_gpiod_get_index Dmitry Torokhov
2019-10-05  5:14   ` kbuild test robot
2019-10-05  5:38   ` kbuild test robot
2019-10-05 22:51 ` [PATCH 0/3] net: phy: " David Miller
2019-10-11 20:42 ` Dmitry Torokhov
2019-10-11 21:05   ` David Miller
2019-10-14 16:32     ` Dmitry Torokhov

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).