From patchwork Sun Feb 17 13:36:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 221061 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 478D12C007E for ; Mon, 18 Feb 2013 00:45:17 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756170Ab3BQNpM (ORCPT ); Sun, 17 Feb 2013 08:45:12 -0500 Received: from mail-ye0-f180.google.com ([209.85.213.180]:62608 "EHLO mail-ye0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756123Ab3BQNpL (ORCPT ); Sun, 17 Feb 2013 08:45:11 -0500 Received: by mail-ye0-f180.google.com with SMTP id r14so836788yen.25 for ; Sun, 17 Feb 2013 05:45:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=cMo4ISQl6L0s3jk1X1puLoNZ2Ujg522s+Fv9BNmA62Q=; b=btbku5oXiuWEi4aea/0JCzTO0R/5HwW32S8wXqU2p0BqqLljA/5BrxzUvnzFdp0JlD kHlC+RM37ivpBUTgN4wWNdMsy0KGZaJOA0efZdZ4YuKrD5faEf1I77eSDe74oPVGMFMb 5zn8o0EfQrX0XgCK/fW6S4aAJdWx4F7O67xmO7q5iD4EwkqZZ90D7RmM3jUKMIL/GT8j cxs1i+lWGDz7DIyNJqvLNKif637WaCmFRAXlIPIca6oeuz/4d3Km2wbzyGzuJUONkr+8 IpPqbKJTcgwmgHFP0HnHB6fv7qnOpEITgfq/orDZmU++FPd3UfI716u+NO8BONNpogvc EsnQ== X-Received: by 10.236.133.44 with SMTP id p32mr14192344yhi.17.1361108216710; Sun, 17 Feb 2013 05:36:56 -0800 (PST) Received: from localhost.localdomain ([201.82.137.218]) by mx.google.com with ESMTPS id u19sm57727913anj.5.2013.02.17.05.36.54 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 17 Feb 2013 05:36:56 -0800 (PST) From: Fabio Estevam To: davem@davemloft.net Cc: s.hauer@pengutronix.de, shawn.guo@linaro.org, marex@denx.de, netdev@vger.kernel.org, Fabio Estevam Subject: [PATCH v2 1/2] net: fec: Do a sanity check on the gpio number Date: Sun, 17 Feb 2013 10:36:43 -0300 Message-Id: <1361108204-9498-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Fabio Estevam Since commit 372e722ea4d (gpiolib: use descriptors internally) the following warning is seen on a mx28evk board: [ 5.116291] ------------[ cut here ]------------ [ 5.121306] WARNING: at drivers/gpio/gpiolib.c:125 gpio_to_desc+0x30/0x44() [ 5.128491] invalid GPIO -2 [ 5.131563] Modules linked in: [ 5.134846] [] (unwind_backtrace+0x0/0xf4) from [] (warn_slowpath_common+0x4c/0x68) [ 5.144682] [] (warn_slowpath_common+0x4c/0x68) from [] (warn_slowpath_fmt+0x30/0x40) [ 5.154693] [] (warn_slowpath_fmt+0x30/0x40) from [] (gpio_to_desc+0x30/0x44) [ 5.164002] [] (gpio_to_desc+0x30/0x44) from [] (gpio_request_one+0x10/0xe8) [ 5.173294] [] (gpio_request_one+0x10/0xe8) from [] (devm_gpio_request_one+0x40/0x74) [ 5.183332] [] (devm_gpio_request_one+0x40/0x74) from [] (fec_probe+0x2d0/0x99c) [ 5.192923] [] (fec_probe+0x2d0/0x99c) from [] (platform_drv_probe+0x14/0x18) [ 5.202228] [] (platform_drv_probe+0x14/0x18) from [] (driver_probe_device+0x90/0x224) [ 5.212332] [] (driver_probe_device+0x90/0x224) from [] (__driver_attach+0x94/0x98) [ 5.222162] [] (__driver_attach+0x94/0x98) from [] (bus_for_each_dev+0x78/0x98) [ 5.231642] [] (bus_for_each_dev+0x78/0x98) from [] (bus_add_driver+0x1a4/0x240) [ 5.241207] [] (bus_add_driver+0x1a4/0x240) from [] (driver_register+0x78/0x140) [ 5.250768] [] (driver_register+0x78/0x140) from [] (do_one_initcall+0x30/0x17c) [ 5.260347] [] (do_one_initcall+0x30/0x17c) from [] (kernel_init_freeable+0xe8/0x1b0) [ 5.270381] [] (kernel_init_freeable+0xe8/0x1b0) from [] (kernel_init+0x8/0xe4) [ 5.279886] [] (kernel_init+0x8/0xe4) from [] (ret_from_fork+0x14/0x2c) [ 5.288740] ---[ end trace c15c72a22979d58d ]--- mx28evk has two ethernet controllers. The GPIO that performs the ethernet reset on both ports is the same GPIO, so on the board dts file, only in one ethernet instance is passed the GPIO reset property. Validate the gpio number prior to requesting it in order to avoid such warning. Signed-off-by: Fabio Estevam Acked-by: Shawn Guo --- Changes since v1: - Added Shawn's ack drivers/net/ethernet/freescale/fec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c index 0fe68c4..5864a67 100644 --- a/drivers/net/ethernet/freescale/fec.c +++ b/drivers/net/ethernet/freescale/fec.c @@ -1689,6 +1689,9 @@ static void fec_reset_phy(struct platform_device *pdev) msec = 1; phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0); + if (!gpio_is_valid(phy_reset)) + return; + err = devm_gpio_request_one(&pdev->dev, phy_reset, GPIOF_OUT_INIT_LOW, "phy-reset"); if (err) {