From patchwork Wed Jun 20 08:03:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10476777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A63760383 for ; Wed, 20 Jun 2018 09:40:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C02C28D9B for ; Wed, 20 Jun 2018 09:40:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6036C28DAB; Wed, 20 Jun 2018 09:40:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AE2528D9B for ; Wed, 20 Jun 2018 09:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754435AbeFTJjY (ORCPT ); Wed, 20 Jun 2018 05:39:24 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:37729 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754311AbeFTI3U (ORCPT ); Wed, 20 Jun 2018 04:29:20 -0400 Received: by mail-wm0-f68.google.com with SMTP id r125-v6so5174234wmg.2 for ; Wed, 20 Jun 2018 01:29:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VX6K7u7qWji4zJugSW5OO83CLqi3CHnY/zhW1WkICh0=; b=uO9X2bjwdnNhGe8khgQKeiQ6uv9RU0NgRdpgPFndN5q1j8q4HeaFVANrH9ozsuXq5i cLZ9NCWwRdepANzNHt75tR7aEcXzKGGBgtKcBIyYlJsJekv3/uLC9MgKrENRfVZzwPTg W4+SB6b3kb1fzfwHsNKX9OUsk5z7YCCeGFfQcr/VQWE91GGm7LzgLIfgIHfOvn8A7oD+ Chh1GiT1j2ZtfqSfBIfeNyGIY9jVa6L2MxttaE9evFrsskjAcD8qWT6mrivi+j9nIqr5 RWm0CLOM+KC5+xf7msVZInXh2e5JAQz4ua+kol3TtYXZV2ajsLIwCjIQUPVWWZvZldup 2Mww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VX6K7u7qWji4zJugSW5OO83CLqi3CHnY/zhW1WkICh0=; b=cgHOK+ypNZFLTob6t3HviqCt3lpag16Fqn+yMKN9XYXzlQuWXph8/rCcCZIk/IDxWd k1ZU0RmX6et9V4pTePldBJ+M1RB34JVk4jfu85DjCRkmBTRPSOByPffL1ZLWHZO0oWAE uBILrtVcepW4eQ4VWBhLh1y8v55pU/9ZxkSXfGTI8oQfPLbpF+8ZJc0BiGGQqn3jG6z1 EWAWOP1bzg78lshoG3pt5L6g7Xb1GQBKIMBXVWHoJYij5DFYA+3cRZ3iM/2DZ3elNqMW /YfL1yJEPhzepXWAAP7cXd5QhylMIC+gtzc1lxOZucM/NY4pZFGVPg3mYl6/eR7iQUxV SAIg== X-Gm-Message-State: APt69E2FOdZFuUWHe1XS2CU/dwvIcBufBGd1VYIEUfbiE6YquBSgu92S G+tbfI2mCyUimRRVKj9yzPlprA== X-Google-Smtp-Source: ADUXVKIBf/IQJqDsp0CsZWpgs/AJDY/kKFl/9ykSNhQNx1Tj2hCzjis4UQdTbXQvUJ42/YlNaxQwSw== X-Received: by 2002:a1c:9d49:: with SMTP id g70-v6mr865653wme.134.1529481844169; Wed, 20 Jun 2018 01:04:04 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-13-249.w90-86.abo.wanadoo.fr. [90.86.134.249]) by smtp.gmail.com with ESMTPSA id t14-v6sm2131704wrm.79.2018.06.20.01.04.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 01:04:03 -0700 (PDT) From: Bartosz Golaszewski To: Grygorii Strashko , "David S . Miller" , Florian Fainelli , Dan Carpenter , Ivan Khoronzhuk , Rob Herring , Lukas Wunner , Kevin Hilman , David Lechner , Sekhar Nori , Andrew Lunn Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , stable@vger.kernel.org Subject: [PATCH v2 1/2] net: ethernet: fix suspend/resume in davinci_emac Date: Wed, 20 Jun 2018 10:03:55 +0200 Message-Id: <20180620080356.11900-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620080356.11900-1-brgl@bgdev.pl> References: <20180620080356.11900-1-brgl@bgdev.pl> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski This patch reverts commit 3243ff2a05ec ("net: ethernet: davinci_emac: Deduplicate bus_find_device() by name matching") and adds a comment which should stop anyone from reintroducing the same "fix" in the future. We can't use bus_find_device_by_name() here because the device name is not guaranteed to be 'davinci_mdio'. On some systems it can be 'davinci_mdio.0' so we need to use strncmp() against the first part of the string to correctly match it. Fixes: 3243ff2a05ec ("net: ethernet: davinci_emac: Deduplicate bus_find_device() by name matching") Cc: stable@vger.kernel.org Signed-off-by: Bartosz Golaszewski Acked-by: Lukas Wunner --- drivers/net/ethernet/ti/davinci_emac.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 06d7c9e4dcda..a1a6445b5a7e 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1385,6 +1385,11 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd) return -EOPNOTSUPP; } +static int match_first_device(struct device *dev, void *data) +{ + return !strncmp(dev_name(dev), "davinci_mdio", 12); +} + /** * emac_dev_open - EMAC device open * @ndev: The DaVinci EMAC network adapter @@ -1484,8 +1489,14 @@ static int emac_dev_open(struct net_device *ndev) /* use the first phy on the bus if pdata did not give us a phy id */ if (!phydev && !priv->phy_id) { - phy = bus_find_device_by_name(&mdio_bus_type, NULL, - "davinci_mdio"); + /* NOTE: we can't use bus_find_device_by_name() here because + * the device name is not guaranteed to be 'davinci_mdio'. On + * some systems it can be 'davinci_mdio.0' so we need to use + * strncmp() against the first part of the string to correctly + * match it. + */ + phy = bus_find_device(&mdio_bus_type, NULL, NULL, + match_first_device); if (phy) { priv->phy_id = dev_name(phy); if (!priv->phy_id || !*priv->phy_id)