🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25874

Re: [RFC net-next 1/2] net: ethernet: add MEN Z87 driver

#25874
From: Andrew Lunn
Date: Wed, 02 Dec 2026 16:34
69 lines
11031 bytes
> > > +static int z87_probe(struct mcb_device *mdev,
> > > +		     const struct mcb_device_id *id)
> > > +{
> > > +	const struct board_config *cfg = NULL;
> > > +	struct net_device *dev = NULL;
> > > +	struct z87_private *np = NULL;
> > > +	void *mem_virt_dma = NULL;
> > > +	dma_addr_t mem_hw_dma;
> > > +	struct resource *mem;
> > > +	int res = -ENXIO;
> > > +
> > > +	cfg = z87_get_board_config(mdev);
> > > +	if (!cfg)
> > > +		return -EOPNOTSUPP;
> > > +
> > > +	/**
> > > +	 * mdev->inst is defined in a per-board basis, so lets check
> > > +	 * if there are more devices that defined for the board. In that
> > > +	 * case, something is wrong.
> > > +	 */
> > > +	if (mdev->inst >= cfg->num_devs) {
> > > +		return dev_err_probe(&mdev->dev, -EINVAL,
> > > +				     "detected more devices than configured for board: %s",
> > > +				     cfg->board_name);
> > > +	}
> > 
> > Does something actually go wrong if there are more?
> 
> Yes, It could crash as it tries to access to an array index that does not exist. However
> I am pretty sure this condition hardly could happens so I just could remove it.

You generally try to write drivers so you can instantiate them an
arbitrary number of times. That means not having any global state.

> > Sorry, but no. The PHY driver should export the LEDs via
> > /sys/class/leds.
> 
> Understood. I would like to agree on this approach. 
> 
> PHY driver dp83822 already implements the mechanism to handle LEDs
> in the correct way using DT nodes. My hardware (FPGA) is a PCI device
> that typically runs on x86 so there is DT node for the PCI function,
> the MCB devices or the PHYs yet.
> 
> Another solution could be transforming of_phy_led()/of_phy_leds()
> functions on phy_device to fwnodes thus my driver just could create
> a subnode describing leds.
> 
> Please could you help me with that? which could be the best approach?

There are a few possible solutions.

It is possible to use DT with X86. drivers/misc/lan966x_pci.dtso gets
loaded as a DT overlay on top of the PCIe node, instantiating various
devices the DT way.

You can also at runtime create fwnode entries and associate them to
the device. I don't know if anybody has done this if LEDs yet, bit it
has been used for SFP sockets and phylink. wangxun/txgbe/txgbe_phy.c

And lastly, you could consider adding an ACPI binding. ACPI and
complex network hardware configurations generally don't go together.
PCIe devices tend to hide all there internal details in firmware,
rather than have Linux drive the hardware. So there has not been any
real need to describe networking hardware in ACPI. But maybe LEDs do
have some sort of standard way of being described in ACPI?

	Andrew
Technical Details
Message-ID: <7d5834f9-d67c-4849-9310-2cb3507af141@lunn.ch>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375929-linux-kernel-netdev=dewy.ru
References: <20261201154009.83819-1-dev-josejavier.rodriguez@duagon.com> <20261201154009.83819-2-dev-josejavier.rodriguez@duagon.com> <0ea1ef07-4296-4ca9-b963-996e514f03c1@lunn.ch> <axAujKD53Aqv1u96@MNI-190>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375929-linux-kernel-netdev=dewy.ru
From: andrew@lunn.ch (Andrew Lunn)
Newsgroups: linux.kernel.netdev
Subject: Re: [RFC net-next 1/2] net: ethernet: add MEN Z87 driver
Date: Wed, 2 Dec 2026 17:34:56 +0100
Organization: Usenet Network
Message-ID: <7d5834f9-d67c-4849-9310-2cb3507af141@lunn.ch>
References: <20261201154009.83819-1-dev-josejavier.rodriguez@duagon.com>
 <20261201154009.83819-2-dev-josejavier.rodriguez@duagon.com>
 <0ea1ef07-4296-4ca9-b963-996e514f03c1@lunn.ch>
 <axAujKD53Aqv1u96@MNI-190>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2010675"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:frA1UjD1lvpDqmSClKaZt9PQQrE= sha256:yCOD6Rf6jFUOIWeDq9ayLVKWmNYdhkBds3QXW0OBjqw=
	sha1:/gVnfWn9ykAF1wEuaFzIW3ZlMgA= sha256:wtPht2frZrY+45ZJMpMemYUTdlGAuAPtEurrGV1Qrjs=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 706F21176B2; Wed,  2 Dec 2026 19:35:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=lunn.ch
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id s1UQUlXk1OXg;
	Wed,  2 Dec 2026 19:35:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375929-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=lunn.ch
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 8437F1176A4; Wed,  2 Dec 2026 19:35:16 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 49AE22EE86; Wed,  2 Dec 2026 16:35:09 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796229309;
	b=L0EYFVJRhXXVb+rua5430Dmw0Hvs5GOK0EmQT1t9tuPNgW+u4uzNiivV/IxUZ3lUv5Io
	 1fFEItDrgSHgqw7geKPUp7M5Us6zHhiTmQLm4bdbIQfaAHmtPMn/mC16oSSoQk2xvFU4w
	 UdoPkREgTWszNYKCbqJyESqfBW2WSllhwQfRWUycDknuCEsblLchZ68T1r1XaKgEg+5SV
	 RzWfK5SJrvI+Yg5TDgfBwXlsLiWYhfxDkGHq8XEfWppA2vRDS/7tp86CiOr7FWFQW2Vai
	 WwuHqA5/lJJDOuERBd5a8yzrqzimvftBxwXM1bbDrN9Jnxnm0ChFS76vb17P+7Ui5+g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796229309;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Date:
	 From:To:Cc:Subject:Message-ID:References:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=2syMH7bFRHwnjjVLDiFDmtcYmRqjoZrnAYA0LL3rvoM=;
	b=w/xmU6TkBN6xFheZxN2XG4n8xeCQKfe3fnAJ5YvVEVioqcoCDpG/oddmHlnuUSUM0AgO
	 hYU3n7c8u/VygdhvEz5wHvgLNQCOvWJtIHHh4MveGpMx/tsq/WUSfoZTSazlXF8XV0KfD
	 b2430rjvjPYuBHcZg5BEBzzgz+hT44RS61kAyhgmAWzQywrtjJ2OADPATmS0o+vWZbwES
	 nhRsRx/BVyDVlI9CXKhkfrEh+E828MbdjDrBDrcc8vcYJNCbpQOCV3FqNZfe/iK8YBWV3
	 9ujXsAa3+KA70x2BSOngSQYwemz3pa204OTBqGJAUcft8Y/rJEPC/94R5yzWpU/oMEw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=j6HWHCrl;
	dmarc=pass header.from=lunn.ch;
	spf=pass smtp.mailfrom=lunn.ch;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EA99606A329;
	Wed,  2 Dec 2026 16:35:09 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=j6HWHCrl
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=156.67.10.101
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796229308;
	b=nYVkoUHR1TEw6Ug2YiuG9pEmh6ELs1pKyR1FDzGX1wUZnlYFdySOGrlTPluvNA9o66x/
	 Zyf7jEFNEZxfZiDY3bziNJzEKRgQ4s/7cIQkdSxGxbB5hMDKV4g02rRVlq/ilT5An2dLr
	 2MtderTklEodnd23wlHhnLRHcRLxsh5SSTqfufH9gPAyIRY+CVABJkQKpOOW+KbpKsbfT
	 p8XO4onfVl5r8tmBwJuNXgPA5DqSp2tgC3STRo/RN0W6vQWUpoqyU9CrTCjwLeWEHVw96
	 wvNnLB5P4LmkVFiljs4VoxIKrytgzVQLNogGNGi6AL4jun21Y4D9qIDwiSjxPveWZ2Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796229308;
	h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject:
	 Message-ID:References:MIME-Version:Content-Type:Content-Disposition:
	 In-Reply-To;
	bh=2syMH7bFRHwnjjVLDiFDmtcYmRqjoZrnAYA0LL3rvoM=;
	b=f44beufBQtytj8Eu5dfPQbOcebnly09hmy/Cg+b0oozPqFLoY/wvT8FWm+cGCo2ozsLL
	 1uDadES54pKHZQ3ojtd/Hgn/tmmGZu4cEc1XhfNdYvAaR0msGTBV7GxeQplWtlISGShIa
	 KFdWMKfp+rDqxYg034ZEF1b/PqZnZKRmDV787LxX/itYogVXSXMuvhasIYIjHSA5VQnO5
	 Nncv7qymbAj2PPaGIEAzoktNHvM6DuUvjxqGvGyUigdajCF6N5GmxEmP4xP4ss9vihO+a
	 hBvV1jCUOnpnZQSphbYIJwTCJcTSA9f+52Wm+tsMPAsLE5DpiS8KpILctXOMIUculAQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=lunn.ch;
	spf=pass smtp.mailfrom=lunn.ch;
	dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=j6HWHCrl;
	arc=none smtp.remote-ip=156.67.10.101
X-Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC96D606A322;
	Wed,  2 Dec 2026 16:35:07 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EC96D606A322
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch;
	s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version:
	References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject:
	Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:
	Content-ID:Content-Description:Content-Disposition:In-Reply-To:References;
	bh=2syMH7bFRHwnjjVLDiFDmtcYmRqjoZrnAYA0LL3rvoM=; b=j6HWHCrlWZAxc1Q6VvlwLjx2Fe
	7a5p0vBKMwHhvHgt1bP/0AexzSs+aj01z/X+Chdp9Y7rJeoxkRt03FIcdtqO/D3ZTfbN5IZzSaDEd
	IheFg4R20NyOhQZQku8VgpRGZ0Yu8oNDMppmEZuuwnmSneQfv+C2lNnAlkoqNE5ENn4g=;
X-Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2)
	(envelope-from <andrew@lunn.ch>)
	id 1xYnIG-002rUQ-2b; Wed, 02 Dec 2026 17:34:56 +0100
X-Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	linux-kernel@vger.kernel.org,
	Filip Jensen <dev-Felipe.Jensen@duagon.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <axAujKD53Aqv1u96@MNI-190>