Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 36353
b: refs/heads/master
c: 06afff0
h: refs/heads/master
i:
  36351: eff43d1
v: v3
  • Loading branch information
Sam Bishop authored and Greg Kroah-Hartman committed Sep 27, 2006
1 parent b428a73 commit eeddb22
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 341323269258ab8484077a9c70db804fbae6ae93
refs/heads/master: 06afff00bcab0e384afbef70194fd3469532abdf
25 changes: 18 additions & 7 deletions trunk/Documentation/DocBook/usb.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,25 @@
file in your Linux kernel sources.
</para>

<para>Otherwise the main use for this file from programs
is to poll() it to get notifications of usb devices
as they're plugged or unplugged.
To see what changed, you'd need to read the file and
compare "before" and "after" contents, scan the filesystem,
or see its hotplug event.
<para>This file, in combination with the poll() system call, can
also be used to detect when devices are added or removed:
<programlisting>int fd;
struct pollfd pfd;

fd = open("/proc/bus/usb/devices", O_RDONLY);
pfd = { fd, POLLIN, 0 };
for (;;) {
/* The first time through, this call will return immediately. */
poll(&amp;pfd, 1, -1);

/* To see what's changed, compare the file's previous and current
contents or scan the filesystem. (Scanning is more precise.) */
}</programlisting>
Note that this behavior is intended to be used for informational
and debug purposes. It would be more appropriate to use programs
such as udev or HAL to initialize a device or start a user-mode
helper program, for instance.
</para>

</sect1>

<sect1>
Expand Down

0 comments on commit eeddb22

Please sign in to comment.