🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #22480

Re: [PATCH net-next 2/2] net: ti: icssg-prueth: Add ethtool RX flow classification support

#22480
From: Simon Horman
Date: Wed, 25 Nov 2026 11:36
54 lines
10105 bytes
On Thu, Nov 19, 2026 at 10:19:48AM +0100, Marco Crivellari wrote:
> Hi,
> 
> On Wed, Nov 18, 2026 at 7:50 PM Meghana Malladi <m-malladi@ti.com> wrote:
> > [...]
> > +       mutex_lock(&emac->rxnfc.rxnfc_lock);
> > +
> > +       /* Check max rules */
> > +       if (emac->rxnfc.rxnfc_rule_count >= ICSSG_RXNFC_MAX_RULES) {
> > +               ret = -ENOSPC;
> > +               goto unlock;
> > +       }
> >  [...]
> > +
> > +unlock:
> > +       mutex_unlock(&emac->rxnfc.rxnfc_lock);
> > +       return ret;
> > +}
> > +EXPORT_SYMBOL_GPL(icssg_rxnfc_rule_add);
> 
> nit: instead of mutex_lock() you can use guard() [1]:
> 
>     guard(mutex)(&emac->rxnfc.rxnfc_lock)
> 
> and remove all the "goto unlock", returning directly. This handles the
> automatic cleanup.
> 
> Same for other places where you're using mutex_lock() / mutex_unlock().
> 
> - [1] https://docs.kernel.org/core-api/cleanup.html

Thanks Marco,

That may be good general advice.
But for networking code the explicit approach taken by this patch
is still preferred.

  Using device-managed and cleanup.h constructs

  Netdev remains skeptical about promises of all “auto-cleanup” APIs,
  including even devm_ helpers, historically. They are not the preferred
  style of implementation, merely an acceptable one.

  Use of guard() is discouraged within any function longer than 20 lines,
  scoped_guard() is considered more readable. Using normal lock/unlock is
  still (weakly) preferred.

  Low level cleanup constructs (such as __free()) can be used when building
  APIs and helpers, especially scoped iterators. However, direct use of
  __free() within networking core and drivers is discouraged. Similar
  guidance applies to declaring variables mid-function.

  Link: https://docs.kernel.org/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs
Technical Details
Message-ID: <20261125113634.GT31322@horms.kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371272-linux-kernel-netdev=dewy.ru
References: <20261118184729.2302130-1-m-malladi@ti.com> <20261118184729.2302130-3-m-malladi@ti.com> <CAAofZF4XYd5z8X56DRARMxbu3t7QX48T7V69MPBw9TW1BQAmKg@mail.gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371272-linux-kernel-netdev=dewy.ru
From: horms@kernel.org (Simon Horman)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 2/2] net: ti: icssg-prueth: Add ethtool RX flow
 classification support
