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
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(-)
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(-)
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(-)
From: kbuild test robot <hidden> Date: 2019-10-05 05:02:09
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 <redacted>
All error/warnings (new ones prefixed by >>):
drivers/net/phy/phylink.c: In function 'phylink_parse_fixedlink':
quoted
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]
From: kbuild test robot <hidden> Date: 2019-10-05 05:15:09
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 <redacted>
All error/warnings (new ones prefixed by >>):
drivers/net/phy/fixed_phy.c: In function 'fixed_phy_get_gpiod':
quoted
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]
From: kbuild test robot <hidden> Date: 2019-10-05 05:34:14
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 <redacted>
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
quoted
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
From: kbuild test robot <hidden> Date: 2019-10-05 05:39:34
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 <redacted>
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
quoted
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
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>
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
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.
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