diff mbox series

hte: tegra-194: Convert to platform remove callback returning void

Message ID 0b0a5d3816973ee88d4be9fe9f2349065a42cbff.1709886922.git.u.kleine-koenig@pengutronix.de
State Handled Elsewhere
Headers show
Series hte: tegra-194: Convert to platform remove callback returning void | expand

Commit Message

Uwe Kleine-König March 8, 2024, 8:51 a.m. UTC
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/hte/hte-tegra194-test.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)


base-commit: 8ffc8b1bbd505e27e2c8439d326b6059c906c9dd

Comments

Thierry Reding March 11, 2024, 4:04 p.m. UTC | #1
On Fri Mar 8, 2024 at 9:51 AM CET, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is ignored (apart
> from emitting a warning) and this typically results in resource leaks.
>
> To improve here there is a quest to make the remove callback return
> void. In the first step of this quest all drivers are converted to
> .remove_new(), which already returns void. Eventually after all drivers
> are converted, .remove_new() will be renamed to .remove().
>
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/hte/hte-tegra194-test.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Acked-by: Thierry Reding <treding@nvidia.com>
Dipen Patel March 11, 2024, 5:13 p.m. UTC | #2
On 3/11/24 9:04 AM, Thierry Reding wrote:
> On Fri Mar 8, 2024 at 9:51 AM CET, Uwe Kleine-König wrote:
>> The .remove() callback for a platform driver returns an int which makes
>> many driver authors wrongly assume it's possible to do error handling by
>> returning an error code. However the value returned is ignored (apart
>> from emitting a warning) and this typically results in resource leaks.
>>
>> To improve here there is a quest to make the remove callback return
>> void. In the first step of this quest all drivers are converted to
>> .remove_new(), which already returns void. Eventually after all drivers
>> are converted, .remove_new() will be renamed to .remove().
>>
>> Trivially convert this driver from always returning zero in the remove
>> callback to the void returning variant.
>>
>> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>> ---
>>  drivers/hte/hte-tegra194-test.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> Acked-by: Thierry Reding <treding@nvidia.com>
Do you want me to take this patch or want to add in your patch series
for the drivers with similar changes?

Acked-by: Dipen Patel <dipenp@nvidia.com>
Uwe Kleine-König March 11, 2024, 8:36 p.m. UTC | #3
Hello Dipen,

On Mon, Mar 11, 2024 at 10:13:15AM -0700, Dipen Patel wrote:
> On 3/11/24 9:04 AM, Thierry Reding wrote:
> > On Fri Mar 8, 2024 at 9:51 AM CET, Uwe Kleine-König wrote:
> >> The .remove() callback for a platform driver returns an int which makes
> >> many driver authors wrongly assume it's possible to do error handling by
> >> returning an error code. However the value returned is ignored (apart
> >> from emitting a warning) and this typically results in resource leaks.
> >>
> >> To improve here there is a quest to make the remove callback return
> >> void. In the first step of this quest all drivers are converted to
> >> .remove_new(), which already returns void. Eventually after all drivers
> >> are converted, .remove_new() will be renamed to .remove().
> >>
> >> Trivially convert this driver from always returning zero in the remove
> >> callback to the void returning variant.
> >>
> >> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> >> ---
> >>  drivers/hte/hte-tegra194-test.c | 6 ++----
> >>  1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > Acked-by: Thierry Reding <treding@nvidia.com>
> Do you want me to take this patch or want to add in your patch series
> for the drivers with similar changes?
> 
> Acked-by: Dipen Patel <dipenp@nvidia.com>

I don't plan (yet) to care for applying these changes myself. So if you
could pick it up that would be great.

Best regards
Uwe
Uwe Kleine-König April 12, 2024, 12:35 p.m. UTC | #4
Hello Dipen,

