public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v2] staging: pi433: add comment to rx_lock mutex definition
@ 2021-12-22 21:56 Paulo Miguel Almeida
  2021-12-30 10:56 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Paulo Miguel Almeida @ 2021-12-22 21:56 UTC (permalink / raw)
  To: gregkh, realwakka, paulo.miguel.almeida.rodenas
  Cc: linux-staging, linux-kernel

Checkpatch reports: CHECK: struct mutex definition without comment.
Fix this by documenting what rx_mutex struct is used for in pi433 driver.

Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
---
v2: ellaborate on reasons why the mutex lock is used in the driver (Req: Greg k-h)
v1: https://lore.kernel.org/lkml/20211222093626.GA13332@localhost.localdomain/
---
 drivers/staging/pi433/pi433_if.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 29bd37669059..1cd3d5f2df2a 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -92,6 +92,17 @@ struct pi433_device {
 	u32			rx_bytes_to_drop;
 	u32			rx_bytes_dropped;
 	unsigned int		rx_position;
+	/*
+	 * rx_lock is used to avoid race-conditions that can be triggered from userspace.
+	 *
+	 * For instance, if a program in userspace is reading the char device
+	 * allocated in this module then another program won't be able to change RX
+	 * configuration of the RF69 hardware module via ioctl and vice versa.
+	 *
+	 * utilization summary:
+	 *  - pi433_read: blocks are read until rx read something (up to the buffer size)
+	 *  - pi433_ioctl: during pending read request, change of config not allowed
+	 */
 	struct mutex		rx_lock;
 	wait_queue_head_t	rx_wait_queue;
 
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-30 14:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-22 21:56 [PATCH v2] staging: pi433: add comment to rx_lock mutex definition Paulo Miguel Almeida
2021-12-30 10:56 ` Greg KH
2021-12-30 14:56   ` Paulo Miguel Almeida

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox