* [PATCH] Bluetooth: vhci: manage mutex with cleanup helpers
@ 2024-08-13 12:18 Yo-Jung (Leo) Lin
2024-08-13 12:38 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Yo-Jung (Leo) Lin @ 2024-08-13 12:18 UTC (permalink / raw)
Cc: linux-kernel-mentees, ricardo, skhan, 0xff07, Marcel Holtmann,
Luiz Augusto von Dentz, linux-bluetooth, linux-kernel
Use macros in liunx/cleanup.h for automatic resource cleanup.
Signed-off-by: Yo-Jung (Leo) Lin <0xff07@gmail.com>
---
drivers/bluetooth/hci_vhci.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index c4046f8f1985..70f0c28372ec 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -19,6 +19,7 @@
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/poll.h>
+#include <linux/cleanup.h>
#include <linux/skbuff.h>
#include <linux/miscdevice.h>
@@ -468,9 +469,9 @@ static int vhci_create_device(struct vhci_data *data, __u8 opcode)
{
int err;
- mutex_lock(&data->open_mutex);
- err = __vhci_create_device(data, opcode);
- mutex_unlock(&data->open_mutex);
+ scoped_guard(mutex, &data->open_mutex) {
+ err = __vhci_create_device(data, opcode);
+ }
return err;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] Bluetooth: vhci: manage mutex with cleanup helpers
2024-08-13 12:18 [PATCH] Bluetooth: vhci: manage mutex with cleanup helpers Yo-Jung (Leo) Lin
@ 2024-08-13 12:38 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2024-08-13 12:38 UTC (permalink / raw)
To: Yo-Jung (Leo) Lin
Cc: linux-kernel-mentees, ricardo, skhan, Marcel Holtmann,
Luiz Augusto von Dentz, linux-bluetooth, linux-kernel
On Tue, Aug 13, 2024 at 08:18:28PM +0800, Yo-Jung (Leo) Lin wrote:
> Use macros in liunx/cleanup.h for automatic resource cleanup.
That says what you do, but not _why_ you want to do it.
>
> Signed-off-by: Yo-Jung (Leo) Lin <0xff07@gmail.com>
> ---
> drivers/bluetooth/hci_vhci.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
> index c4046f8f1985..70f0c28372ec 100644
> --- a/drivers/bluetooth/hci_vhci.c
> +++ b/drivers/bluetooth/hci_vhci.c
> @@ -19,6 +19,7 @@
> #include <linux/errno.h>
> #include <linux/sched.h>
> #include <linux/poll.h>
> +#include <linux/cleanup.h>
>
> #include <linux/skbuff.h>
> #include <linux/miscdevice.h>
> @@ -468,9 +469,9 @@ static int vhci_create_device(struct vhci_data *data, __u8 opcode)
> {
> int err;
>
> - mutex_lock(&data->open_mutex);
> - err = __vhci_create_device(data, opcode);
> - mutex_unlock(&data->open_mutex);
> + scoped_guard(mutex, &data->open_mutex) {
> + err = __vhci_create_device(data, opcode);
> + }
This isn't correct, but also, it's not needed at all :(
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-13 12:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-13 12:18 [PATCH] Bluetooth: vhci: manage mutex with cleanup helpers Yo-Jung (Leo) Lin
2024-08-13 12:38 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox