From patchwork Fri Jan 5 08:23:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13511825 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D55A2E630 for ; Fri, 5 Jan 2024 08:25:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="gsgGM5Lt" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5569472f775so1560295a12.2 for ; Fri, 05 Jan 2024 00:25:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443111; x=1705047911; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5U2pCYzsTsR2Xw27TGhf44nRfdvpa0/cuFsAnchyMS4=; b=gsgGM5Lt+4lEhMw05w9UEQd3DGPWmnaC5f0z0sLslPQpx9dpaeKjQEp5k9f3pO2yy2 lzn/2HBTokVHEa02+U4zjBDDXOoqaiv+f3XuyoEWSMpVsjyvERRMKj6vJFuCPrlI5foX AQy7kCNLwvS8/abhkZZW4+K30yCTdkbNh9y/3MHbpAuaskEGwF1KE9Mbvq8tcM+NMGt2 GRJbt8nK39bKsylVPs/XjBcn2R2amhqEamfaaV1OCXF6S6qcegdSkfgwXZfZTU9Aac2t ty3yBpgmN3G1G5Ki9orffF3G4CNbMErPHqYnCT6XDG6YMHEuYyW/FoNrkPImP+4hVBh8 ZkHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443111; x=1705047911; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5U2pCYzsTsR2Xw27TGhf44nRfdvpa0/cuFsAnchyMS4=; b=HmUfi/j4xYibRWdXKeUX5L7RURwdN7314juz+DhxXEIGkjLBgwz8vMywGeY94Plpkt O1PUUlqm7ME3xpGhy7tfEo5gdv3W/PJcJuGE3ABSiCuTqeCgfaHFLjggV2NWozPScowf ITSvSXBkEHTnO4F7QJ6MYeg1Q3ji9Ub8UD55WWHXWNpLggPS16eDFNZpn1W/nduOBDs7 1u5tHHNbHCev/M/v4zZ99RP1CQ8BMfE4w/JyAj88h+mthmnuB2Xe2956k8OM/z6VTSl2 IOs/a6xZUQRvMgIZNsawOfJ4g5VvmzZ4jc+lchmaax9107UlETAb/Z5ZkWKdegioVhF0 +ivw== X-Gm-Message-State: AOJu0YzMoVBHB2/fzZ2XK5SbsWGOHutTgStgxcZVj/brRvnbsP8wcE3A EPcnjLyFKRhEqgzeaCtHHMSXLTnA0ezL0Q== X-Google-Smtp-Source: AGHT+IH0caICiGs5TP+bLK+UImZa1gQcigWL0U5s6xrhu6cJw4xSLLAdsZ1NSqlHH2rNr044NPfUBw== X-Received: by 2002:a17:907:747:b0:a27:d1d6:c578 with SMTP id xc7-20020a170907074700b00a27d1d6c578mr1065921ejb.27.1704443111453; Fri, 05 Jan 2024 00:25:11 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.25.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:25:11 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 15/19] net: ravb: Simplify ravb_resume() Date: Fri, 5 Jan 2024 10:23:35 +0200 Message-Id: <20240105082339.1468817-16-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea Remove explicit calls to functions that are called by ravb_open(). There is no need to have them doubled now that the ravb_open() already contains what is needed for the interface configuration. Along with it, configurations needed by PTP were moved to ravb_wol_restore(). With this, code in ravb_resume() becomes simpler. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - fixed typos in patch description - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 58 ++++++++++-------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 1d228e0d875f..06c7ee45d567 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2900,6 +2900,20 @@ static int ravb_wol_restore(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; + int error; + + /* Set reset mode to rearm the WoL logic. */ + error = ravb_set_opmode(ndev, CCC_OPC_RESET); + if (error) + return error; + + /* Set AVB config mode. */ + error = ravb_set_config_mode(ndev); + if (error) + return error; + + if (priv->info->ccc_gac) + ravb_ptp_init(ndev, priv->pdev); if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); @@ -2939,53 +2953,29 @@ static int ravb_resume(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); - const struct ravb_hw_info *info = priv->info; int ret; ret = reset_control_deassert(priv->rstc); if (ret) return ret; - /* If WoL is enabled set reset mode to rearm the WoL logic */ + if (!netif_running(ndev)) + return 0; + + /* If WoL is enabled restore the interface. */ if (priv->wol_enabled) { - ret = ravb_set_opmode(ndev, CCC_OPC_RESET); + ret = ravb_wol_restore(ndev); if (ret) return ret; } - /* All register have been reset to default values. - * Restore all registers which where setup at probe time and - * reopen device if it was running before system suspended. - */ - - /* Set AVB config mode */ - ret = ravb_set_config_mode(ndev); - if (ret) + /* Reopening the interface will restore the device to the working state. */ + ret = ravb_open(ndev); + if (ret < 0) return ret; - ravb_set_gti(ndev); - - if (info->internal_delay) - ravb_set_delay_mode(ndev); - - /* Restore descriptor base address table */ - ravb_write(ndev, priv->desc_bat_dma, DBAT); - - if (priv->info->ccc_gac) - ravb_ptp_init(ndev, priv->pdev); - - if (netif_running(ndev)) { - if (priv->wol_enabled) { - ret = ravb_wol_restore(ndev); - if (ret) - return ret; - } - ret = ravb_open(ndev); - if (ret < 0) - return ret; - ravb_set_rx_mode(ndev); - netif_device_attach(ndev); - } + ravb_set_rx_mode(ndev); + netif_device_attach(ndev); return ret; }