From patchwork Thu Nov 9 21:51:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 163614 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp727706vqs; Thu, 9 Nov 2023 13:52:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdLfxSDZnvM3mJVq7902rvtsEtYWXeBbU3WnpESRF3K7w0MtgQkH1GfT+GSZcRLqumdsex X-Received: by 2002:a17:902:f7cc:b0:1cc:361b:7b10 with SMTP id h12-20020a170902f7cc00b001cc361b7b10mr5688220plw.24.1699566739356; Thu, 09 Nov 2023 13:52:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699566739; cv=none; d=google.com; s=arc-20160816; b=yAt0ptm/rbFTKEIpoR7snEt8GCuOeN/cC+SGNuldR5m/olM6acIK7XnRlYo3GIF7dO o5IARq7DDAJEPC8jcYBhBDLwH+UUvxC7XgzyPYzpYvBKyCOfDivG4G1fTnHKR8dQ3PAl IpmTE1RmeFglMH7s4tRAYNEMxKr4Rf7H+DEE2Ek9I3KGXABxT1q4r1+Dt3mNX+86tvUf 5f06eDybmGI5lvlJhJfKgOhKAdfRJTt+WezuC3KnNdYTxCmHdL1K88Ug6EDmZbFOQ16q VKZPUsE+azZwwkUTPijRIXM3pZiJAsra+sNz1WuE2YmozfNaayZosBF5vjoDyGNJNAvR o9Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=Kb+2yvlTQrGKxKDtG+tM4Xj4phSgbeCggxJFtRdqXbc=; fh=9GVzMIks0k0Waq6W0HUSHcdxejYnykUnl93AUDny5kk=; b=UbMpHqJheVhUwOuGWMn0C6A7R5I3k3k52QuRkLXB0p6+VF9o0dCxRXLf0SfXvdePPd oV9/rBFbMiqtl5e9HC2K8L2qwsWF3ReKwgOPK/USB64hX/exe/smJg+Z+6rj+RICyJ2P 19iwpMt4a6+D96YgYlv/ZK9OCwAKhhAlFmkAD3KAqUv0R7y9mWSKIV5hrOL2HibMrRP7 yH14TEpk3tAYEk/CA1mSzzbFJFF9ykmmxpjFOCfKFWmMER4DVEN00+iX4Q+iW2R0eccJ UxLTPan9tEJkftW9bZdWtRsPTy+ZJVV7ML9jHphoykkUVnVclzfbybTENRr5WY353Wzs AsaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id x12-20020a170902ec8c00b001c6183af4d3si6522500plg.332.2023.11.09.13.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 13:52:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id B59EB829B3E4; Thu, 9 Nov 2023 13:52:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345320AbjKIVwC (ORCPT + 30 others); Thu, 9 Nov 2023 16:52:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234801AbjKIVvv (ORCPT ); Thu, 9 Nov 2023 16:51:51 -0500 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6581B44B3; Thu, 9 Nov 2023 13:51:49 -0800 (PST) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96.2) (envelope-from ) id 1r1Cw6-0003XH-0Q; Thu, 09 Nov 2023 21:51:38 +0000 Date: Thu, 9 Nov 2023 21:51:34 +0000 From: Daniel Golle To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , Matthias Brugger , AngeloGioacchino Del Regno , Andrew Lunn , Heiner Kallweit , Russell King , Alexander Couzens , Daniel Golle , Philipp Zabel , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org Subject: [RFC PATCH 4/8] net: pcs: pcs-mtk-lynxi: allow calling with NULL advertising Message-ID: <0dcc5efc480b640d184046ba405a44bada88f88b.1699565880.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 09 Nov 2023 13:52:16 -0800 (PST) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782124892936296510 X-GMAIL-MSGID: 1782124892936296510 Allow calling pcs_config with advertising set to NULL and in this case keep the previously assigned advertisement. Signed-off-by: Daniel Golle --- drivers/net/pcs/pcs-mtk-lynxi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/pcs/pcs-mtk-lynxi.c b/drivers/net/pcs/pcs-mtk-lynxi.c index 6204448d8eac6..1372653c3d422 100644 --- a/drivers/net/pcs/pcs-mtk-lynxi.c +++ b/drivers/net/pcs/pcs-mtk-lynxi.c @@ -81,6 +81,7 @@ struct mtk_pcs_lynxi { phy_interface_t interface; struct phylink_pcs pcs; u32 flags; + int advertise; }; static struct mtk_pcs_lynxi *pcs_to_mtk_pcs_lynxi(struct phylink_pcs *pcs) @@ -121,11 +122,19 @@ static int mtk_pcs_lynxi_config(struct phylink_pcs *pcs, unsigned int neg_mode, unsigned int rgc3, sgm_mode, bmcr; int advertise, link_timer; - advertise = phylink_mii_c22_pcs_encode_advertisement(interface, - advertising); - if (advertise < 0) - return advertise; + if (advertising) { + advertise = phylink_mii_c22_pcs_encode_advertisement(interface, + advertising); + if (advertise < 0) + return advertise; + mpcs->advertise = advertise; + } else { + if (mpcs->advertise < 0) + return -EINVAL; + + advertise = mpcs->advertise; + } /* Clearing IF_MODE_BIT0 switches the PCS to BASE-X mode, and * we assume that fixes it's speed at bitrate = line rate (in * other words, 1000Mbps or 2500Mbps). @@ -299,6 +308,7 @@ struct phylink_pcs *mtk_pcs_lynxi_create(struct device *dev, mpcs->pcs.neg_mode = true; mpcs->pcs.poll = true; mpcs->interface = PHY_INTERFACE_MODE_NA; + mpcs->advertise = -1; return &mpcs->pcs; }