Discussion:
[PATCH] rfkill: print events when input handler is disabled/enabled
(too old to reply)
Johannes Berg
2009-06-07 10:26:52 UTC
Permalink
It is useful for debugging when we know if something disabled
the in-kernel rfkill input handler.

Signed-off-by: Johannes Berg <johannes-***@public.gmane.org>
---
net/rfkill/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

--- wireless-testing.orig/net/rfkill/core.c 2009-06-07 11:46:05.000000000 +0200
+++ wireless-testing/net/rfkill/core.c 2009-06-07 11:53:40.000000000 +0200
@@ -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;
}



--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Marcel Holtmann
2009-06-07 15:25:31 UTC
Permalink
Hi Johannes,
Post by Johannes Berg
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(-)
--- wireless-testing.orig/net/rfkill/core.c 2009-06-07 11:46:05.000000000 +0200
+++ wireless-testing/net/rfkill/core.c 2009-06-07 11:53:40.000000000 +0200
@@ -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;
}
do you really think the == 1 is the correct thing here. I think that
should be a > 0.

Regards

Marcel


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Johannes Berg
2009-06-07 17:18:34 UTC
Permalink
Post by Marcel Holtmann
Post by Johannes Berg
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
Marcel Holtmann
2009-06-08 00:18:24 UTC
Permalink
Hi Johannes,
Post by Johannes Berg
Post by Marcel Holtmann
Post by Johannes Berg
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.
you are right, we only care about the printk once. No need to keep
printing it on every change.

Acked-by: Marcel Holtmann <marcel-kz+***@public.gmane.org>

Regard

Marcel


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Continue reading on narkive:
Loading...