public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Krzysztof Kozlowski <krzk@kernel.org>,
	Marcel Holtmann <marcel@holtmann.org>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name()
Date: Thu, 31 Oct 2024 12:41:11 +0100	[thread overview]
Message-ID: <26d090ef-5630-4afd-8e77-e20019cd018a@gmail.com> (raw)
In-Reply-To: <d9fcd228-8198-4e4c-8752-e950ab598013@kernel.org>

On 31/10/2024 12:30, Krzysztof Kozlowski wrote:
> On 31/10/2024 12:14, Krzysztof Kozlowski wrote:
>> On 31/10/2024 12:10, Javier Carrasco wrote:
>>> On 31/10/2024 12:08, Krzysztof Kozlowski wrote:
>>>> On 30/10/2024 16:46, Javier Carrasco wrote:
>>>>> Switch to a more robust approach by automating the node release when it
>>>>> goes out of scope, removing the need for explicit calls to
>>>>> of_node_put().
>>>>>
>>>>> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
>>>>> ---
>>>>>  drivers/bluetooth/btbcm.c | 8 ++------
>>>>>  1 file changed, 2 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>>>>> index 400c2663d6b0..a1153ada74d2 100644
>>>>> --- a/drivers/bluetooth/btbcm.c
>>>>> +++ b/drivers/bluetooth/btbcm.c
>>>>> @@ -541,23 +541,19 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
>>>>>  static const char *btbcm_get_board_name(struct device *dev)
>>>>>  {
>>>>>  #ifdef CONFIG_OF
>>>>> -	struct device_node *root;
>>>>> +	struct device_node *root __free(device_node) = of_find_node_by_path("/");
>>>>>  	char *board_type;
>>>>>  	const char *tmp;
>>>>>  
>>>>> -	root = of_find_node_by_path("/");
>>>>>  	if (!root)
>>>>>  		return NULL;
>>>>>  
>>>>> -	if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
>>>>> -		of_node_put(root);
>>>>
>>>> You just added this. Don't add code which is immediately removed. It's a
>>>> noop or wrong code.
>>>>
>>>>
>>>>
>>>> Best regards,
>>>> Krzysztof
>>>>
>>>
>>> Exactly, I added that code to fix the issue in stable kernels that don't
>>
>> Then send backport for stable.
>>
>>> support the __free() macro, and then I removed it to use a safer
>>> approach from now on.
>>
>> This is not correct approach. We work here on mainline and in mainline
>> this is one logical change: fixing issue. Whether you fix issue with
>> of_node_put or cleanup or by removing of_find_node_by_path() call, it
>> does not matter. All of these are fixing the same, one issue.
>>
>> If you think about stable kernels, then work on backports, not inflate
>> mainline kernel with multiple commits doing the same, creating
>> artificial history.
>>
> 
> And to clarify even more: these stable backports are close to useless,
> because it does not matter for them. No impact, not much benefits,
> nothing improved for users/developers. There is no need to backport
> them, although of course there is no loss by doing so. Therefore entire
> dance affects mainline kernel without any real benefits for stable.
> 
> Your split suggests you don't really know what this dropping reference
> is for.

Such splits were suggested in other threads, and they came exactly for
those reasons: they could not be applied to stable. That was not my
first approach, which was just using __free() to fix the issue. I am not
looking forward to inflating any history, as that's in the end more work
for me.

If a simple patch that adds the cleanup attribute is enough, that's
awesome. I will go for that approach for all cases then, and use your
explanation as a reference if I am asked to split the fix again.

> Best regards,
> Krzysztof
> 

Thanks for your feedback and best regards,
Javier Carrasco

  reply	other threads:[~2024-10-31 11:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-30 15:46 [PATCH 0/2] Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name() Javier Carrasco
2024-10-30 15:46 ` [PATCH 1/2] " Javier Carrasco
2024-10-30 15:46 ` [PATCH 2/2] Bluetooth: btbcm: automate node cleanup " Javier Carrasco
2024-10-31 11:08   ` Krzysztof Kozlowski
2024-10-31 11:10     ` Javier Carrasco
2024-10-31 11:14       ` Krzysztof Kozlowski
2024-10-31 11:29         ` Javier Carrasco
2024-10-31 11:33           ` Krzysztof Kozlowski
2024-10-31 11:44           ` Krzysztof Kozlowski
2024-10-31 11:30         ` Krzysztof Kozlowski
2024-10-31 11:41           ` Javier Carrasco [this message]
2024-10-31 11:46             ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=26d090ef-5630-4afd-8e77-e20019cd018a@gmail.com \
    --to=javier.carrasco.cruz@gmail.com \
    --cc=krzk@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox