* Notification when a new device is added or removed
@ 2009-02-28 4:35 Alessio Sangalli
2009-03-01 2:39 ` Dmitry Torokhov
0 siblings, 1 reply; 6+ messages in thread
From: Alessio Sangalli @ 2009-02-28 4:35 UTC (permalink / raw)
To: linux-input
Hi, what is the easiest way to get somewhat notified when a device is
added or removed from the system? I know /proc/bus/input/devices reports
the devices list, can I make use of that? I am in an embedded
environment where I prefer not having to bringup all the hotplug + udev
infrastructure.
bye
Alessio
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Notification when a new device is added or removed
2009-02-28 4:35 Notification when a new device is added or removed Alessio Sangalli
@ 2009-03-01 2:39 ` Dmitry Torokhov
2009-03-01 2:58 ` Alessio Sangalli
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2009-03-01 2:39 UTC (permalink / raw)
To: Alessio Sangalli; +Cc: linux-input
On Fri, Feb 27, 2009 at 08:35:03PM -0800, Alessio Sangalli wrote:
> Hi, what is the easiest way to get somewhat notified when a device is
> added or removed from the system? I know /proc/bus/input/devices reports
> the devices list, can I make use of that? I am in an embedded
> environment where I prefer not having to bringup all the hotplug + udev
> infrastructure.
>
You should be able to poll (select) /proc/bus/input/devices.
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Notification when a new device is added or removed
2009-03-01 2:39 ` Dmitry Torokhov
@ 2009-03-01 2:58 ` Alessio Sangalli
2009-03-01 10:23 ` Dmitry Torokhov
0 siblings, 1 reply; 6+ messages in thread
From: Alessio Sangalli @ 2009-03-01 2:58 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input
Dmitry Torokhov wrote:
> You should be able to poll (select) /proc/bus/input/devices.
Yeah that would be great; anyway, I tried and... well nothing happens. I
am obviously missing something here:
#include <poll.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
int main()
{
int fd, c;
struct pollfd pfd;
fd=open("/proc/bus/input/devices", O_RDONLY);
if(fd==-1)
return -1;
pfd.fd=fd;
pfd.events=POLLIN;
while(1) {
c=poll(&pfd, 1, 20000);
if(c==-1)
printf("Error polling\n");
else if(c==0)
printf("Timeout\n");
else
printf("Something changed");
}
}
The result, while I detach or attach new devices is:
Timeout
Timeout
Timeout
Timeout
Timeout
bye
Alessio
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Notification when a new device is added or removed
2009-03-01 2:58 ` Alessio Sangalli
@ 2009-03-01 10:23 ` Dmitry Torokhov
2009-03-02 23:41 ` Alessio Sangalli
2009-03-09 12:06 ` Peter Korsgaard
0 siblings, 2 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2009-03-01 10:23 UTC (permalink / raw)
To: Alessio Sangalli; +Cc: linux-input
On Sat, Feb 28, 2009 at 06:58:05PM -0800, Alessio Sangalli wrote:
> Dmitry Torokhov wrote:
>
> > You should be able to poll (select) /proc/bus/input/devices.
>
> Yeah that would be great; anyway, I tried and... well nothing happens. I
> am obviously missing something here:
>
Hmm, it turns out poll is completely busted. The patch below should
help.
--
Dmitry
Input: fix polling of /proc/bus/input/devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/input.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 46e9ce1..913392f 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -744,11 +744,11 @@ static inline void input_wakeup_procfs_readers(void)
static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait)
{
- int state = input_devices_state;
-
poll_wait(file, &input_devices_poll_wait, wait);
- if (state != input_devices_state)
+ if (file->f_version != input_devices_state) {
+ file->f_version = input_devices_state;
return POLLIN | POLLRDNORM;
+ }
return 0;
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: Notification when a new device is added or removed
2009-03-01 10:23 ` Dmitry Torokhov
@ 2009-03-02 23:41 ` Alessio Sangalli
2009-03-09 12:06 ` Peter Korsgaard
1 sibling, 0 replies; 6+ messages in thread
From: Alessio Sangalli @ 2009-03-02 23:41 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input
Dmitry Torokhov wrote:
> Hmm, it turns out poll is completely busted. The patch below should
> help.
Testing shows that patch solves the problem.
bye!
as
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Notification when a new device is added or removed
2009-03-01 10:23 ` Dmitry Torokhov
2009-03-02 23:41 ` Alessio Sangalli
@ 2009-03-09 12:06 ` Peter Korsgaard
1 sibling, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2009-03-09 12:06 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Alessio Sangalli, linux-input
>>>>> "Dmitry" == Dmitry Torokhov <dmitry.torokhov@gmail.com> writes:
Hi,
>> > You should be able to poll (select) /proc/bus/input/devices.
>>
>> Yeah that would be great; anyway, I tried and... well nothing happens. I
>> am obviously missing something here:
>>
Dmitry> Hmm, it turns out poll is completely busted. The patch below should
Dmitry> help.
2.6.29 material?
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-03-09 12:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-28 4:35 Notification when a new device is added or removed Alessio Sangalli
2009-03-01 2:39 ` Dmitry Torokhov
2009-03-01 2:58 ` Alessio Sangalli
2009-03-01 10:23 ` Dmitry Torokhov
2009-03-02 23:41 ` Alessio Sangalli
2009-03-09 12:06 ` Peter Korsgaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).