* [PATCH] rfkill: print events when input handler is disabled/enabled
@ 2009-06-07 10:26 Johannes Berg
2009-06-07 15:25 ` Marcel Holtmann
0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2009-06-07 10:26 UTC (permalink / raw)
To: John Linville; +Cc: Marcel Holtmann, linux-wireless
It is useful for debugging when we know if something disabled
the in-kernel rfkill input handler.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
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;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rfkill: print events when input handler is disabled/enabled
2009-06-07 10:26 [PATCH] rfkill: print events when input handler is disabled/enabled Johannes Berg
@ 2009-06-07 15:25 ` Marcel Holtmann
2009-06-07 17:18 ` Johannes Berg
0 siblings, 1 reply; 4+ messages in thread
From: Marcel Holtmann @ 2009-06-07 15:25 UTC (permalink / raw)
To: Johannes Berg; +Cc: John Linville, linux-wireless
Hi Johannes,
> It is useful for debugging when we know if something disabled
> the in-kernel rfkill input handler.
>
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> ---
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rfkill: print events when input handler is disabled/enabled
2009-06-07 15:25 ` Marcel Holtmann
@ 2009-06-07 17:18 ` Johannes Berg
2009-06-08 0:18 ` Marcel Holtmann
0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2009-06-07 17:18 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: John Linville, linux-wireless
[-- Attachment #1: Type: text/plain, Size: 605 bytes --]
On Sun, 2009-06-07 at 17:25 +0200, Marcel Holtmann wrote:
> > 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
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rfkill: print events when input handler is disabled/enabled
2009-06-07 17:18 ` Johannes Berg
@ 2009-06-08 0:18 ` Marcel Holtmann
0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2009-06-08 0:18 UTC (permalink / raw)
To: Johannes Berg; +Cc: John Linville, linux-wireless
Hi Johannes,
> > > 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@holtmann.org>
Regard
Marcel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-06-08 0:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-07 10:26 [PATCH] rfkill: print events when input handler is disabled/enabled Johannes Berg
2009-06-07 15:25 ` Marcel Holtmann
2009-06-07 17:18 ` Johannes Berg
2009-06-08 0:18 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox