From patchwork Wed Nov 29 02:12:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 171027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp68321vqn; Tue, 28 Nov 2023 18:12:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJqKlVPpEu0MgYZ5lfdY4b3HXDOvjuA7aCSBASIYBA8fZIEYEg8g6TpwkEzwkmgTDdTSXE X-Received: by 2002:a17:902:c10d:b0:1cf:cd2d:e296 with SMTP id 13-20020a170902c10d00b001cfcd2de296mr8206205pli.37.1701223975551; Tue, 28 Nov 2023 18:12:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701223975; cv=none; d=google.com; s=arc-20160816; b=wVv0q3tJo5krfQe7oHzkJ+qsX07f90mJYtjH4WbHuqelL0+Fk2ukB4dgNf8lXnnSRn YVJIAJRRDQXQH/SJ7R8tF7PtaTWQwfgV4yCIQC97xc7b2s/Gz/f3csREjBOONpQkf+Ka OuC3UQ/sZkJpXCGEQiVmnrFxf2xvFWHrSzvaqNI2GmCXKyAQd7yh6gM1Kuek66riiyv6 LcTjk4EoSMnByD/CZH1XF8EfdX5/s3gcyi5dXspcKufz9f6cSpwL1V8TQWVjPv1190dA T9usBECsI0PUgvMCDJ6c0A3L/je+JhU0zfxGSHOIwy5EEmduwmQluao6mnHH6xjXWuHd p4yA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lHb4Hqab32ZAoiBQ23jqK137Vq4bVEqKWL0HZ1i2azE=; fh=M/Mg9TtngevyqXgZJCTwFV5p5//1sl9LEorA0JOhC3o=; b=rAxWS6SAmKlNl60FgPuGziLZtJoAogb4/GsGQXNEJGR1c0mWcSwh0P1D7qIdKnGTdd 7W3Xiwpkfwcfxgi2c630UnwQjTg3Dr3BuJAwMgpqf6bjej4jXcOrbNDYk3489DzM4eyC OqfnIAki5HHb8zOED/RtRvQgBYSt+yZ+yQ/vSU75ttG6apnPFtFwfNjHGgOqXnND2+Sq Z5FJmRTzs2Edqd9N4obm/sZQZZHvnDEuqOdSb8m0kBcFt6AtzvmegZQsnXQLhEHahhW6 Y3Qrm8XiBwjhv8R7IAepaM9s7D7EsrAqqIhNYt7gfP454GQPTNnWCWt9/gFKqo/cFpBR BC1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cJB0KiRG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id 2-20020a170902ee4200b001c613b5e778si12538458plo.557.2023.11.28.18.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 18:12:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cJB0KiRG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id C392281C8D97; Tue, 28 Nov 2023 18:12:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234890AbjK2CMk (ORCPT + 99 others); Tue, 28 Nov 2023 21:12:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376749AbjK2CM1 (ORCPT ); Tue, 28 Nov 2023 21:12:27 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25109172E; Tue, 28 Nov 2023 18:12:34 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40838915cecso44294065e9.2; Tue, 28 Nov 2023 18:12:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701223952; x=1701828752; 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=lHb4Hqab32ZAoiBQ23jqK137Vq4bVEqKWL0HZ1i2azE=; b=cJB0KiRGYYw0avtvXFOT3EtiLm8A/bIq2XiUEamaWVLL89RuiA0h8AbvT9trO+JxyT 4fjE56FTzZRBuzEDB2QAvPaqEpv5JjQWnvbc+Tdt79cYJcR8NW3dVXIGwmYpok9ggQaF XHIShR1kXCBUHhFaVp6ldsDbWAUurfJps6nChtI9pUQXRIbZ0weSUAdEuUWa7Po/Kl2G Yl2Vry1CVpqYgfgEC5ljsihpnQ1OcYL08QpXIOhkpU6IzXLbJsg4moxE6vmBSsRw3b5i Dlw5mae8X/B6Yla7+sLCaaws+6FV86THN0rogLOYoPaG1M2A4N/o5D9VfEtl77JBOg5I bhnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701223952; x=1701828752; 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=lHb4Hqab32ZAoiBQ23jqK137Vq4bVEqKWL0HZ1i2azE=; b=al0oVoxReKvUZiwa80nsLzhMFQ5D8k1Ccy9gytMTQqg2PoQJFy5a37iFzNJ+Kor14P UpRnOpScR1/bTVIivSoj68qP4r6mNPpNCB5czewL9dD21p2s84XE1PVbATPuPAt5GYiH sRn4wa/4TEoAIEMkLt2Ygy6R0ih4+qI2y3iqffcLmK6xlGfrIW6EtDXnYhF9qw1hHoSn bTp954bAYYUWuByCKQkx1VkBH2QB7nNXQ+Oos1Hg3z7Y+/oaXqOVLntrkAWlFeaW+4YT /wu86DGgENNfDFxlQ/Sb67/s+RdSNOQFjo8pnAQQkhBwcVsM5GX515623fREq8CJzL1c 9IrQ== X-Gm-Message-State: AOJu0YxMqiM4xM32cgRCFduMjjqJfpJMp7iH7eVAhroJzLoRZbLhbaz+ vG2qfRP46Nt1ZvC3X4a1pW4= X-Received: by 2002:a05:600c:1ca8:b0:408:3707:b199 with SMTP id k40-20020a05600c1ca800b004083707b199mr9687018wms.3.1701223952579; Tue, 28 Nov 2023 18:12:32 -0800 (PST) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id b19-20020a05600c4e1300b0040648217f4fsm321406wmq.39.2023.11.28.18.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 18:12:32 -0800 (PST) From: Christian Marangi To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andy Gross , Bjorn Andersson , Konrad Dybcio , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH 04/14] net: phy: at803x: move qca83xx stats out of generic at803x_priv struct Date: Wed, 29 Nov 2023 03:12:09 +0100 Message-Id: <20231129021219.20914-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231129021219.20914-1-ansuelsmth@gmail.com> References: <20231129021219.20914-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 pete.vger.email 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 (pete.vger.email [0.0.0.0]); Tue, 28 Nov 2023 18:12:52 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783862631312976436 X-GMAIL-MSGID: 1783862631312976436 Introduce a specific priv struct for qca83xx PHYs to store hw stats data and a specific probe to allocate this alternative priv struct. This also have the benefits of reducing memory allocated for every other at803x PHY since only qca83xx currently supports storing hw stats. Signed-off-by: Christian Marangi --- drivers/net/phy/at803x.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 4ff41d70fc47..3b7baa4bb637 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -301,6 +301,10 @@ static struct at803x_hw_stat qca83xx_hw_stats[] = { { "eee_wake_errors", 0x16, GENMASK(15, 0), MMD}, }; +struct qca83xx_priv { + u64 stats[ARRAY_SIZE(qca83xx_hw_stats)]; +}; + struct at803x_priv { int flags; u16 clk_25m_reg; @@ -311,7 +315,6 @@ struct at803x_priv { bool is_1000basex; struct regulator_dev *vddio_rdev; struct regulator_dev *vddh_rdev; - u64 stats[ARRAY_SIZE(qca83xx_hw_stats)]; }; struct at803x_context { @@ -547,7 +550,7 @@ static void qca83xx_get_strings(struct phy_device *phydev, u8 *data) static u64 qca83xx_get_stat(struct phy_device *phydev, int i) { struct at803x_hw_stat stat = qca83xx_hw_stats[i]; - struct at803x_priv *priv = phydev->priv; + struct qca83xx_priv *priv = phydev->priv; int val; u64 ret; @@ -1591,6 +1594,20 @@ static int at803x_cable_test_start(struct phy_device *phydev) return 0; } +static int qca83xx_probe(struct phy_device *phydev) +{ + struct device *dev = &phydev->mdio.dev; + struct qca83xx_priv *priv; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + phydev->priv = priv; + + return 0; +} + static int qca83xx_config_init(struct phy_device *phydev) { u8 switch_revision; @@ -2164,7 +2181,7 @@ static struct phy_driver at803x_driver[] = { .name = "Qualcomm Atheros 8337 internal PHY", /* PHY_GBIT_FEATURES */ .link_change_notify = qca83xx_link_change_notify, - .probe = at803x_probe, + .probe = qca83xx_probe, .flags = PHY_IS_INTERNAL, .config_init = qca83xx_config_init, .soft_reset = genphy_soft_reset, @@ -2180,7 +2197,7 @@ static struct phy_driver at803x_driver[] = { .name = "Qualcomm Atheros 8327-A internal PHY", /* PHY_GBIT_FEATURES */ .link_change_notify = qca83xx_link_change_notify, - .probe = at803x_probe, + .probe = qca83xx_probe, .flags = PHY_IS_INTERNAL, .config_init = qca83xx_config_init, .soft_reset = genphy_soft_reset, @@ -2196,7 +2213,7 @@ static struct phy_driver at803x_driver[] = { .name = "Qualcomm Atheros 8327-B internal PHY", /* PHY_GBIT_FEATURES */ .link_change_notify = qca83xx_link_change_notify, - .probe = at803x_probe, + .probe = qca83xx_probe, .flags = PHY_IS_INTERNAL, .config_init = qca83xx_config_init, .soft_reset = genphy_soft_reset,