From patchwork Tue Jun 19 12:44:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10474225 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 54E406029B for ; Tue, 19 Jun 2018 12:44:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42AF71FF60 for ; Tue, 19 Jun 2018 12:44:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35F9F289E0; Tue, 19 Jun 2018 12:44:20 +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=ham 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 503281FF60 for ; Tue, 19 Jun 2018 12:44:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937793AbeFSMoR (ORCPT ); Tue, 19 Jun 2018 08:44:17 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:50251 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937775AbeFSMoP (ORCPT ); Tue, 19 Jun 2018 08:44:15 -0400 Received: by mail-wm0-f65.google.com with SMTP id e16-v6so170147wmd.0 for ; Tue, 19 Jun 2018 05:44:15 -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; bh=ADA5Q+NCfXV/mZjpNHccIMsB+3ZlXTeJHda7DVng7Y8=; b=DS04SrduV2R7sqXC3OLvfJD5CreVPYyANC5MhFbo85eF0TURJ+93PKyhdbjNoK1pkF f9rOxGf+M6G+LHws+ARD3Fn1PqK1vo7fTtPFLSVNhuvhRsa9iC2cm6H6HkcUQhPjNbAS i6uVLwCuQ4g2v9L+A5tSdm1MxuLvTgSPVO65AnlD7PWB9aBNcj4pw2KCxixuKgij/Eul DVkOgdocTOP5Xs5KZ/3r49R4PTeUyCe7XBVjnYOAJ+CrZllVI8xuTPL/HulFtM8Xz3Tg FWgitD3FS5LZud43iEpagM4rgcG+jBvEdmE82fDZ2EwNhe6KcdpuYyGlQPgm5a/633b0 yfcg== 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; bh=ADA5Q+NCfXV/mZjpNHccIMsB+3ZlXTeJHda7DVng7Y8=; b=ncA4kdHpEkrg5xQ8ss+h584mrMX956/IlSwfISfCLiFSfyFuyZWS0mgtKrpqRIDlKk jPUccHn/hFUyeTCce0MYdJYdfaKEAa8T4KLhbO9wcHbwYSQQ97tcO0M4surtlmRlORL3 fYqnPTz6+9JnlSS6Z5WLk+97rZgROrRgQ4T+JBotws0sRxPAejy17R0rdb7D5p4ei0Vn smxHJ6X8vTmVdvZkMRQcwHFfgZG20dcZHCmtoGwH5TbvC7u5SQakAiMQQUpcUYoDNrv9 Bwsvt9Bc/IDPn73NDI5uCU12a1yBd1LszX3VWRuQB5uSB+y0+ebNjNOwM554qI9txGPT Yp0Q== X-Gm-Message-State: APt69E0CNSM4vxfkGHiZI8/u1gSZ+7k6/k7UVTsuB3vsn6/u4Z+5FrwK TTGS6JPr0RF+CZemO+i27MqkOg== X-Google-Smtp-Source: ADUXVKKQpPIPK8mrPit/VRmMLzzYbEfPEv5OJbXjpCzhHvc0cQvGbDZ048SYPbIikItePVqcqrSekQ== X-Received: by 2002:a1c:3504:: with SMTP id c4-v6mr11009875wma.59.1529412254584; Tue, 19 Jun 2018 05:44:14 -0700 (PDT) Received: from brgl-bgdev.lan (LFbn-1-7080-22.w90-116.abo.wanadoo.fr. [90.116.249.22]) by smtp.gmail.com with ESMTPSA id r2-v6sm18591142wrq.55.2018.06.19.05.44.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jun 2018 05:44:13 -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 Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , stable@vger.kernel.org Subject: [PATCH] net: ethernet: fix suspend/resume in davinci_emac Date: Tue, 19 Jun 2018 14:44:00 +0200 Message-Id: <20180619124400.11878-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.1 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)