* [PATCH] media: tw5864: Simplify 'tw5864_finidev()'
@ 2021-10-16 8:40 Christophe JAILLET
2021-10-19 10:35 ` Kieran Bingham
0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2021-10-16 8:40 UTC (permalink / raw)
To: maintainers, anton, andrey.utkin, mchehab
Cc: linux-media, linux-kernel, kernel-janitors, Christophe JAILLET
Some resources are allocated with 'pci_request_regions()', so use
'pci_release_regions()' to free them, instead of a verbose
'release_mem_region()'.
There is no point in calling 'devm_kfree()'. The corresponding resource is
managed, so it will be fried automatically.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/media/pci/tw5864/tw5864-core.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/media/pci/tw5864/tw5864-core.c b/drivers/media/pci/tw5864/tw5864-core.c
index 23d3cae54a5d..fee3b7711901 100644
--- a/drivers/media/pci/tw5864/tw5864-core.c
+++ b/drivers/media/pci/tw5864/tw5864-core.c
@@ -333,11 +333,9 @@ static void tw5864_finidev(struct pci_dev *pci_dev)
/* release resources */
iounmap(dev->mmio);
- release_mem_region(pci_resource_start(pci_dev, 0),
- pci_resource_len(pci_dev, 0));
+ pci_release_regions(pci_dev);
v4l2_device_unregister(&dev->v4l2_dev);
- devm_kfree(&pci_dev->dev, dev);
}
static struct pci_driver tw5864_pci_driver = {
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] media: tw5864: Simplify 'tw5864_finidev()'
2021-10-16 8:40 [PATCH] media: tw5864: Simplify 'tw5864_finidev()' Christophe JAILLET
@ 2021-10-19 10:35 ` Kieran Bingham
2021-10-19 17:46 ` Christophe JAILLET
0 siblings, 1 reply; 3+ messages in thread
From: Kieran Bingham @ 2021-10-19 10:35 UTC (permalink / raw)
To: Christophe JAILLET, andrey.utkin, anton, maintainers, mchehab
Cc: linux-media, linux-kernel, kernel-janitors, Christophe JAILLET
Quoting Christophe JAILLET (2021-10-16 09:40:29)
> Some resources are allocated with 'pci_request_regions()', so use
> 'pci_release_regions()' to free them, instead of a verbose
> 'release_mem_region()'.
And the driver was even already using pci_release_regions() in
tw5864_initdev(), so indeed this makes it more consistent too.
I'm curious that tw5864_initdev() calls pci_enable_device() (and
pci_disable_device in it's error path), while tw5864_finidev() doesn't.
Would you like to submit a patch to fix that on top of this one? or should I?
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> There is no point in calling 'devm_kfree()'. The corresponding resource is
> managed, so it will be fried automatically.
Indeed.
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/media/pci/tw5864/tw5864-core.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/media/pci/tw5864/tw5864-core.c b/drivers/media/pci/tw5864/tw5864-core.c
> index 23d3cae54a5d..fee3b7711901 100644
> --- a/drivers/media/pci/tw5864/tw5864-core.c
> +++ b/drivers/media/pci/tw5864/tw5864-core.c
> @@ -333,11 +333,9 @@ static void tw5864_finidev(struct pci_dev *pci_dev)
>
> /* release resources */
> iounmap(dev->mmio);
> - release_mem_region(pci_resource_start(pci_dev, 0),
> - pci_resource_len(pci_dev, 0));
> + pci_release_regions(pci_dev);
>
> v4l2_device_unregister(&dev->v4l2_dev);
> - devm_kfree(&pci_dev->dev, dev);
> }
>
> static struct pci_driver tw5864_pci_driver = {
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: tw5864: Simplify 'tw5864_finidev()'
2021-10-19 10:35 ` Kieran Bingham
@ 2021-10-19 17:46 ` Christophe JAILLET
0 siblings, 0 replies; 3+ messages in thread
From: Christophe JAILLET @ 2021-10-19 17:46 UTC (permalink / raw)
To: Kieran Bingham, andrey.utkin, anton, maintainers, mchehab
Cc: linux-media, linux-kernel, kernel-janitors
Le 19/10/2021 à 12:35, Kieran Bingham a écrit :
> Quoting Christophe JAILLET (2021-10-16 09:40:29)
>> Some resources are allocated with 'pci_request_regions()', so use
>> 'pci_release_regions()' to free them, instead of a verbose
>> 'release_mem_region()'.
>
> And the driver was even already using pci_release_regions() in
> tw5864_initdev(), so indeed this makes it more consistent too.
>
> I'm curious that tw5864_initdev() calls pci_enable_device() (and
> pci_disable_device in it's error path), while tw5864_finidev() doesn't.
I agree with you. I should have spotted it when I've looked at the probe
and remove functions :(
>
> Would you like to submit a patch to fix that on top of this one? or should I?
Either way is fine for me.
If it's fine for you to fix it, I leave it to you.
A more invasive fix could be to switch to 'pcim_enable_device()' and
remove both 'pci_release_regions()' and 'pci_disable_device()' calls.
CJ
>
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>
>> There is no point in calling 'devm_kfree()'. The corresponding resource is
>> managed, so it will be fried automatically.
>
> Indeed.
>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>> drivers/media/pci/tw5864/tw5864-core.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/media/pci/tw5864/tw5864-core.c b/drivers/media/pci/tw5864/tw5864-core.c
>> index 23d3cae54a5d..fee3b7711901 100644
>> --- a/drivers/media/pci/tw5864/tw5864-core.c
>> +++ b/drivers/media/pci/tw5864/tw5864-core.c
>> @@ -333,11 +333,9 @@ static void tw5864_finidev(struct pci_dev *pci_dev)
>>
>> /* release resources */
>> iounmap(dev->mmio);
>> - release_mem_region(pci_resource_start(pci_dev, 0),
>> - pci_resource_len(pci_dev, 0));
>> + pci_release_regions(pci_dev);
>>
>> v4l2_device_unregister(&dev->v4l2_dev);
>> - devm_kfree(&pci_dev->dev, dev);
>> }
>>
>> static struct pci_driver tw5864_pci_driver = {
>> --
>> 2.30.2
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-19 17:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-16 8:40 [PATCH] media: tw5864: Simplify 'tw5864_finidev()' Christophe JAILLET
2021-10-19 10:35 ` Kieran Bingham
2021-10-19 17:46 ` Christophe JAILLET
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).