Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp456206ybt; Fri, 19 Jun 2020 06:02:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyn4oA/aNGWiSQMbrc2bal5OsF6dm49dOWhsQVbuZG5+Yr8XAf3rupBha6643a/aOjsJE+N X-Received: by 2002:a17:906:2c07:: with SMTP id e7mr3544067ejh.172.1592571740418; Fri, 19 Jun 2020 06:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592571740; cv=none; d=google.com; s=arc-20160816; b=NMu0+RRiqecSxnoeueDW8E214fdQcce3Llr3BczbCe7NR3WkuP85bavR4Ly+Tzu1OA VEHheq5wd+zu7mctN5ue+59PoERJmYCpzDs5yQBeff3tWBgrvOVIatklmmwA1D/0j3XO AEyejeBiLhp4DkhHQsLQ9NGYiiSOZIViPCRq5igyxw9gc8gEbiZTFgxSFQtZtarKfghM wiIpSKTO0l+WPuVLZ6EF4p8g9v5Owu/zV3RC4pyCKg5Xixv/YY+B1KnTb9thYzqqONYN 97fwvdnFVLL9NdPLMmbXxiRH7sFRJgl8WNWsU+qmYXljPE4ioD2+Xspby8TpuQdudugd ncjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hGfaWFePeggg6a6bW+xY4zRGMnZWrOUzSh+BJ3y+S2Y=; b=DenS5AHinE7G8hBlzdDXMxr1olPSJl29bixSpeEzrvuqlYeuRcyWDdM3t5EHAT2KxL SIlRpd9J3FArGvna8dJhjaTWKM/G/ofjTdmIfeWI2R+WNfcjYWqQkc6e2uD2h4YLCCzo obYcHSMum90yq/vjHogT/6WisRY3G7MLSo2GIUWLk0c9G+zgs4KvBLEn8lrrqHIHWutc khXjrTnQlitBpmAczUFu2gxEsgTP0+W8BwtQfgi+giazO4Xp93PAccPBeKT5cO0tM3D7 3SRtJhH/8mYGnjHiCnb5TkM9dPGbu8sEnscF2iO/UrWwe3fkWd0Mfe8D4lXpxvkhh5KR 5VtA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si3898907edw.220.2020.06.19.06.01.57; Fri, 19 Jun 2020 06:02:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733052AbgFSMZ6 (ORCPT + 99 others); Fri, 19 Jun 2020 08:25:58 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:57231 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733008AbgFSMZS (ORCPT ); Fri, 19 Jun 2020 08:25:18 -0400 X-Originating-IP: 90.76.143.236 Received: from localhost (lfbn-tou-1-1075-236.w90-76.abo.wanadoo.fr [90.76.143.236]) (Authenticated sender: antoine.tenart@bootlin.com) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 10BF740017; Fri, 19 Jun 2020 12:25:01 +0000 (UTC) From: Antoine Tenart To: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, richardcochran@gmail.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, allan.nielsen@microchip.com, foss@0leil.net, antoine.tenart@bootlin.com Subject: [PATCH net-next v3 1/8] net: phy: add support for a common probe between shared PHYs Date: Fri, 19 Jun 2020 14:22:53 +0200 Message-Id: <20200619122300.2510533-2-antoine.tenart@bootlin.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200619122300.2510533-1-antoine.tenart@bootlin.com> References: <20200619122300.2510533-1-antoine.tenart@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Shared PHYs (PHYs in the same hardware package) may have shared registers and their drivers would usually need to share information. There is currently a way to have a shared (part of the) init, by using phy_package_init_once(). This patch extends the logic to share parts of the probe to allow sharing the initialization of locks or resources retrieval. Signed-off-by: Antoine Tenart --- include/linux/phy.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/include/linux/phy.h b/include/linux/phy.h index 8c05d0fb5c00..058219b6441f 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -244,7 +244,8 @@ struct phy_package_shared { }; /* used as bit number in atomic bitops */ -#define PHY_SHARED_F_INIT_DONE 0 +#define PHY_SHARED_F_INIT_DONE 0 +#define PHY_SHARED_F_PROBE_DONE 1 /* * The Bus class for PHYs. Devices which provide access to @@ -1554,14 +1555,25 @@ static inline int __phy_package_write(struct phy_device *phydev, return __mdiobus_write(phydev->mdio.bus, shared->addr, regnum, val); } -static inline bool phy_package_init_once(struct phy_device *phydev) +static inline bool __phy_package_set_once(struct phy_device *phydev, + unsigned int b) { struct phy_package_shared *shared = phydev->shared; if (!shared) return false; - return !test_and_set_bit(PHY_SHARED_F_INIT_DONE, &shared->flags); + return !test_and_set_bit(b, &shared->flags); +} + +static inline bool phy_package_init_once(struct phy_device *phydev) +{ + return __phy_package_set_once(phydev, PHY_SHARED_F_INIT_DONE); +} + +static inline bool phy_package_probe_once(struct phy_device *phydev) +{ + return __phy_package_set_once(phydev, PHY_SHARED_F_PROBE_DONE); } extern struct bus_type mdio_bus_type; -- 2.26.2