Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1365471 > unrolled thread
| Started by | Charles Keepax <ckeepax@opensource.wolfsonmicro.com> |
|---|---|
| First post | 2016-03-28 14:50 +0200 |
| Last post | 2016-03-29 10:30 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] net: macb: Only call GPIO functions if there is a valid GPIO Charles Keepax <ckeepax@opensource.wolfsonmicro.com> - 2016-03-28 14:50 +0200
Re: [PATCH] net: macb: Only call GPIO functions if there is a valid GPIO David Miller <davem@davemloft.net> - 2016-03-28 17:50 +0200
Re: [PATCH] net: macb: Only call GPIO functions if there is a valid GPIO Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-03-28 19:40 +0200
Re: [PATCH] net: macb: Only call GPIO functions if there is a valid GPIO Charles Keepax <ckeepax@opensource.wolfsonmicro.com> - 2016-03-29 10:30 +0200
| From | Charles Keepax <ckeepax@opensource.wolfsonmicro.com> |
|---|---|
| Date | 2016-03-28 14:50 +0200 |
| Subject | [PATCH] net: macb: Only call GPIO functions if there is a valid GPIO |
| Message-ID | <rhEMi-78o-19@gated-at.bofh.it> |
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 <ckeepax@opensource.wolfsonmicro.com>
---
drivers/net/ethernet/cadence/macb.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 6619178..71bb42e 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -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);
--
2.1.4
[toc] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-03-28 17:50 +0200 |
| Subject | Re: [PATCH] net: macb: Only call GPIO functions if there is a valid GPIO |
| Message-ID | <rhHAt-C5-3@gated-at.bofh.it> |
| In reply to | #1365471 |
From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Date: Mon, 28 Mar 2016 13:47:42 +0100 > 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 <ckeepax@opensource.wolfsonmicro.com> Applied.
[toc] | [prev] | [next] | [standalone]
| From | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| Date | 2016-03-28 19:40 +0200 |
| Subject | Re: [PATCH] net: macb: Only call GPIO functions if there is a valid GPIO |
| Message-ID | <rhJiW-1Rg-9@gated-at.bofh.it> |
| In reply to | #1365471 |
Hello.
On 03/28/2016 03:47 PM, Charles Keepax wrote:
> 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 <ckeepax@opensource.wolfsonmicro.com>
> ---
> drivers/net/ethernet/cadence/macb.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index 6619178..71bb42e 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -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.
> }
> 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)...
>
> unregister_netdev(dev);
> clk_disable_unprepare(bp->tx_clk);
MBR, Sergei
[toc] | [prev] | [next] | [standalone]
| From | Charles Keepax <ckeepax@opensource.wolfsonmicro.com> |
|---|---|
| Date | 2016-03-29 10:30 +0200 |
| Subject | Re: [PATCH] net: macb: Only call GPIO functions if there is a valid GPIO |
| Message-ID | <rhXce-3ke-3@gated-at.bofh.it> |
| In reply to | #1365600 |
On Mon, Mar 28, 2016 at 08:30:11PM +0300, Sergei Shtylyov wrote:
> >@@ -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 <linus.walleij@linaro.org>
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web