From patchwork Wed Aug 26 18:49:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 511016 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 574FA140311 for ; Thu, 27 Aug 2015 04:49:28 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=roeck-us.net header.i=@roeck-us.net header.b=vKm3FqsT; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752423AbbHZStM (ORCPT ); Wed, 26 Aug 2015 14:49:12 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:39173 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751896AbbHZStL (ORCPT ); Wed, 26 Aug 2015 14:49:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=8S7X4FO9hBlDmFQIpVA8lWt+dx2wejJkjjbksNzrPII=; b=vKm3FqsTby+SaNRdoI16xQ5LaoOh1E0Jc6qwDOMU9nOmasXspO4lD7GydAa+B7pOj2AHo70ZEnjUY9QZ2qiYc9HQkwpgXOZCoQbuT7To6rS2kZiiV/p7iY9+5NpILtEa9HvGbuql78IRBo7AC91kHFL+P7e0C8/6d7TUypsle0A=; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:49388 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.85) (envelope-from ) id 1ZUfky-003bu7-KR; Wed, 26 Aug 2015 18:49:09 +0000 From: Guenter Roeck To: Steve Glendinning Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, tony@atomide.com, jeremy.linton@arm.com, Guenter Roeck Subject: [RFC PATCH] smsc911x: Ignore error return from device_get_phy_mode() Date: Wed, 26 Aug 2015 11:49:08 -0700 Message-Id: <1440614948-27428-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.1.4 X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Commit 62ee783bf1f8 ("smsc911x: Fix crash seen if neither ACPI nor OF is configured or used") introduces an error check for the return value from device_get_phy_mode() and bails out if there is an error. Unfortunately, there are configurations where no phy is configured. Those configurations now fail. To fix the problem, assign a phy interface mode of PHY_INTERFACE_MODE_NA if device_get_phy_mode() returns an error. Check the return value from device_property_read_u32() to see if there is a suitable firmware interface to read the data, and abort if not. The function should return -ENXIO in that case; however, it returns -ENODATA. Check for both. Fixes: 62ee783bf1f8 ("smsc911x: Fix crash seen if neither ACPI nor OF is configured or used") Signed-off-by: Guenter Roeck Tested-by: Jeremy Linton --- Needs testing. RFC because I am not sure if the -ENODATA check is acceptable. drivers/net/ethernet/smsc/smsc911x.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index 6eef3251d833..81e29e420fd0 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -2369,23 +2369,29 @@ static int smsc911x_probe_config(struct smsc911x_platform_config *config, { int phy_interface; u32 width = 0; + int err; phy_interface = device_get_phy_mode(dev); if (phy_interface < 0) - return phy_interface; - + phy_interface = PHY_INTERFACE_MODE_NA; config->phy_interface = phy_interface; device_get_mac_address(dev, config->mac, ETH_ALEN); - device_property_read_u32(dev, "reg-shift", &config->shift); - - device_property_read_u32(dev, "reg-io-width", &width); - if (width == 4) + err = device_property_read_u32(dev, "reg-io-width", &width); + /* device_property_read_u32() should return -ENXIO if there is no + * suitable firmware interface. In reality it returns -ENODATA. + * Check for both and use platform data if that is the case. + */ + if (err == -ENXIO || err == -ENODATA) + return err; + if (!err && width == 4) config->flags |= SMSC911X_USE_32BIT; else config->flags |= SMSC911X_USE_16BIT; + device_property_read_u32(dev, "reg-shift", &config->shift); + if (device_property_present(dev, "smsc,irq-active-high")) config->irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH;