net: macb: Only call GPIO functions if there is a valid GPIO
Subsystems (3)
PATCH 1/1 net: macb: Only call GPIO functions if there is a valid GPIO
GPIOlib will print warning messages if we call GPIO functions without a valid GPIO. Change the code to avoid doing so.
--- drivers/net/ethernet/cadence/macb.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/cadence/macb.c +5 -3
@@ -2957,9 +2957,10 @@ static int macb_probe(struct platform_device *pdev) phy_node =of_get_next_available_child (np,NULL );if (phy_node) {int gpio =of_get_named_gpio (phy_node,"reset-gpios" ,0 ); -if (gpio_is_valid (gpio)) +if (gpio_is_valid (gpio)) { bp->reset_gpio =gpio_to_desc (gpio); -gpiod_direction_output (bp->reset_gpio,1 ); +gpiod_direction_output (bp->reset_gpio,1 ); + } }of_node_put (phy_node);
@@ -3029,7 +3030,8 @@ static int macb_remove(struct platform_device *pdev)mdiobus_free (bp->mii_bus);/* Shutdown the PHY if there is a GPIO reset */ -gpiod_set_value (bp->reset_gpio,0 ); +if (bp->reset_gpio) +gpiod_set_value (bp->reset_gpio,0 );unregister_netdev (dev);clk_disable_unprepare (bp->tx_clk);
Signature · 1 line
2.1.4
From: Charles Keepax <[email protected]>
Date: Mon, 28 Mar 2016 13:47:42 +0100
Quoted 4 lines
GPIOlib will print warning messages if we call GPIO functions without a valid GPIO. Change the code to avoid doing so.
Signed-off-by Charles Keepax <[email protected]>
Applied.
Hello.
Quoted 13 lines · Charles Keepax
GPIOlib will print warning messages if we call GPIO functions without a valid GPIO. Change the code to avoid doing so.
Signed-off-by Charles Keepax <[email protected]>--- drivers/net/ethernet/cadence/macb.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/net/ethernet/cadence/macb.c +0
-0
drivers/net/ethernet/cadence/macb.c static int macb_probe(struct platform_device *pdev) · line 2963
Quoted 9 lines
drivers/net/ethernet/cadence/macb.c +3
-2@@ -2957,9 +2957,10 @@ static int macb_probe(struct platform_device *pdev) phy_node =of_get_next_available_child (np,NULL );if (phy_node) {int gpio =of_get_named_gpio (phy_node,"reset-gpios" ,0 ); -if (gpio_is_valid (gpio)) +if (gpio_is_valid (gpio)) { bp->reset_gpio =gpio_to_desc (gpio); -gpiod_direction_output (bp->reset_gpio,1 ); +gpiod_direction_output (bp->reset_gpio,1 ); + }
Oops, sorry for missing this while fixing this code.
drivers/net/ethernet/cadence/macb.c static int macb_remove(struct platform_device *pdev) · line 3034
Quoted 10 lines
drivers/net/ethernet/cadence/macb.c +2
-1}of_node_put (phy_node);@@ -3029,7 +3030,8 @@ static int macb_remove(struct platform_device *pdev)mdiobus_free (bp->mii_bus);/* Shutdown the PHY if there is a GPIO reset */ -gpiod_set_value (bp->reset_gpio,0 ); +if (bp->reset_gpio) +gpiod_set_value (bp->reset_gpio,0 );
Hm, this function was previously OK to call with NULL (it didn't curse)...
drivers/net/ethernet/cadence/macb.c static int macb_remove(struct platform_device *pdev) · line 3037
Quoted 3 lines
drivers/net/ethernet/cadence/macb.c +0
-0unregister_netdev (dev);clk_disable_unprepare (bp->tx_clk);
MBR, Sergei
Quoted 10 lines · Sergei Shtylyov
drivers/net/ethernet/cadence/macb.c static int macb_remove(struct platform_device *pdev) · line 3034
Quoted 7 lines
drivers/net/ethernet/cadence/macb.c +2
-1@@ -3029,7 +3030,8 @@ static int macb_remove(struct platform_device *pdev)mdiobus_free (bp->mii_bus);/* Shutdown the PHY if there is a GPIO reset */ -gpiod_set_value (bp->reset_gpio,0 ); +if (bp->reset_gpio) +gpiod_set_value (bp->reset_gpio,0 );Hm, this function was previously OK to call with NULL (it didn't curse)...
Looks like it was changed so that it does complain fairly recently (patch librally snipped down):
commit fdeb8e1547cb9dd39d5d7223b33f3565cf86c28e
Author: Linus Walleij <[email protected]>
gpio: reflect base and ngpio into gpio_device
+#define VALIDATE_DESC_VOID(desc) do { \
+ if (!desc || !desc->gdev) { \
+ pr_warn("%s: invalid GPIO\n", __func__); \
+ return; \
+ } \
+
void gpiod_set_value(struct gpio_desc *desc, int value) {
- if (!desc)
- return;
+ VALIDATE_DESC_VOID(desc);
Thanks,
Charles