From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2B5EC54787 for ; Sat, 17 Feb 2024 19:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=w6KV4n8Kr+j2/unS7jCZhnwRFZpx4PRUTyiUwCIeagI=; b=qnk/RrIOaHk+QD z8oeL/B4WMF8tUjB3yDBg7iLrDwZPpyzE+F2chREnp7Y++oEG+B91XJXrL6irziCQoLbhWLFudLQT MgjgJjNiqKZANWveGGk7mxBN2wF5nRI3CTxX2R2vfepw2H6H4QzWdApZsMjIQra4ETMMm+S0gmTFW t//j6O9ewHwbpTGGdFTMJtasGsctGLFPV6ALX+bd/fR1tlAJrazoYvKI+CkRONjqB77JvuWUoyAxC FCRjy77Do2wrWK2aRe5bsYju9PG8SiomO7BYGy26jHjo9KCaXBqu8kQDli3Ai23n/ghwxihkdY0sR WcH3K5SRA5GqIZ3HNqoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbQZK-00000006FqG-0Ybg; Sat, 17 Feb 2024 19:41:50 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbQZ7-00000006FhW-3Box; Sat, 17 Feb 2024 19:41:39 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3392b045e0aso1942578f8f.2; Sat, 17 Feb 2024 11:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708198896; x=1708803696; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pEGqx9swrd2Efs0TPhy/y31ToK5jrlVR+4ffHyJyKoM=; b=Hx6URy23OurdBAeECiG0oROiF0EQu1dJDPsKhcK6zgAr+4q7TBdlp1xDVj4SNDuj8f ZHMKtjA2h9fZp11T8y4XZGOft2Z4DxnFqNXSzYuq3S21GqujLtLYrkIExq/QC2sdTcO3 8bA+CclNfNUypCvxZ5xt6swrLoZAE1L2MnBlrQRB55fzDO89YqvHJiyzWr2PI6fDNN7x OGURGlKLYmob3OieRmiFb6gJGp6Lcf1MT+qEBlXHfNz1HKKjaB9jR2Wp291a+ClnAu95 fYfwtNAk7UUHB+EEivyrDEUk3Y1AKNQ/Cvqk7f4oWIFGP3gL6XOxnOdNodJEpWjlUdUA j/GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708198896; x=1708803696; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pEGqx9swrd2Efs0TPhy/y31ToK5jrlVR+4ffHyJyKoM=; b=PETC5uVS6jDZvZfQOuLXkWZ8pppp7vO0Yii9loUWie0bBz97N05HG0JdHtbx8LQ3kQ 06CdqbnhOFQSaRaSqqMVpQ1qxedx1ZNULCFPITJLqQkrfzSrdeLmf9TSyOm3YIiw2dHA GEzfb+fR6N33RuzOLLv6gkBz4d+UVh9hbL8IvdEgx/D7rn2dyli0XdTgHAt4lySQ8mNE VhY+64Jt+Cbcw9/p6o9TGPDJH8C1QtbO+Aki+AhOhCI4GMLRcJA6OuSmtvWfIrL1P1Xa /RRqtYgSAko6XOwpTZuh0+GJatgB0eF+ey2h08+8/wN48WJBkmWMrJmofe+cRaiscEyL dLcQ== X-Forwarded-Encrypted: i=1; AJvYcCWs921guERXblSAo5EDLwY4y8XTgIaHa6znav9w2Ezqz8PFyyB4Tkjh90OJzZgW6yhP8HlbYdYUkehze2nSCi4LpKxucuUGSuVSc8JiafjyvG2t6iXu7xP/5ew+4btwYrmN9I679uXXN1VCk9crmCwmg58owYwr6KDdMsx/26FHIQtmjJh23AflKi9izO5/G0t7PgJvU6zCl+a+mG7OnbpbObmyOx0pkIk82PU+2+Yb21mN5lR6EM1sPouDak9L1A== X-Gm-Message-State: AOJu0YxOdSp3KK4dgIJq4iHkKZeDGwwtcbDaFDXMHW3+CyymVu0icG9I WwaqF+hxTAv1DfT9qJwpKLtKgQXjkBHkBRpBxSp/FNzywZ8y37Ma X-Google-Smtp-Source: AGHT+IHTBfuLFBgxYDXyAEdhLvoS/uyVjXtTiqArx5lwkdOqMzfSKqV8T9BR5k1vk63E8j+lc/Nsdg== X-Received: by 2002:a05:6000:105:b0:33d:39bb:a350 with SMTP id o5-20020a056000010500b0033d39bba350mr736402wrx.59.1708198896316; Sat, 17 Feb 2024 11:41:36 -0800 (PST) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id b10-20020a5d40ca000000b0033ceca3a3dbsm5661169wrq.2.2024.02.17.11.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 11:41:35 -0800 (PST) From: Christian Marangi To: Michael Hennerich , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Richard Cochran , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Daniel Golle , Qingfang Deng , SkyLake Huang , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Arun Ramadoss , UNGLinuxDriver@microchip.com, Peter Geis , Frank , Xu Liang , Piergiorgio Beruto , Andrei Botila , Bjorn Andersson , Konrad Dybcio , Heiko Stuebner , Michal Simek , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Matthias Brugger , AngeloGioacchino Del Regno , Christian Marangi , Robert Marko , "Russell King (Oracle)" , Vladimir Oltean , David Epping , Harini Katakam , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, rust-for-linux@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [net-next RFC PATCH 3/3] net: phy: bcm7xxx: use common OPs for PHYs where possible Date: Sat, 17 Feb 2024 20:41:14 +0100 Message-ID: <20240217194116.8565-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217194116.8565-1-ansuelsmth@gmail.com> References: <20240217194116.8565-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240217_114137_985550_E2BCD786 X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Group common OPs for PHY, make them static and reference these statically link OPs table instead of duplicating them for each PHY. Signed-off-by: Christian Marangi --- drivers/net/phy/bcm7xxx.c | 80 +++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/drivers/net/phy/bcm7xxx.c b/drivers/net/phy/bcm7xxx.c index c820a94b30a4..adfe364846dd 100644 --- a/drivers/net/phy/bcm7xxx.c +++ b/drivers/net/phy/bcm7xxx.c @@ -840,6 +840,17 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) return ret; } +static const struct phy_driver_ops bcm7xxx_28nm_gpy_ops = { + .config_init = bcm7xxx_28nm_config_init, + .resume = bcm7xxx_28nm_resume, + .get_tunable = bcm7xxx_28nm_get_tunable, + .set_tunable = bcm7xxx_28nm_set_tunable, + .get_sset_count = bcm_phy_get_sset_count, + .get_strings = bcm_phy_get_strings, + .get_stats = bcm7xxx_28nm_get_phy_stats, + .probe = bcm7xxx_28nm_probe, +}; + #define BCM7XXX_28NM_GPHY(_oui, _name) \ { \ .phy_id = (_oui), \ @@ -847,18 +858,20 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) .name = _name, \ /* PHY_GBIT_FEATURES */ \ .flags = PHY_IS_INTERNAL, \ - .ops = &(const struct phy_driver_ops){ \ - .config_init = bcm7xxx_28nm_config_init, \ - .resume = bcm7xxx_28nm_resume, \ - .get_tunable = bcm7xxx_28nm_get_tunable, \ - .set_tunable = bcm7xxx_28nm_set_tunable, \ - .get_sset_count = bcm_phy_get_sset_count, \ - .get_strings = bcm_phy_get_strings, \ - .get_stats = bcm7xxx_28nm_get_phy_stats, \ - .probe = bcm7xxx_28nm_probe, \ - }, \ + .ops = &bcm7xxx_28nm_gpy_ops, \ } +static const struct phy_driver_ops bcm7xxx_28nm_ephy_ops = { + .config_init = bcm7xxx_28nm_ephy_config_init, + .resume = bcm7xxx_28nm_ephy_resume, + .get_sset_count = bcm_phy_get_sset_count, + .get_strings = bcm_phy_get_strings, + .get_stats = bcm7xxx_28nm_get_phy_stats, + .probe = bcm7xxx_28nm_probe, + .read_mmd = bcm7xxx_28nm_ephy_read_mmd, + .write_mmd = bcm7xxx_28nm_ephy_write_mmd, +}; + #define BCM7XXX_28NM_EPHY(_oui, _name) \ { \ .phy_id = (_oui), \ @@ -866,18 +879,16 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) .name = _name, \ /* PHY_BASIC_FEATURES */ \ .flags = PHY_IS_INTERNAL, \ - .ops = &(const struct phy_driver_ops){ \ - .config_init = bcm7xxx_28nm_ephy_config_init, \ - .resume = bcm7xxx_28nm_ephy_resume, \ - .get_sset_count = bcm_phy_get_sset_count, \ - .get_strings = bcm_phy_get_strings, \ - .get_stats = bcm7xxx_28nm_get_phy_stats, \ - .probe = bcm7xxx_28nm_probe, \ - .read_mmd = bcm7xxx_28nm_ephy_read_mmd, \ - .write_mmd = bcm7xxx_28nm_ephy_write_mmd, \ - }, \ + .ops = &bcm7xxx_28nm_ephy_ops, \ } +static const struct phy_driver_ops bcm7xxx_40nm_ephy_ops = { + .soft_reset = genphy_soft_reset, + .config_init = bcm7xxx_config_init, + .suspend = bcm7xxx_suspend, + .resume = bcm7xxx_config_init, +}; + #define BCM7XXX_40NM_EPHY(_oui, _name) \ { \ .phy_id = (_oui), \ @@ -885,14 +896,20 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) .name = _name, \ /* PHY_BASIC_FEATURES */ \ .flags = PHY_IS_INTERNAL, \ - .ops = &(const struct phy_driver_ops){ \ - .soft_reset = genphy_soft_reset, \ - .config_init = bcm7xxx_config_init, \ - .suspend = bcm7xxx_suspend, \ - .resume = bcm7xxx_config_init, \ - }, \ + .ops = &bcm7xxx_40nm_ephy_ops, \ } +static const struct phy_driver_ops bcm7xxx_16nm_ephy_ops = { + .get_sset_count = bcm_phy_get_sset_count, + .get_strings = bcm_phy_get_strings, + .get_stats = bcm7xxx_28nm_get_phy_stats, + .probe = bcm7xxx_28nm_probe, + .config_init = bcm7xxx_16nm_ephy_config_init, + .config_aneg = genphy_config_aneg, + .read_status = genphy_read_status, + .resume = bcm7xxx_16nm_ephy_resume, +}; + #define BCM7XXX_16NM_EPHY(_oui, _name) \ { \ .phy_id = (_oui), \ @@ -900,16 +917,7 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) .name = _name, \ /* PHY_BASIC_FEATURES */ \ .flags = PHY_IS_INTERNAL, \ - .ops = &(const struct phy_driver_ops){ \ - .get_sset_count = bcm_phy_get_sset_count, \ - .get_strings = bcm_phy_get_strings, \ - .get_stats = bcm7xxx_28nm_get_phy_stats, \ - .probe = bcm7xxx_28nm_probe, \ - .config_init = bcm7xxx_16nm_ephy_config_init, \ - .config_aneg = genphy_config_aneg, \ - .read_status = genphy_read_status, \ - .resume = bcm7xxx_16nm_ephy_resume, \ - }, \ + .ops = &bcm7xxx_16nm_ephy_ops, \ } static struct phy_driver bcm7xxx_driver[] = { -- 2.43.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 EC0E01E863; Sat, 17 Feb 2024 19:41:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708198899; cv=none; b=hJmdel5d74sSCVO6rkP/Tyq+lMHtq+TnkuQWzYPaLbJzDZPh5oUoiUMdFKg+xn6ekV3vb23nMXvxoDpu6sp1b8NxZBfmBBSChVFksTwwOxpvKM8n0fMEU68GkEVSIz3bkVs7g4dl5+Mym7Z+/eEWdVZ10xHL7xm+gjUqJZGjsbI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708198899; c=relaxed/simple; bh=7l+4WmcZhRm+cQXIUxCvDteAB3XdXH5QXlynCwU1qq4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G2MQAmKUGMz0sTWd19itI3fvEEAPTZ2s2c8wDguqbWBUseYmkSDlnvqUhcQlgCzeSRG5JaaLRVR0M4jBjlh+mSc2B44jYK7N8w2Ng4c0y2YrLslvwUr0l953e90/I0+Nt5mtJx6shCTgOCb47wYLYlTaDLbckTFoZoyNJr5GtlE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Zp65E9yj; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zp65E9yj" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-33d38c9f227so131153f8f.0; Sat, 17 Feb 2024 11:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708198896; x=1708803696; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pEGqx9swrd2Efs0TPhy/y31ToK5jrlVR+4ffHyJyKoM=; b=Zp65E9yjSzzfs9w0zqjXmFpPWIvc6ryOatypdrsonRJR8xzP10at40ET5L4abUVbip Q5Oq6mGG1AB5Ivs+z1nWljfWl75YZe/cPsg3P6FSUnt4xLzcJ7mGC9wsGdoIKTzN4ao8 WnW4VMAPXZMzwX2zTpHHXMaKkSRl2ZbTm+CG/EooUOZjsa2JsaQQ4aPQ/Sys5WD24rxv NOaxH1G/oEKUnfWSwZZtlWXlcS5Te7Kf27E3JamM40gzY6eAqpf1DSi3eSUAE+R+47if GgJ+aYLCuZAFXRgsL3pMCT1aB1yqrE27MPsLgi2SgmQfXMtbVNHkme9vR3cVQbL7nSB/ HSKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708198896; x=1708803696; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pEGqx9swrd2Efs0TPhy/y31ToK5jrlVR+4ffHyJyKoM=; b=F3+kFpmEciEekOs6s9gOiPheI+tyPDZ89LS/oRUnG/7KGNxAM9tXda484CLaPGSrvp TY2tF6peNFKhiZYGA1p9sGneGG7rg5NtyhjkcUy6ooqvyo1LLtDUcRuAtKGYCnDFJ9Qo N+LtM8R6gn/tqOMb4HpjJPU/I7lvPxGjJrcmdit4f8I3lBHNJWbKTScZV+7BuegN4HCc Qp0SgYWebjEvsyQWVgccv9Chyf5FtGaH/Mvll88BlQDXVTgu2Bsv1ddDiJ79weV1RiFj jXY6Urvc2tDhdf0rB3QIDbIYDjGqejLB6z6G8fYgzBkaY5vr5bR32m3bbFLverayWwVK KzEw== X-Forwarded-Encrypted: i=1; AJvYcCXp8LPm0Z4WYw1D9A9I3rWSpJ0eSL4pAu+rgRRcAwZBKsy3PXvoOzfy84VwZG1Dz+4YqdPZJLZowAcUMt8zWE0CkgilTeQ8qkTTXhV1YKGk8xHpeMj5rOJ09+kqeBdHv/UVeK4SriwGuZDKeKWi7zF2CxGYV2cnpC0z6OnVUCS9cQD0wlHmxqSfXldd8rSCGnvJD8CBtUxmrK3cFx37QAB+eONu X-Gm-Message-State: AOJu0YxBcpWulFPGNA+wvTPXbTXwmbGzj1zQZb46cvdwBYAVSwBpDD2s T5M2v+MH6mdM6Xa/obhlWEayaSuNEdf+5ixN/hOGTTjS+3TVnunV X-Google-Smtp-Source: AGHT+IHTBfuLFBgxYDXyAEdhLvoS/uyVjXtTiqArx5lwkdOqMzfSKqV8T9BR5k1vk63E8j+lc/Nsdg== X-Received: by 2002:a05:6000:105:b0:33d:39bb:a350 with SMTP id o5-20020a056000010500b0033d39bba350mr736402wrx.59.1708198896316; Sat, 17 Feb 2024 11:41:36 -0800 (PST) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id b10-20020a5d40ca000000b0033ceca3a3dbsm5661169wrq.2.2024.02.17.11.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 11:41:35 -0800 (PST) From: Christian Marangi To: Michael Hennerich , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Richard Cochran , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Daniel Golle , Qingfang Deng , SkyLake Huang , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Arun Ramadoss , UNGLinuxDriver@microchip.com, Peter Geis , Frank , Xu Liang , Piergiorgio Beruto , Andrei Botila , Bjorn Andersson , Konrad Dybcio , Heiko Stuebner , Michal Simek , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Matthias Brugger , AngeloGioacchino Del Regno , Christian Marangi , Robert Marko , "Russell King (Oracle)" , Vladimir Oltean , David Epping , Harini Katakam , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, rust-for-linux@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [net-next RFC PATCH 3/3] net: phy: bcm7xxx: use common OPs for PHYs where possible Date: Sat, 17 Feb 2024 20:41:14 +0100 Message-ID: <20240217194116.8565-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217194116.8565-1-ansuelsmth@gmail.com> References: <20240217194116.8565-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Group common OPs for PHY, make them static and reference these statically link OPs table instead of duplicating them for each PHY. Signed-off-by: Christian Marangi --- drivers/net/phy/bcm7xxx.c | 80 +++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/drivers/net/phy/bcm7xxx.c b/drivers/net/phy/bcm7xxx.c index c820a94b30a4..adfe364846dd 100644 --- a/drivers/net/phy/bcm7xxx.c +++ b/drivers/net/phy/bcm7xxx.c @@ -840,6 +840,17 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) return ret; } +static const struct phy_driver_ops bcm7xxx_28nm_gpy_ops = { + .config_init = bcm7xxx_28nm_config_init, + .resume = bcm7xxx_28nm_resume, + .get_tunable = bcm7xxx_28nm_get_tunable, + .set_tunable = bcm7xxx_28nm_set_tunable, + .get_sset_count = bcm_phy_get_sset_count, + .get_strings = bcm_phy_get_strings, + .get_stats = bcm7xxx_28nm_get_phy_stats, + .probe = bcm7xxx_28nm_probe, +}; + #define BCM7XXX_28NM_GPHY(_oui, _name) \ { \ .phy_id = (_oui), \ @@ -847,18 +858,20 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) .name = _name, \ /* PHY_GBIT_FEATURES */ \ .flags = PHY_IS_INTERNAL, \ - .ops = &(const struct phy_driver_ops){ \ - .config_init = bcm7xxx_28nm_config_init, \ - .resume = bcm7xxx_28nm_resume, \ - .get_tunable = bcm7xxx_28nm_get_tunable, \ - .set_tunable = bcm7xxx_28nm_set_tunable, \ - .get_sset_count = bcm_phy_get_sset_count, \ - .get_strings = bcm_phy_get_strings, \ - .get_stats = bcm7xxx_28nm_get_phy_stats, \ - .probe = bcm7xxx_28nm_probe, \ - }, \ + .ops = &bcm7xxx_28nm_gpy_ops, \ } +static const struct phy_driver_ops bcm7xxx_28nm_ephy_ops = { + .config_init = bcm7xxx_28nm_ephy_config_init, + .resume = bcm7xxx_28nm_ephy_resume, + .get_sset_count = bcm_phy_get_sset_count, + .get_strings = bcm_phy_get_strings, + .get_stats = bcm7xxx_28nm_get_phy_stats, + .probe = bcm7xxx_28nm_probe, + .read_mmd = bcm7xxx_28nm_ephy_read_mmd, + .write_mmd = bcm7xxx_28nm_ephy_write_mmd, +}; + #define BCM7XXX_28NM_EPHY(_oui, _name) \ { \ .phy_id = (_oui), \ @@ -866,18 +879,16 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) .name = _name, \ /* PHY_BASIC_FEATURES */ \ .flags = PHY_IS_INTERNAL, \ - .ops = &(const struct phy_driver_ops){ \ - .config_init = bcm7xxx_28nm_ephy_config_init, \ - .resume = bcm7xxx_28nm_ephy_resume, \ - .get_sset_count = bcm_phy_get_sset_count, \ - .get_strings = bcm_phy_get_strings, \ - .get_stats = bcm7xxx_28nm_get_phy_stats, \ - .probe = bcm7xxx_28nm_probe, \ - .read_mmd = bcm7xxx_28nm_ephy_read_mmd, \ - .write_mmd = bcm7xxx_28nm_ephy_write_mmd, \ - }, \ + .ops = &bcm7xxx_28nm_ephy_ops, \ } +static const struct phy_driver_ops bcm7xxx_40nm_ephy_ops = { + .soft_reset = genphy_soft_reset, + .config_init = bcm7xxx_config_init, + .suspend = bcm7xxx_suspend, + .resume = bcm7xxx_config_init, +}; + #define BCM7XXX_40NM_EPHY(_oui, _name) \ { \ .phy_id = (_oui), \ @@ -885,14 +896,20 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) .name = _name, \ /* PHY_BASIC_FEATURES */ \ .flags = PHY_IS_INTERNAL, \ - .ops = &(const struct phy_driver_ops){ \ - .soft_reset = genphy_soft_reset, \ - .config_init = bcm7xxx_config_init, \ - .suspend = bcm7xxx_suspend, \ - .resume = bcm7xxx_config_init, \ - }, \ + .ops = &bcm7xxx_40nm_ephy_ops, \ } +static const struct phy_driver_ops bcm7xxx_16nm_ephy_ops = { + .get_sset_count = bcm_phy_get_sset_count, + .get_strings = bcm_phy_get_strings, + .get_stats = bcm7xxx_28nm_get_phy_stats, + .probe = bcm7xxx_28nm_probe, + .config_init = bcm7xxx_16nm_ephy_config_init, + .config_aneg = genphy_config_aneg, + .read_status = genphy_read_status, + .resume = bcm7xxx_16nm_ephy_resume, +}; + #define BCM7XXX_16NM_EPHY(_oui, _name) \ { \ .phy_id = (_oui), \ @@ -900,16 +917,7 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) .name = _name, \ /* PHY_BASIC_FEATURES */ \ .flags = PHY_IS_INTERNAL, \ - .ops = &(const struct phy_driver_ops){ \ - .get_sset_count = bcm_phy_get_sset_count, \ - .get_strings = bcm_phy_get_strings, \ - .get_stats = bcm7xxx_28nm_get_phy_stats, \ - .probe = bcm7xxx_28nm_probe, \ - .config_init = bcm7xxx_16nm_ephy_config_init, \ - .config_aneg = genphy_config_aneg, \ - .read_status = genphy_read_status, \ - .resume = bcm7xxx_16nm_ephy_resume, \ - }, \ + .ops = &bcm7xxx_16nm_ephy_ops, \ } static struct phy_driver bcm7xxx_driver[] = { -- 2.43.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E063EC54764 for ; Sat, 17 Feb 2024 19:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JHEMVMyg9deJDlxVbMS9rU8b5cHtboYHv+0omz/xf9U=; b=1FTnSZVsRrASiQ 2t0nC+O/Y4azTr7cuLUYODOGEjh/SFYnSOBCSIYegoExmyeIKEO//ayZD5RvYKkiBSwrfkIuSHfLG mgMPRGnO/1pjgpfhZeWG6G7RSPgJih2/pKPkbaPw5B9TTaZpgA4McwZNhTLWoaZbzEfWOzHorhz5E mocFd/gKFLR1fXpIpX+qoxIetgdYd7bYo6UWmWwmGUy0ypH7Ny0gFkh7umALw4L+pu/xcUqhnYepY fix1bMiMMpnNrLbmnV/yqiH6phvB4cZDzMABq8Td6nsvBTRVaUcS973tfJx68cdoNYBI/lBJHVv2D 8QxQMUz0yE54bUSlnntg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbQZL-00000006Fqx-0c0N; Sat, 17 Feb 2024 19:41:51 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbQZ7-00000006FhW-3Box; Sat, 17 Feb 2024 19:41:39 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3392b045e0aso1942578f8f.2; Sat, 17 Feb 2024 11:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708198896; x=1708803696; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pEGqx9swrd2Efs0TPhy/y31ToK5jrlVR+4ffHyJyKoM=; b=Hx6URy23OurdBAeECiG0oROiF0EQu1dJDPsKhcK6zgAr+4q7TBdlp1xDVj4SNDuj8f ZHMKtjA2h9fZp11T8y4XZGOft2Z4DxnFqNXSzYuq3S21GqujLtLYrkIExq/QC2sdTcO3 8bA+CclNfNUypCvxZ5xt6swrLoZAE1L2MnBlrQRB55fzDO89YqvHJiyzWr2PI6fDNN7x OGURGlKLYmob3OieRmiFb6gJGp6Lcf1MT+qEBlXHfNz1HKKjaB9jR2Wp291a+ClnAu95 fYfwtNAk7UUHB+EEivyrDEUk3Y1AKNQ/Cvqk7f4oWIFGP3gL6XOxnOdNodJEpWjlUdUA j/GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708198896; x=1708803696; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pEGqx9swrd2Efs0TPhy/y31ToK5jrlVR+4ffHyJyKoM=; b=PETC5uVS6jDZvZfQOuLXkWZ8pppp7vO0Yii9loUWie0bBz97N05HG0JdHtbx8LQ3kQ 06CdqbnhOFQSaRaSqqMVpQ1qxedx1ZNULCFPITJLqQkrfzSrdeLmf9TSyOm3YIiw2dHA GEzfb+fR6N33RuzOLLv6gkBz4d+UVh9hbL8IvdEgx/D7rn2dyli0XdTgHAt4lySQ8mNE VhY+64Jt+Cbcw9/p6o9TGPDJH8C1QtbO+Aki+AhOhCI4GMLRcJA6OuSmtvWfIrL1P1Xa /RRqtYgSAko6XOwpTZuh0+GJatgB0eF+ey2h08+8/wN48WJBkmWMrJmofe+cRaiscEyL dLcQ== X-Forwarded-Encrypted: i=1; AJvYcCWs921guERXblSAo5EDLwY4y8XTgIaHa6znav9w2Ezqz8PFyyB4Tkjh90OJzZgW6yhP8HlbYdYUkehze2nSCi4LpKxucuUGSuVSc8JiafjyvG2t6iXu7xP/5ew+4btwYrmN9I679uXXN1VCk9crmCwmg58owYwr6KDdMsx/26FHIQtmjJh23AflKi9izO5/G0t7PgJvU6zCl+a+mG7OnbpbObmyOx0pkIk82PU+2+Yb21mN5lR6EM1sPouDak9L1A== X-Gm-Message-State: AOJu0YxOdSp3KK4dgIJq4iHkKZeDGwwtcbDaFDXMHW3+CyymVu0icG9I WwaqF+hxTAv1DfT9qJwpKLtKgQXjkBHkBRpBxSp/FNzywZ8y37Ma X-Google-Smtp-Source: AGHT+IHTBfuLFBgxYDXyAEdhLvoS/uyVjXtTiqArx5lwkdOqMzfSKqV8T9BR5k1vk63E8j+lc/Nsdg== X-Received: by 2002:a05:6000:105:b0:33d:39bb:a350 with SMTP id o5-20020a056000010500b0033d39bba350mr736402wrx.59.1708198896316; Sat, 17 Feb 2024 11:41:36 -0800 (PST) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id b10-20020a5d40ca000000b0033ceca3a3dbsm5661169wrq.2.2024.02.17.11.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 11:41:35 -0800 (PST) From: Christian Marangi To: Michael Hennerich , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Richard Cochran , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Daniel Golle , Qingfang Deng , SkyLake Huang , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Arun Ramadoss , UNGLinuxDriver@microchip.com, Peter Geis , Frank , Xu Liang , Piergiorgio Beruto , Andrei Botila , Bjorn Andersson , Konrad Dybcio , Heiko Stuebner , Michal Simek , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Matthias Brugger , AngeloGioacchino Del Regno , Christian Marangi , Robert Marko , "Russell King (Oracle)" , Vladimir Oltean , David Epping , Harini Katakam , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, rust-for-linux@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [net-next RFC PATCH 3/3] net: phy: bcm7xxx: use common OPs for PHYs where possible Date: Sat, 17 Feb 2024 20:41:14 +0100 Message-ID: <20240217194116.8565-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217194116.8565-1-ansuelsmth@gmail.com> References: <20240217194116.8565-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240217_114137_985550_E2BCD786 X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Group common OPs for PHY, make them static and reference these statically link OPs table instead of duplicating them for each PHY. Signed-off-by: Christian Marangi --- drivers/net/phy/bcm7xxx.c | 80 +++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/drivers/net/phy/bcm7xxx.c b/drivers/net/phy/bcm7xxx.c index c820a94b30a4..adfe364846dd 100644 --- a/drivers/net/phy/bcm7xxx.c +++ b/drivers/net/phy/bcm7xxx.c @@ -840,6 +840,17 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) return ret; } +static const struct phy_driver_ops bcm7xxx_28nm_gpy_ops = { + .config_init = bcm7xxx_28nm_config_init, + .resume = bcm7xxx_28nm_resume, + .get_tunable = bcm7xxx_28nm_get_tunable, + .set_tunable = bcm7xxx_28nm_set_tunable, + .get_sset_count = bcm_phy_get_sset_count, + .get_strings = bcm_phy_get_strings, + .get_stats = bcm7xxx_28nm_get_phy_stats, + .probe = bcm7xxx_28nm_probe, +}; + #define BCM7XXX_28NM_GPHY(_oui, _name) \ { \ .phy_id = (_oui), \ @@ -847,18 +858,20 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) .name = _name, \ /* PHY_GBIT_FEATURES */ \ .flags = PHY_IS_INTERNAL, \ - .ops = &(const struct phy_driver_ops){ \ - .config_init = bcm7xxx_28nm_config_init, \ - .resume = bcm7xxx_28nm_resume, \ - .get_tunable = bcm7xxx_28nm_get_tunable, \ - .set_tunable = bcm7xxx_28nm_set_tunable, \ - .get_sset_count = bcm_phy_get_sset_count, \ - .get_strings = bcm_phy_get_strings, \ - .get_stats = bcm7xxx_28nm_get_phy_stats, \ - .probe = bcm7xxx_28nm_probe, \ - }, \ + .ops = &bcm7xxx_28nm_gpy_ops, \ } +static const struct phy_driver_ops bcm7xxx_28nm_ephy_ops = { + .config_init = bcm7xxx_28nm_ephy_config_init, + .resume = bcm7xxx_28nm_ephy_resume, + .get_sset_count = bcm_phy_get_sset_count, + .get_strings = bcm_phy_get_strings, + .get_stats = bcm7xxx_28nm_get_phy_stats, + .probe = bcm7xxx_28nm_probe, + .read_mmd = bcm7xxx_28nm_ephy_read_mmd, + .write_mmd = bcm7xxx_28nm_ephy_write_mmd, +}; + #define BCM7XXX_28NM_EPHY(_oui, _name) \ { \ .phy_id = (_oui), \ @@ -866,18 +879,16 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) .name = _name, \ /* PHY_BASIC_FEATURES */ \ .flags = PHY_IS_INTERNAL, \ - .ops = &(const struct phy_driver_ops){ \ - .config_init = bcm7xxx_28nm_ephy_config_init, \ - .resume = bcm7xxx_28nm_ephy_resume, \ - .get_sset_count = bcm_phy_get_sset_count, \ - .get_strings = bcm_phy_get_strings, \ - .get_stats = bcm7xxx_28nm_get_phy_stats, \ - .probe = bcm7xxx_28nm_probe, \ - .read_mmd = bcm7xxx_28nm_ephy_read_mmd, \ - .write_mmd = bcm7xxx_28nm_ephy_write_mmd, \ - }, \ + .ops = &bcm7xxx_28nm_ephy_ops, \ } +static const struct phy_driver_ops bcm7xxx_40nm_ephy_ops = { + .soft_reset = genphy_soft_reset, + .config_init = bcm7xxx_config_init, + .suspend = bcm7xxx_suspend, + .resume = bcm7xxx_config_init, +}; + #define BCM7XXX_40NM_EPHY(_oui, _name) \ { \ .phy_id = (_oui), \ @@ -885,14 +896,20 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) .name = _name, \ /* PHY_BASIC_FEATURES */ \ .flags = PHY_IS_INTERNAL, \ - .ops = &(const struct phy_driver_ops){ \ - .soft_reset = genphy_soft_reset, \ - .config_init = bcm7xxx_config_init, \ - .suspend = bcm7xxx_suspend, \ - .resume = bcm7xxx_config_init, \ - }, \ + .ops = &bcm7xxx_40nm_ephy_ops, \ } +static const struct phy_driver_ops bcm7xxx_16nm_ephy_ops = { + .get_sset_count = bcm_phy_get_sset_count, + .get_strings = bcm_phy_get_strings, + .get_stats = bcm7xxx_28nm_get_phy_stats, + .probe = bcm7xxx_28nm_probe, + .config_init = bcm7xxx_16nm_ephy_config_init, + .config_aneg = genphy_config_aneg, + .read_status = genphy_read_status, + .resume = bcm7xxx_16nm_ephy_resume, +}; + #define BCM7XXX_16NM_EPHY(_oui, _name) \ { \ .phy_id = (_oui), \ @@ -900,16 +917,7 @@ static int bcm7xxx_28nm_probe(struct phy_device *phydev) .name = _name, \ /* PHY_BASIC_FEATURES */ \ .flags = PHY_IS_INTERNAL, \ - .ops = &(const struct phy_driver_ops){ \ - .get_sset_count = bcm_phy_get_sset_count, \ - .get_strings = bcm_phy_get_strings, \ - .get_stats = bcm7xxx_28nm_get_phy_stats, \ - .probe = bcm7xxx_28nm_probe, \ - .config_init = bcm7xxx_16nm_ephy_config_init, \ - .config_aneg = genphy_config_aneg, \ - .read_status = genphy_read_status, \ - .resume = bcm7xxx_16nm_ephy_resume, \ - }, \ + .ops = &bcm7xxx_16nm_ephy_ops, \ } static struct phy_driver bcm7xxx_driver[] = { -- 2.43.0 _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip