Skip to contentSkip to conversation

rfkill: print events when input handler is disabled/enabled

PATCH In review Johannes Berg 2 participants 4 messages Jun 7, 2009 – Jun 8, 2009 Rfkill

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH 1/1 rfkill: print events when input handler is disabled/enabled

It is useful for debugging when we know if something disabled the in-kernel rfkill input handler.

---
 net/rfkill/core.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/rfkill/core.c +4 -2
@@ -1134,7 +1134,8 @@ static int rfkill_fop_release(struct ino
 
 #ifdef CONFIG_RFKILL_INPUT
 	if (data->input_handler)
-		atomic_dec(&rfkill_input_disabled);
+		if (atomic_dec_return(&rfkill_input_disabled) == 0)
+			printk(KERN_DEBUG "rfkill: input handler enabled\n");
 #endif
 
 	kfree(data);
@@ -1157,7 +1158,8 @@ static long rfkill_fop_ioctl(struct file
 	mutex_lock(&data->mtx);
 
 	if (!data->input_handler) {
-		atomic_inc(&rfkill_input_disabled);
+		if (atomic_inc_return(&rfkill_input_disabled) == 1)
+			printk(KERN_DEBUG "rfkill: input handler disabled\n");
 		data->input_handler = true;
 	}
 
#1 lore raw

Hi Johannes,

Quoted 21 lines

It is useful for debugging when we know if something disabled the in-kernel rfkill input handler.

---
 net/rfkill/core.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/rfkill/core.c +2 -1
@@ -1134,7 +1134,8 @@ static int rfkill_fop_release(struct ino
 
 #ifdef CONFIG_RFKILL_INPUT
 	if (data->input_handler)
-		atomic_dec(&rfkill_input_disabled);
+		if (atomic_dec_return(&rfkill_input_disabled) == 0)
+			printk(KERN_DEBUG "rfkill: input handler enabled\n");
 #endif
 
 	kfree(data);

net/rfkill/core.c static long rfkill_fop_ioctl(struct file · line 1164

Quoted 8 lines
net/rfkill/core.c +2 -1
@@ -1157,7 +1158,8 @@ static long rfkill_fop_ioctl(struct file
 	mutex_lock(&data->mtx);
 
 	if (!data->input_handler) {
-		atomic_inc(&rfkill_input_disabled);
+		if (atomic_inc_return(&rfkill_input_disabled) == 1)
+			printk(KERN_DEBUG "rfkill: input handler disabled\n");
 		data->input_handler = true;
 	}

do you really think the == 1 is the correct thing here. I think that should be a > 0.

Regards

Marcel

author maintainer
#2 lore raw
Quoted 9 lines · Marcel Holtmann

net/rfkill/core.c static long rfkill_fop_ioctl(struct file · line 1164

Quoted 6 lines
net/rfkill/core.c +2 -1
 	if (!data->input_handler) {
-		atomic_inc(&rfkill_input_disabled);
+		if (atomic_inc_return(&rfkill_input_disabled) == 1)
+			printk(KERN_DEBUG "rfkill: input handler disabled\n");
 		data->input_handler = true;
 	}

do you really think the == 1 is the correct thing here. I think that should be a > 0.

Why would you want to know every time somebody uses the ioctl? I think the first time should be sufficient, no? Common case will hopefully be only one program using it anyway though.

johannes

#3 lore raw

Hi Johannes,

Quoted 10 lines
Quoted 9 lines

net/rfkill/core.c static long rfkill_fop_ioctl(struct file · line 1164

Quoted 6 lines
net/rfkill/core.c +2 -1
 	if (!data->input_handler) {
-		atomic_inc(&rfkill_input_disabled);
+		if (atomic_inc_return(&rfkill_input_disabled) == 1)
+			printk(KERN_DEBUG "rfkill: input handler disabled\n");
 		data->input_handler = true;
 	}

do you really think the == 1 is the correct thing here. I think that should be a > 0.

Quoted 3 lines

Why would you want to know every time somebody uses the ioctl? I think the first time should be sufficient, no? Common case will hopefully be only one program using it anyway though.

you are right, we only care about the printk once. No need to keep printing it on every change.

Regard

Marcel