Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755094AbcC1RaS (ORCPT ); Mon, 28 Mar 2016 13:30:18 -0400 Received: from mail-lf0-f42.google.com ([209.85.215.42]:34435 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751212AbcC1RaP (ORCPT ); Mon, 28 Mar 2016 13:30:15 -0400 Subject: Re: [PATCH] net: macb: Only call GPIO functions if there is a valid GPIO To: Charles Keepax , nicolas.ferre@atmel.com, davem@davemloft.net References: <1459169262-3941-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, patches@opensource.wolfsonmicro.com From: Sergei Shtylyov Organization: Cogent Embedded Message-ID: <56F96A23.4000001@cogentembedded.com> Date: Mon, 28 Mar 2016 20:30:11 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1459169262-3941-1-git-send-email-ckeepax@opensource.wolfsonmicro.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1537 Lines: 47 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 > --- > 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