Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5135578imm; Tue, 19 Jun 2018 05:45:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIKqQmKrmOOXJEJC4wwFAIi4YO0N0ti1VsvaJP7aGS/8GJIcIkR2yuTy+VsMubo5T043Yol X-Received: by 2002:a62:8917:: with SMTP id v23-v6mr13747907pfd.127.1529412312491; Tue, 19 Jun 2018 05:45:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529412312; cv=none; d=google.com; s=arc-20160816; b=bggwJXRrFSkiomuJtAI537TOJqc1B6r3/rrHeUNIrZW5zA9csIbIiFa++/s3xdBU6T AUa/6C8lGTkJeFTF0+Nr3iuAxOSCUxkfs6IAKUg5ooD1XyHzuInFJkj5T3xM1N+MJnFy Sad21iFjj94ihlIDpImVxlrOS5zyS5vsYWTUK4J6Y9ghQZkYBmwtXgzordFQ5YHu3/hC jGx1ph7Vt785LYp8QlDsU212pHd9D3+8Xopz2fJHGg5GordJFahAWBjrPXcq73vlJwsS wRP6ZBp5qYQnpT3jf5ClKd6ACbi0hXJLyWezVBYLJcE6y4UzaTr3C89qM9yrPF3SP+4X 4MWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ADA5Q+NCfXV/mZjpNHccIMsB+3ZlXTeJHda7DVng7Y8=; b=FK5yLyyDaK6iH9QQ4O5XdJ8pe5odPbc4/C5m2lwGNp3IMgKrflMmAOngXFnUnnotjt aBZ4JgLvRT9OsXZMPp/CI4gw0efV1gMBDX0jjMsmseJJRHGaq2ZRbGH3Udh847+LpOmj W62krR94i4Qah2VFrK0rB+OzsuPAaRE2BctnxKq6bRxay3Oo7mi2XOuHF0yerNSwQNLF CLB2qPjttiz2/abfxQLRG+gmizIIvy/3zssJVRd3+5EJAFtvQgikpTmPq4SGI9ii6Vl1 VeR3k/pD5P5Qnq4+ZEvtc8cwVbH86gGMLM3YnQ3WIqDMdqtOSnUaDOMw5KjlP/HGzqll 8WWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=DS04Srdu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z23-v6si16152825pfh.266.2018.06.19.05.44.58; Tue, 19 Jun 2018 05:45:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=DS04Srdu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937821AbeFSMoS (ORCPT + 99 others); Tue, 19 Jun 2018 08:44:18 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53663 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937771AbeFSMoP (ORCPT ); Tue, 19 Jun 2018 08:44:15 -0400 Received: by mail-wm0-f68.google.com with SMTP id x6-v6so140596wmc.3 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=kX4qzWqqo+7b0D/zVx7m14zIQFgWCUreuVRev4U2rT1uq3OE9cucdDxPpgm+zyKCf8 AZ64dx81IhfFhqJQeZqnbdmOSRlvBayc/D71wtsyuW1/+RO4JOd5hvW0WbCgKCUc2ref MiwYkx5XZq1w2ifr0UiUCNd0Vvd2tQZVTbsQUV3WU+xBaCjsQPcB0NCReNi0u2TSqgfb kPN+83KASFus1NvYSQYjN8B1Bo4oT9MVajmUDssHL6JmEjE93VAfPtWReswmB/nYBgYD U8NZPCzJ7LJ3cvw1QmzW/gJ9eaZoWshUGp2GQy2hL8AusitTRULKm8/gNeI9msRDQTiu B5Vw== X-Gm-Message-State: APt69E1IyuYon/PeCZp8NOk0kCHbPdqOugTX9cvB8LFnw/pDGAEX+mca XAM8RZOxyQNpPCNIAUv6s6/iuTfWoC4= 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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) -- 2.17.1