Skip to contentSkip to conversation

counter: intel-qep: Use devm_mutex_init()

PATCH Applied Ilpo Järvinen 4 participants 6 messages May 20 – May 31

Subsystems (4)
lore
Share & tools
lore

Ilpo Järvinen

author maintainer
#0 lore raw

PATCH 1/1 counter: intel-qep: Use devm_mutex_init()

intel_qep_probe() calls mutex_init() but lacks the pairing mutex_destroy() calls. Convert to devm_mutex_init() which handles cleanup automatically.

Fixes b711f687a1c1 ("counter: Add support for Intel Quadrature Encoder Peripheral")
---
 drivers/counter/intel-qep.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/counter/intel-qep.c +3 -1
index c49c178056f4..816586893517 100644
@@ -414,7 +414,9 @@ static int intel_qep_probe(struct pci_dev *pci, const struct pci_device_id *id)
 
 	qep->dev = dev;
 	qep->regs = regs;
-	mutex_init(&qep->lock);
+	ret = devm_mutex_init(dev, &qep->lock);
+	if (ret)
+		return ret;
 
 	intel_qep_init(qep);
 	pci_set_drvdata(pci, qep);

base-commit: 1d5dcaa3bd65f2e8c9baa14a393d3a2dc5db7524

Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#2 lore raw
In reply to Ilpo Järvinen
Quoted 17 lines · Ilpo Järvinen

intel_qep_probe() calls mutex_init() but lacks the pairing mutex_destroy() calls. Convert to devm_mutex_init() which handles cleanup automatically.

Fixes b711f687a1c1 ("counter: Add support for Intel Quadrature Encoder Peripheral")
---
 drivers/counter/intel-qep.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/counter/intel-qep.c +0 -0
index c49c178056f4..816586893517 100644

drivers/counter/intel-qep.c static int intel_qep_probe(struct pci_dev *pci, const struct pci_device_id *id) · line 419

Quoted 7 lines
drivers/counter/intel-qep.c +3 -1
@@ -414,7 +414,9 @@ static int intel_qep_probe(struct pci_dev *pci, const struct pci_device_id *id)
 
        qep->dev = dev;
        qep->regs = regs;
-       mutex_init(&qep->lock);
+       ret = devm_mutex_init(dev, &qep->lock);
+       if (ret)
+               return ret;

Unless you're compiling with CONFIG_DEBUG_MUTEXES, mutex_destroy() is a nop, so a solo mutex_init() call is okay. Nevertheless the devm_ counterpart makes
debugging easier.

Signature · 3 lines
Kind regards

CJD
maintainer Applied
#3 lore raw
In reply to Ilpo Järvinen
Quoted 5 lines · Ilpo Järvinen

intel_qep_probe() calls mutex_init() but lacks the pairing mutex_destroy() calls. Convert to devm_mutex_init() which handles cleanup automatically.

Applied, thanks!

[1/1] counter: intel-qep: Use devm_mutex_init()

      commit: ff35c72101d1dc6793496ade9c1bc3d70dd27bdd

Best regards,

Signature · 1 line
William Breathitt Gray <[email protected]>
#4 lore raw
Quoted 8 lines · William Breathitt Gray
Quoted 5 lines · Ilpo Järvinen

intel_qep_probe() calls mutex_init() but lacks the pairing mutex_destroy() calls. Convert to devm_mutex_init() which handles cleanup automatically.

Quoted 8 lines

Applied, thanks!

[1/1] counter: intel-qep: Use devm_mutex_init()

      commit: ff35c72101d1dc6793496ade9c1bc3d70dd27bdd

Best regards,
--
William Breathitt Gray <[email protected]>

Hello Ilpo,

In a similar patch[^1], Jonathan made a good point that a Fixes tag may not be appropriate for this patch when it only affects debug information as Joshua pointed out[^2].

So I am going to treat this as an update patch to intel-qep rather than a bug fix and remove the Fixes tag and [email protected] CC line from the description. If you feel that this patch really should be picked up by the stable trees, please let us know and we can discuss further.

Thank you,

William Breathitt Gray

[^1] https://lore.kernel.org/all/20260527175513.0df47897@jic23-huawei/
[^2] https://lore.kernel.org/all/CALoEA-wrYjbkhM7EiS+f-JjXShpRJw+gqy2zzymq9Ue5t-XN5A@mail.gmail.com/

author maintainer
#5 lore raw
Quoted 24 lines · William Breathitt Gray
Quoted 8 lines · William Breathitt Gray
Quoted 5 lines · Ilpo Järvinen

intel_qep_probe() calls mutex_init() but lacks the pairing mutex_destroy() calls. Convert to devm_mutex_init() which handles cleanup automatically.

Quoted 8 lines

Applied, thanks!

[1/1] counter: intel-qep: Use devm_mutex_init()

      commit: ff35c72101d1dc6793496ade9c1bc3d70dd27bdd

Best regards,
--
William Breathitt Gray <[email protected]>

Hello Ilpo,

In a similar patch[^1], Jonathan made a good point that a Fixes tag may not be appropriate for this patch when it only affects debug information as Joshua pointed out[^2].

Quoted 5 lines

So I am going to treat this as an update patch to intel-qep rather than a bug fix and remove the Fixes tag and [email protected] CC line from the description. If you feel that this patch really should be picked up by the stable trees, please let us know and we can discuss further.

Hi,

It's fine for me to leave those tags out if you so prefer.

Signature · 1 line
 i.