Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2827579pxb; Mon, 1 Nov 2021 02:39:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7Cg/AV4/ttvkV5nyQWnRdxVgSUAfuT4Y94MgsDlQIJbGiUja/EtNj+J4p4h8tMwPjx7U2 X-Received: by 2002:a50:a40e:: with SMTP id u14mr19637642edb.164.1635759572712; Mon, 01 Nov 2021 02:39:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635759572; cv=none; d=google.com; s=arc-20160816; b=J8JP2DvsauFcxcptRJnG6sj4547NjP3RmN5+AzVMGoABlJSrCQDv8bTYYExO2P/EQ9 9R80iDTDMu7xggu9FZs0xK/JH8TioVyLJrlritRPCnzTedXOLcFsU4Pde6Eds6XPvabf v54NPDNFwL5j0fHedH8uwX1nTU1kM23qEIFCAt5sD9B1HP0CQzjcs4D/bVz8EDXL4a71 qMveDInNsii/YjVJhBemwVXAwewpkUGax+Si9oZ9ZP6rOd0Zgou+bCxIzkEfP6mPjXJI a3Car9i+qY4EJjiXqLOJ/FqxBUt/njUJXRHv0bCe9d73P2XAH+z2QQbaFjWfGW21bqfJ QPgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/EMVkPHKYLESwYVMYPdZ45P5hoJ+NILhReMyR3d2KBk=; b=ctQBBl3jHAiN7/NBWmjoYLiLvBUbDxg5j4ILZLo3qHJZ+3WJB4zI2IayfPrHbzBZUC CHlCq7z+1gK9y1YHPHLTEXfoIFfr5Wqbk2opU4uOb+mPk6ZyZigqdjDSwjeI6OGd8JYz 6+K480iYNuEWGfZZz4ZTxWYO5T404B2pxfKGYFkvtvhHVCPyhe5JFpiWGni6IqBO/sZE EjKH40IN2sq893/5zKW0SPQC6HUBf16pdPyOV2lBwXbt5OxYHjgopoNdEXjGOQi6B/Ds sus3K9zfZIpHh/r0eZup259SXeSAAkcmOsUJjkuGgexfOmTpijkSmyOgiCnc90/59d44 GzSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AKoc42QY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kz1si19289425ejc.7.2021.11.01.02.39.07; Mon, 01 Nov 2021 02:39:32 -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=@linuxfoundation.org header.s=korg header.b=AKoc42QY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233492AbhKAJjt (ORCPT + 99 others); Mon, 1 Nov 2021 05:39:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:43562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233633AbhKAJhp (ORCPT ); Mon, 1 Nov 2021 05:37:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9446E6134F; Mon, 1 Nov 2021 09:26:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635758798; bh=Yra+beBhWD7jxPbK6Qw8ggXqe3M9mzT9u8IUB9ffgVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AKoc42QYEphlPEhv0eYjxSAS1eWL650Hu0Zz9q/Us8/5YKP2rGq7oG6Rd8o9SULLc zP4S7nItPTaBaYFoooJDGH0on5GduTnGB0cLgVWwhDpcglU9OwvCg+wNg7wEUMAQKX jh+JhshNJlS47OzDdxFaCL7zTLHUprYh9lbDlgbw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Lunn , "David S. Miller" Subject: [PATCH 5.10 62/77] phy: phy_ethtool_ksettings_set: Move after phy_start_aneg Date: Mon, 1 Nov 2021 10:17:50 +0100 Message-Id: <20211101082524.670392917@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101082511.254155853@linuxfoundation.org> References: <20211101082511.254155853@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Lunn commit 64cd92d5e8180c2ded3fdea76862de6f596ae2c9 upstream. This allows it to make use of a helper which assume the PHY is already locked. Fixes: 2d55173e71b0 ("phy: add generic function to support ksetting support") Signed-off-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/phy.c | 106 +++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 53 deletions(-) --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -260,59 +260,6 @@ static void phy_sanitize_settings(struct } } -int phy_ethtool_ksettings_set(struct phy_device *phydev, - const struct ethtool_link_ksettings *cmd) -{ - __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); - u8 autoneg = cmd->base.autoneg; - u8 duplex = cmd->base.duplex; - u32 speed = cmd->base.speed; - - if (cmd->base.phy_address != phydev->mdio.addr) - return -EINVAL; - - linkmode_copy(advertising, cmd->link_modes.advertising); - - /* We make sure that we don't pass unsupported values in to the PHY */ - linkmode_and(advertising, advertising, phydev->supported); - - /* Verify the settings we care about. */ - if (autoneg != AUTONEG_ENABLE && autoneg != AUTONEG_DISABLE) - return -EINVAL; - - if (autoneg == AUTONEG_ENABLE && linkmode_empty(advertising)) - return -EINVAL; - - if (autoneg == AUTONEG_DISABLE && - ((speed != SPEED_1000 && - speed != SPEED_100 && - speed != SPEED_10) || - (duplex != DUPLEX_HALF && - duplex != DUPLEX_FULL))) - return -EINVAL; - - phydev->autoneg = autoneg; - - if (autoneg == AUTONEG_DISABLE) { - phydev->speed = speed; - phydev->duplex = duplex; - } - - linkmode_copy(phydev->advertising, advertising); - - linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, - phydev->advertising, autoneg == AUTONEG_ENABLE); - - phydev->master_slave_set = cmd->base.master_slave_cfg; - phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl; - - /* Restart the PHY */ - phy_start_aneg(phydev); - - return 0; -} -EXPORT_SYMBOL(phy_ethtool_ksettings_set); - void phy_ethtool_ksettings_get(struct phy_device *phydev, struct ethtool_link_ksettings *cmd) { @@ -818,6 +765,59 @@ static int phy_poll_aneg_done(struct phy return ret < 0 ? ret : 0; } +int phy_ethtool_ksettings_set(struct phy_device *phydev, + const struct ethtool_link_ksettings *cmd) +{ + __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); + u8 autoneg = cmd->base.autoneg; + u8 duplex = cmd->base.duplex; + u32 speed = cmd->base.speed; + + if (cmd->base.phy_address != phydev->mdio.addr) + return -EINVAL; + + linkmode_copy(advertising, cmd->link_modes.advertising); + + /* We make sure that we don't pass unsupported values in to the PHY */ + linkmode_and(advertising, advertising, phydev->supported); + + /* Verify the settings we care about. */ + if (autoneg != AUTONEG_ENABLE && autoneg != AUTONEG_DISABLE) + return -EINVAL; + + if (autoneg == AUTONEG_ENABLE && linkmode_empty(advertising)) + return -EINVAL; + + if (autoneg == AUTONEG_DISABLE && + ((speed != SPEED_1000 && + speed != SPEED_100 && + speed != SPEED_10) || + (duplex != DUPLEX_HALF && + duplex != DUPLEX_FULL))) + return -EINVAL; + + phydev->autoneg = autoneg; + + if (autoneg == AUTONEG_DISABLE) { + phydev->speed = speed; + phydev->duplex = duplex; + } + + linkmode_copy(phydev->advertising, advertising); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, + phydev->advertising, autoneg == AUTONEG_ENABLE); + + phydev->master_slave_set = cmd->base.master_slave_cfg; + phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl; + + /* Restart the PHY */ + phy_start_aneg(phydev); + + return 0; +} +EXPORT_SYMBOL(phy_ethtool_ksettings_set); + /** * phy_speed_down - set speed to lowest speed supported by both link partners * @phydev: the phy_device struct