[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3a325efb-af05-4e39-b9ae-587d55af9b0b@gmail.com>
Date: Wed, 9 Oct 2024 01:31:14 +0200
From: Javier Carrasco <javier.carrasco.cruz@...il.com>
To: Andrew Lunn <andrew@...n.ch>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Daniel Scally <djrscally@...il.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Florian Fainelli <f.fainelli@...il.com>, Vladimir Oltean
<olteanv@...il.com>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Linus Walleij <linus.walleij@...aro.org>,
linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org
Subject: Re: [PATCH net-next 3/3] net: dsa: mv88e6xxx: leds: fix leds refcount
On 08/10/2024 18:40, Andrew Lunn wrote:
>> - leds = fwnode_get_named_child_node(p->fwnode, "leds");
>> + struct fwnode_handle *leds __free(fwnode_handle) =
>> + fwnode_get_named_child_node(p->fwnode, "leds");
>
> https://docs.kernel.org/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs
>
> 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.
>
> Andrew
>
> ---
> pw-bot: cr
Hi Andrew,
Thanks for your review. I have seen that the __free() macro is used in
multiple net drivers, especially (but not only) __free(kfree). Why would
this one would be discouraged?
I would have nothing against declaring the variable at the top and
initializing it to NULL if that is the preferred way in the networking
subsystem, but the __free() macro seems to be well established, and it
simplifies the code.
Otherwise 4 calls to fwnode_handle_put() or a couple of goto jumps will
be required to get the same result. Moreover, if any other error path is
introduced, the mechanism will automatically account for it.
Best regards,
Javier Carrasco
Powered by blists - more mailing lists