Date: Wed, 25 Nov 2026 11:36:34 +0000
Organization: Usenet Network
Message-ID: <20261125113634.GT31322@horms.kernel.org>
References: <20261118184729.2302130-1-m-malladi@ti.com>
 <20261118184729.2302130-3-m-malladi@ti.com>
 <CAAofZF4XYd5z8X56DRARMxbu3t7QX48T7V69MPBw9TW1BQAmKg@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="194750"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:6kZJw0x/Y1sTOZSeQHkCraH895g= sha256:BeSqJX6GgKUzAmY3n1FsjjCAUYPB6Qr3ZmKZdfC+PtU=
	sha1:STehdZav5EE3EJF+Ngsff87VCHQ= sha256:QK+8Cr/lRtsBM1XUuorlVk+Qr129wPHnyDkELtgWXmc=
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 9D424125E59; Wed, 25 Nov 2026 14:37:10 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	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 (2048-bit key)
	header.d=kernel.org
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 7kUF69Y19rmD;
	Wed, 25 Nov 2026 14:37:02 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-371272-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 75A26125E57; Wed, 25 Nov 2026 14:36:54 +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 6306434A62; Wed, 25 Nov 2026 11:36:52 +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=1795606612;
	b=MkaO8LBdCcr+xNAi1SJLQ4yYQLu5F4gCrprEL9bUma7pXbYHoPHdrJ6y3/TrufTJPY2J
	 Nc+5sAwt23Ci2uccRO0odKM8o5HmRQSqXl2F5d/QRYx9z87geAuyqVkACZ0zS58cP1ADW
	 j7dgudbVPcdkpVSfTqxnaGmIAPWJmITRZZrMFFZuT48T26hHgGQw+rlQ1GKcptU5yrTLp
	 jf4QSOLcBjSllDr72XDRZglGSjt1Q6xK01vx+Cm/UbzukbD53upQyXpq7rxOO2SJPnIcq
	 uNz4qZQ8lJ0FbjtAEai/V3TjRWpEfDZbefkGNjDCX5eBnj1xgiAQZFac+olwhqzFoAA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795606612;
	h=X-Original-To:Received:Received:DKIM-Signature: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:
	 Content-Transfer-Encoding:In-Reply-To;
	bh=8lUtvBf4yp1q4uRBQvvRAWZrQAMHjkc9iS4tTLTfDyA=;
	b=fLSwa0hh54HURu7qznQF0ZD0TSSzCRI6X036ndbBTxFReB756da6FfgFS3Nf9VhoQX/U
	 xbxj85rfzvf7lHjiXq+gSor0eeenZ9Z1HWYJhX9eNBpsMxKJhsmDNl8sdJuSstU/b4qhq
	 IHNbThh7HC0lm+Ou8ntEwVFrI7+o+ljcV8bItbcSYIGkDIu+sCdOMTSxY8C3aiMsw8lEL
	 HgsBH34vT4QfR9tnmKQGhNXQ38vctmAYssvXjYvtCQF3kp+iSgCRtxNczuipOkQbYtx85
	 Pm6PFFmIJLi8vQfrs6gu6CueWK0uL3tHCTQYUo/vrLunazqMVkz5p7N2pT/zGdn7gug==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OEK+WUgT;
	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 381B6606A330;
	Wed, 25 Nov 2026 11:36:52 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OEK+WUgT
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795606601;
	b=2zwO3+ZrAl/LSuax9Y6Du+LMijQbOn/9FiQALRdFMEdPX5ERlQSorOS6/0l2TUqYd159
	 OysBxFjG5pMG9/QK4YZ4DqLSA2ZS/vEoRdNlUrLs/iJ37TuCBeH/D7yWo8jTLDW4oNTHJ
	 CSQPAmwKXwgV+F5SaKZSkfdV7oby561yE0IXX9+vVXHutF9VcSa/Fms+Jw9wSIFi0tHSB
	 jjnitIneHbQ4yghBJr1fdMJsefZ3jw1PCTA0xRJadiXHbft78Alo6+diUq3Fy/Zui3LzD
	 u4FxKVApAMZi3/aHMR+RzdmEk4MApovJ+WJbnrJaeDIaRscCgcZRjqCvM8iKkI9L0/Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795606601;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:
	 Content-Transfer-Encoding:In-Reply-To;
	bh=8lUtvBf4yp1q4uRBQvvRAWZrQAMHjkc9iS4tTLTfDyA=;
	b=DBnZpzFGBb/WAYP2rPeoeaa43xkfgIXq8yen3D9VEURt1Ut0USno87+GFSLGdWKrQg9v
	 liAqrioODjLA/pj1kbz6ebTnchLJdArVN0siKlObg6QhpaZ8ikP20F2+vALfZrXyZ4kSO
	 sxWMwtRnEAD0hIwOagU4NezT+kZp4SNbmZTgqYqyKs14695bpxXscqKCHhcOBIz5SA/9Z
	 EDiSpxRi2QEWSBkXzRfwgAJfU1kYrocdfaD+7HHlruSyQdJ1DmQ7QN0+yAxsr+Am+7Lw9
	 +48wcaC6bJqS7v6DGgvSs+V6aiqPP5gvjUhHMmpM3qSzq4M9Q/1Mc5A+W2ws/f+xplA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OEK+WUgT;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54237606A31E;
	Wed, 25 Nov 2026 11:36:41 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D9D51F000CA;
	Wed, 25 Nov 2026 11:36:36 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795606600;
	bh=8lUtvBf4yp1q4uRBQvvRAWZrQAMHjkc9iS4tTLTfDyA=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=OEK+WUgTJdEarfLjej1HEQDPg1tpmClXTWZKCTeuWPyTcUZTsgfsbeVmYw7beWYif
	 SCn5YZyW62ypU6+YGtN40Xm/UGIBnPPVp01hWmUc0KXSHwHxLNPKNiROGjNDjT9FNh
	 0dQjV2DwEIcwBrvnMZGycFinF0L9HNUThcW5z8UTA0s1/q+EBi/JGIr+Tbud0bnsWH
	 uRfUh4yStcTsT8j9CDvLcqoRY7Q8R0/ib7q91r0cBsW0SMgxSrIQK48n12s6b208Eq
	 nQXKyqVc15Y5aBdK3k2ARBhNywi6Ubv4RGlW34ti4WdcyOKEdzvxTdINKeYIZRf0ZM
	 7mpix3n+1kJvA==
X-Cc: Meghana Malladi <m-malladi@ti.com>, kees+treewide@kernel.org,
	laixiangwu@cmss.chinamobile.com, philippe.schenker@impulsing.ch,
	haokexin@gmail.com, devnexen@gmail.com, jacob.e.keller@intel.com,
	sdf@fomichev.me, john.fastabend@gmail.com, hawk@kernel.org,
	daniel@iogearbox.net, ast@kernel.org, pabeni@redhat.com,
	kuba@kernel.org, edumazet@kernel.org, davem@davemloft.net,
	andrew+netdev@lunn.ch, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, srk@ti.com,
	Vignesh Raghavendra <vigneshr@ti.com>, danishanwar@ti.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: <CAAofZF4XYd5z8X56DRARMxbu3t7QX48T7V69MPBw9TW1BQAmKg@mail.gmail.com>