Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2609468ybt; Mon, 22 Jun 2020 02:45:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5BbL5AT3SVhcFVFk8phGUZSFvvUXuTq1PN496k2pkH9ahOADsg2yLyjKCBWVpOkXQ/iMU X-Received: by 2002:aa7:c80d:: with SMTP id a13mr6365691edt.327.1592819114514; Mon, 22 Jun 2020 02:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592819114; cv=none; d=google.com; s=arc-20160816; b=oAimwpAGAsLi8F6yJcLq7vH61CviKnC2CggRBYHbkRsOo54VS07mykis7ZGfLbzQlj jn1Pwac2PWal7ZU0RwLKUh0PRpIXusk5Dbi1vnfgVBzRe1QFRoyP7pXJA/kqAtV9A+xs +cG4hg2Pbuve3KCRpp0Wtd74taX5loWxpq3k9s1jYNjAPILlyS9g4RFB0+XxNRuUm2hc R6ibdurL9gdgyPwkT64B1+sfNQjp7nXiL4dlszs8QqzHVq9jtmQ9L6Xr/EVAdVgAudMl MckaO1NVsm/BVyNIPseaItqsmtCvEMXEoTTYFyVmtbsndj+9NdasBn1rmKmIWLmW5aa4 xedQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cfUc+TkUAgqz9MdoL32AGr8CBlEvrLInm5v62775Pps=; b=okY+fkXM6mBSrcjhN9C7YAIdGlIH/7CU1uQiTtcHnMui+uEKdb1VXlziopXGKAc0M0 tbAtigcLBpdaNr6xk4yYs5Yg54EXEgKbw11hQv0zri4VKnP9qX9upROB4CdjhhwSuZ/n GubPnIqHjkWfgmRR5aXUUU0wfYhrKmZM/dAibR4CFoemm2SQ9kDebjQPGh6Gl4TnQjS2 BrlUPHeWv3KO54vwal3WcqiL2xznFQ8A4wgJ1nen7rjOz2nUScPKEH9bVrs9CfgOmPsL 3XnPUB/BGOOLM/Niv57+dhZvOAD/pboGXnKB9w6S5DXhWdT5Ut9W/vGZQLCQeqRsiRTb qHHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=A2nZUOgn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si2602886edx.162.2020.06.22.02.44.52; Mon, 22 Jun 2020 02:45:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=A2nZUOgn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727124AbgFVJln (ORCPT + 99 others); Mon, 22 Jun 2020 05:41:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727010AbgFVJlc (ORCPT ); Mon, 22 Jun 2020 05:41:32 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2259CC061795 for ; Mon, 22 Jun 2020 02:41:32 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id a6so13983894wrm.4 for ; Mon, 22 Jun 2020 02:41:32 -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 :mime-version:content-transfer-encoding; bh=cfUc+TkUAgqz9MdoL32AGr8CBlEvrLInm5v62775Pps=; b=A2nZUOgnmx1UP+ORv6aiykQQt+lLSQ1KO7Odnx9nMWmPGWBB/9zwG2qDldAgXJmqFF xP5a4eGOadOLgU5l8x7N7j9+z2XQcTH/rFKkU1WWhZmJmVhXF2hTLLfHyQ5etAtMHKmX GzjJGiUtKBqAj3ZO+9U33Aqe6H7sc3uFms0oEry7uZGxugnSgJBjckjsDuq2/0a7BeEq I4qul8QuxKe+CEztgYEFZDIF1pwVYkuHKS4ZkApg+YQ/TcNclWYBEankibn6cVK3MPY7 ZU+9DUlAqUZCkiO9dP4Q1H37N9frUcXcUiOti5AX0YjukaK8I91Rvini9mJsIrmoYDWK Og9w== 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:mime-version:content-transfer-encoding; bh=cfUc+TkUAgqz9MdoL32AGr8CBlEvrLInm5v62775Pps=; b=BswNjuFz2ZIYLgc78pNLBlJgRO13rIOkEJ44gCgak/rP6aQZt7Kz7p974CBDJwmYuu R7f99qUWI/c2BtE4dlbbnjf3LA6Mr+UsTQyk+WpUQyXYnzjGMHZn0moGPbptIwFndKQb hYu/arsqodCaHfYlqqjDcsr+OUhES2B/IS1+1vrlfMdZEYKWroO/q4W20Yly7AOKZlDd nmiZEa//IV7cxpe54NrfILeaB6OBPkiOwAcZyWlfiMBW+gPoEqlzBB7n+AjJ3A3K7Kfo 4dGnzXTo4qCTniVlHmYFsrM8wvQc0R4+D9WtnczxOKeV1hZNJgeQCiMbnZQxmTr1oBnP BEeA== X-Gm-Message-State: AOAM531YIoQ+cSokS23Lm6ye3utfJPr7cpxaA1hk7zPi7FdibnPVllVH J3k0AxkhL4HNQwSrcJyPJsP5yg== X-Received: by 2002:a5d:470a:: with SMTP id y10mr5777035wrq.405.1592818890889; Mon, 22 Jun 2020 02:41:30 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id j24sm14392652wrd.43.2020.06.22.02.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 02:41:30 -0700 (PDT) From: Bartosz Golaszewski To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Rob Herring , Matthias Brugger , Microchip Linux Driver Support , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , Vivien Didelot , Tom Lendacky , Yisen Zhuang , Salil Mehta , Jassi Brar , Ilias Apalodimas , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Frank Rowand , Philipp Zabel , Liam Girdwood , Mark Brown Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Stephane Le Provost , Pedro Tsai , Andrew Perepech , Bartosz Golaszewski Subject: [PATCH 05/15] net: phy: reset the PHY even if probe() is not implemented Date: Mon, 22 Jun 2020 11:37:34 +0200 Message-Id: <20200622093744.13685-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200622093744.13685-1-brgl@bgdev.pl> References: <20200622093744.13685-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski Currently we only call phy_device_reset() if the PHY driver implements the probe() callback. This is not mandatory and many drivers (e.g. realtek) don't need probe() for most devices but still can have reset GPIOs defined. There's no reason to depend on the presence of probe() here so pull the reset code out of the if clause. Signed-off-by: Bartosz Golaszewski --- drivers/net/phy/phy_device.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 1b4df12c70ad..f6985db08340 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2690,16 +2690,13 @@ static int phy_probe(struct device *dev) mutex_lock(&phydev->lock); - if (phydev->drv->probe) { - /* Deassert the reset signal */ - phy_device_reset(phydev, 0); + /* Deassert the reset signal */ + phy_device_reset(phydev, 0); + if (phydev->drv->probe) { err = phydev->drv->probe(phydev); - if (err) { - /* Assert the reset signal */ - phy_device_reset(phydev, 1); + if (err) goto out; - } } /* Start out supporting everything. Eventually, @@ -2761,6 +2758,10 @@ static int phy_probe(struct device *dev) phydev->state = PHY_READY; out: + /* Assert the reset signal */ + if (err) + phy_device_reset(phydev, 1); + mutex_unlock(&phydev->lock); return err; @@ -2779,12 +2780,12 @@ static int phy_remove(struct device *dev) sfp_bus_del_upstream(phydev->sfp_bus); phydev->sfp_bus = NULL; - if (phydev->drv && phydev->drv->remove) { + if (phydev->drv && phydev->drv->remove) phydev->drv->remove(phydev); - /* Assert the reset signal */ - phy_device_reset(phydev, 1); - } + /* Assert the reset signal */ + phy_device_reset(phydev, 1); + phydev->drv = NULL; return 0; -- 2.26.1