Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5363660imm; Tue, 19 Jun 2018 09:13:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKICL66xyjG+8w1+eBlrMGG5ZPlAumxvQo5IGBiYH0Xooq5Xf3659taFuh1vBdS11mG3yVna X-Received: by 2002:a17:902:292b:: with SMTP id g40-v6mr19760582plb.273.1529424818951; Tue, 19 Jun 2018 09:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529424818; cv=none; d=google.com; s=arc-20160816; b=is/4G42XKdSKaAL2w6jiiIbOUHshqJQO3e7Ykf3UmvNG57gVh0C/XFqunWm00/qY6s M5zpohmX2/u06amI9bWPFXkx+RdOVYaqpMIDiBkCyduzsjp5cCRbTEhjW+4ynKdjCSn9 Fh0mmuJLiu7BnnZJ1eN6HH2g/GBldz4gG4AuTCAzVHu8y2euqKniDFN+1Nan9rGjA2eO w9o+LSBdZzXcEbkC9qUHYJAr3bIVekYGXEahtx4UJ3vlv5c+EwJAZ2pKTicRSd/fWLbx w+j5cYUh7qSKW/yHAOOMyLvY65sj6/qoRAdYi5qe9KaBbGUkvpHAE94N4nW/ioRSXGff FY6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ADA5Q+NCfXV/mZjpNHccIMsB+3ZlXTeJHda7DVng7Y8=; b=pEgk3MTVpHm5kcpm7Ir7QKowppJ7ivYpRQKWofnYyYWbOn/ugI/BYBG9RxCWwi1pXL CSOhzI8fUbHiQeAIHMvCkXCFCvZyMfQhny5OqtKEEwXbMieMr3xelANKSUCpBavdKeWv KYbJaXOxSKrLmueY2b2OBT7SAjGZyMA545tbk9N8tYkelKU88PkCamXGw1258FdQhcOT IGLhJ6E+LuQzvke6oiH3Ul/wCyWvTuF/RJer6u3JU6PUVEH9THZevrXS9V5DebSFd4rQ YKc3s/phZFGcNuUXeMQEhI4lpLCRBsmXFJ6UXiFVLwOX0of0SVLdvMsx1Zxw9YIuUDO+ oOdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=bBpTNjNM; 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 x7-v6si40455pfd.124.2018.06.19.09.13.25; Tue, 19 Jun 2018 09:13:38 -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=bBpTNjNM; 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 S967118AbeFSQLM (ORCPT + 99 others); Tue, 19 Jun 2018 12:11:12 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:42458 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967032AbeFSQKA (ORCPT ); Tue, 19 Jun 2018 12:10:00 -0400 Received: by mail-wr0-f196.google.com with SMTP id w10-v6so224839wrk.9 for ; Tue, 19 Jun 2018 09:10:00 -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=ADA5Q+NCfXV/mZjpNHccIMsB+3ZlXTeJHda7DVng7Y8=; b=bBpTNjNMWGfBcInQXTydKWpkkzcjkPqmELo2IC3aJzFG5vhhO68Kl96rVhzwWD1lef j8cQ0jxsj22Ss3QHCRSC+GhP3MS/5v5XGYgz5neFqGnCIXtslLfJlF3XIr8X3xS/S68C JvpsMO1HZjwTdBmbFzyehVZBc2J6s6kEK2+NUivE+WXhDCEM21uNdaqEEMW8XTR4MZx1 5Fm8dpGDSFkNYlZJLR7W7U7pjEhJhw+GytVpU9eirODwjqU16uxel0nkHnYZ+bzAlKKN 9LJju5NCLurKsHI9elnm35xyE/EHyMAM6ZMkmOcM0kmDP56stxfuYo0hd53yRDfXfVGo 1rxA== 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=ADA5Q+NCfXV/mZjpNHccIMsB+3ZlXTeJHda7DVng7Y8=; b=MXfmbRjhtnae8dJAqlTccwNmtjEsyUczlVoPkJFGQxkWrXMltf+FmZ+GyP3Ex5UFgG h+8iIAcCPGKGp4kpQ9QjFmoQzYhJcP+fUd/AmP7vPSIh4katAUdpd9fYk9DtKdbYa954 AvODcYGQKdGEdT6ixMrwvNNtpLcZhE0a4e3yQ1uFlMsqP5xWrfSr7sysQC0EqGxmHSZb AOVJsfbeZIu16XWZeldHVbbw2rvuXAzCOysROQH4CEpptZKx59pP5ThTLEjGBuXw1dU6 90GpJ+VJ7pycd/WbrWH5oJ0PwsDkpL/q/Wkl9GaABPpCxTI7nZYP8ubzo/8Xn3FNTL47 YSUA== X-Gm-Message-State: APt69E3hc12RJRf0mp1t2Z2Z9/yibdy4y30N6GFi8DWgYuaisx/Z4eq+ FCtOdk//yExXfKwvQGXlDBuWew== X-Received: by 2002:adf:9d02:: with SMTP id k2-v6mr14388213wre.213.1529424599631; Tue, 19 Jun 2018 09:09:59 -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 74-v6sm619327wmt.31.2018.06.19.09.09.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jun 2018 09:09:58 -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 1/3] net: ethernet: fix suspend/resume in davinci_emac Date: Tue, 19 Jun 2018 18:09:48 +0200 Message-Id: <20180619160950.6283-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619160950.6283-1-brgl@bgdev.pl> References: <20180619160950.6283-1-brgl@bgdev.pl> 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