On Mon, Mar 11, 2024 at 09:36:06PM +0100, Uwe Kleine-König wrote:
> On Mon, Mar 11, 2024 at 10:13:15AM -0700, Dipen Patel wrote:
> > On 3/11/24 9:04 AM, Thierry Reding wrote:
> > > On Fri Mar 8, 2024 at 9:51 AM CET, Uwe Kleine-König wrote:
> > >> The .remove() callback for a platform driver returns an int which makes
> > >> many driver authors wrongly assume it's possible to do error handling by
> > >> returning an error code. However the value returned is ignored (apart
> > >> from emitting a warning) and this typically results in resource leaks.
> > >>
> > >> To improve here there is a quest to make the remove callback return
> > >> void. In the first step of this quest all drivers are converted to
> > >> .remove_new(), which already returns void. Eventually after all drivers
> > >> are converted, .remove_new() will be renamed to .remove().
> > >>
> > >> Trivially convert this driver from always returning zero in the remove
> > >> callback to the void returning variant.
> > >>
> > >> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > >> ---
> > >>  drivers/hte/hte-tegra194-test.c | 6 ++----
> > >>  1 file changed, 2 insertions(+), 4 deletions(-)
> > > 
> > > Acked-by: Thierry Reding <treding@nvidia.com>
> > Do you want me to take this patch or want to add in your patch series
> > for the drivers with similar changes?
> > 
> > Acked-by: Dipen Patel <dipenp@nvidia.com>
> 
> I don't plan (yet) to care for applying these changes myself. So if you
> could pick it up that would be great.

Either you didn't pick it up or your tree isn't included in next. Both
options are not optimal in my eyes.

Given that I want to change struct platform_driver::remove in the merge
window after v6.10, it would be great if this patch made it into
v6.10-rc1.

Thanks for considering
Uwe
Dipen Patel April 12, 2024, 5:49 p.m. UTC | #5
On 4/12/24 5:35 AM, Uwe Kleine-König wrote:
> Hello Dipen,
> 
> On Mon, Mar 11, 2024 at 09:36:06PM +0100, Uwe Kleine-König wrote:
>> On Mon, Mar 11, 2024 at 10:13:15AM -0700, Dipen Patel wrote:
>>> On 3/11/24 9:04 AM, Thierry Reding wrote:
>>>> On Fri Mar 8, 2024 at 9:51 AM CET, Uwe Kleine-König wrote:
>>>>> The .remove() callback for a platform driver returns an int which makes
>>>>> many driver authors wrongly assume it's possible to do error handling by
>>>>> returning an error code. However the value returned is ignored (apart
>>>>> from emitting a warning) and this typically results in resource leaks.
>>>>>
>>>>> To improve here there is a quest to make the remove callback return
>>>>> void. In the first step of this quest all drivers are converted to
>>>>> .remove_new(), which already returns void. Eventually after all drivers
>>>>> are converted, .remove_new() will be renamed to .remove().
>>>>>
>>>>> Trivially convert this driver from always returning zero in the remove
>>>>> callback to the void returning variant.
>>>>>
>>>>> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>>>>> ---
>>>>>  drivers/hte/hte-tegra194-test.c | 6 ++----
>>>>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>>>
>>>> Acked-by: Thierry Reding <treding@nvidia.com>
>>> Do you want me to take this patch or want to add in your patch series
>>> for the drivers with similar changes?
>>>
>>> Acked-by: Dipen Patel <dipenp@nvidia.com>
>>
>> I don't plan (yet) to care for applying these changes myself. So if you
>> could pick it up that would be great.
> 
> Either you didn't pick it up or your tree isn't included in next. Both
> options are not optimal in my eyes.
> 
> Given that I want to change struct platform_driver::remove in the merge
> window after v6.10, it would be great if this patch made it into
> v6.10-rc1.
> 
> Thanks for considering
> Uwe
> 
Sorry for the miss, I will pick it up for 6.10.

Best Regards,
Dipen Patel
diff mbox series

Patch

diff --git a/drivers/hte/hte-tegra194-test.c b/drivers/hte/hte-tegra194-test.c
index ab2edff018eb..8ee038ccf601 100644
--- a/drivers/hte/hte-tegra194-test.c
+++ b/drivers/hte/hte-tegra194-test.c
@@ -214,7 +214,7 @@  static int tegra_hte_test_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int tegra_hte_test_remove(struct platform_device *pdev)
+static void tegra_hte_test_remove(struct platform_device *pdev)
 {
 	(void)pdev;
 
@@ -222,13 +222,11 @@  static int tegra_hte_test_remove(struct platform_device *pdev)
 	gpiod_put(hte.gpio_in);
 	gpiod_put(hte.gpio_out);
 	del_timer_sync(&hte.timer);
-
-	return 0;
 }
 
 static struct platform_driver tegra_hte_test_driver = {
 	.probe = tegra_hte_test_probe,
-	.remove = tegra_hte_test_remove,
+	.remove_new = tegra_hte_test_remove,
 	.driver = {
 		.name = "tegra_hte_test",
 		.of_match_table = tegra_hte_test_of_match,