I found some occurences of sysfs_notify in different driver (phidgetkit driver for example). As I sayd in my previous post now it's working. I can start poll on my attribute (sysfs file) and when I execute sysfs_notify in my driver the event is handled by poll. But I have still a little probleme, the poll call return POLLPRI and POLLERR. Only POLLPRI is normal I don't understand why we have both ??? Any idea ? --- En date de : Mer 7.1.09, Belisko Marek <marek.belisko@xxxxxxxxx> a écrit : > De: Belisko Marek <marek.belisko@xxxxxxxxx> > Objet: Re: sysfs_notify & poll > À: kpa_info@xxxxxxxx > Date: Mercredi 7 Janvier 2009, 15h46 > Hi, > > On Wed, Jan 7, 2009 at 3:25 PM, PAtrick Gerber > <kpa_info@xxxxxxxx> wrote: > > I am not sure but I had understanded that we need to > implement the pool syscall, as described in ldd3 books, only > for chardevices. For attributes in sysfs, the poll syscall > is managed by the kernel/sysfs and we can simply use > sysfs_notify on the kernel side. An event queue is managed > for each attribute for this purprose. > I think sysfs_notify couldn't be called from > kobject-example. If you > search through whole kernel tree > no occurences only in sysfs/file.c is found. > > You can read this article (http://lwn.net/Articles/174660/) > and try > what's described. > If poll returns close file and open again. New value should > be obtained. > > > > But as I say before I am not clear with this. You can > read this : > http://lists.linuxcoding.com/kernel/2006-q1/msg28166.html or > this from the kernel source: > > > > /* Sysfs attribute files are pollable. The idea is > that you read > > * the content and then you use 'poll' or > 'select' to wait for > > * the content to change. When the content changes > (assuming the > > * manager for the kobject supports notification), > poll will > > * return POLLERR|POLLPRI, and select will return the > fd whether > > * it is waiting for read, write, or exceptions. > > * Once poll/select indicates that the value has > changed, you > > * need to close and re-open the file, as simply > seeking and reading > > * again will not get new data, or reset the state of > 'poll'. > > * Reminder: this only works for attributes which > actively support > > * it, and it is not possible to test an attribute > from userspace > > * to see if it supports poll (Nether 'poll' > or 'select' return > > * an appropriate error code). When in doubt, set a > suitable timeout value. > > */ > > > > > > --- En date de : Mer 7.1.09, Belisko Marek > <marek.belisko@xxxxxxxxx> a écrit : > > > >> De: Belisko Marek <marek.belisko@xxxxxxxxx> > >> Objet: Re: sysfs_notify & poll > >> À: "PAtrick Gerber" > <kpa_info@xxxxxxxx> > >> Cc: kernelnewbies@xxxxxxxxxxxx > >> Date: Mercredi 7 Janvier 2009, 15h09 > >> Hi, > >> > >> On Wed, Jan 7, 2009 at 2:21 PM, PAtrick Gerber > >> <kpa_info@xxxxxxxx> wrote: > >> > Thanks for the information. > >> > > >> > I have tested with the example from > >> http://linux.die.net/man/3/poll slightly modified > (see the > >> attached file). > >> > If I test pool on the > >> "/sys/module/systest/sections/.data" > file it seems > >> to work fine. But if I try the same test > application with my > >> attribute (/sys/kernel/kobject_example/bar) > created with the > >> example from linux sources > >> (samples/kobject/kobject_example.c) the result is > an event > >> POLLERR. > >> > >> > > >> > Do you have any idea why ? Need I to add > special code > >> for support poll syscall in my driver ? > >> Of course you should implement poll syscall in > kernel > >> driver. But for > >> kobject-example it could be a problem > >> because you don't have a file operations in > this > >> example. But thats > >> only my feeling ;) > >> Example for poll : (ldd3 > >> http://lwn.net/images/pdf/LDD3/ch06.pdf ) > >> > > >> > Thanks in advance > >> > > >> > --- En date de : Mer 7.1.09, Belisko Marek > >> <marek.belisko@xxxxxxxxx> a écrit : > >> > > >> >> De: Belisko Marek > <marek.belisko@xxxxxxxxx> > >> >> Objet: Re: sysfs_notify & poll > >> >> À: "PAtrick Gerber" > >> <kpa_info@xxxxxxxx> > >> >> Date: Mercredi 7 Janvier 2009, 13h59 > >> >> Hi, > >> >> > >> >> On Wed, Jan 7, 2009 at 1:54 PM, PAtrick > Gerber > >> >> <kpa_info@xxxxxxxx> wrote: > >> >> > Ok thanks. Usefull example. But I > have > >> another > >> >> question: > >> >> > > >> >> > Need I to use poll or epoll ? I dont > really > >> understand > >> >> the difference. > >> >> epoll is a variant of poll that can be > used either > >> as Edge > >> >> or Level > >> >> Triggered interface and scales well to > large > >> numbers of > >> >> watched fds. > >> >> For beginnig you can use normal poll > syscall. > >> >> > >> >> > > >> >> > Thanks in advance for any help ! > >> >> > > >> >> > On Wed, Jan 7, 2009 at 9:40 AM, > PAtrick > >> Gerber > >> >> <kpa_info@xxxxxxxx> wrote: > >> >> >> Hello, > >> >> >> > >> >> >> I would like to try to use > sysfs_notify() > >> / poll() > >> >> mechanism from my > >> >> > driver > >> >> >> to notify some events to my > application. > >> I'm > >> >> looking for a tiny > >> >> > example > >> >> >> showing the use of this > mechanism. > >> >> >> > >> >> >> The driver side with > sysfs_notify seems > >> quite > >> >> simple but I have absolutely > >> >> >> no idea about the application > side. > >> >> > > >> >> > Fo poll method you canfind good > description > >> and also > >> >> example at: > >> >> > http://linux.die.net/man/3/poll > >> >> > > >> >> >> > >> >> >> Thanks in advance > >> >> >> > >> >> >> Patrick > >> >> >> > >> >> > > >> >> > thanks, > >> >> > > >> >> > Marek > >> >> > > >> >> > > >> >> > > >> >> > > >> >> > > >> >> > > >> >> > > >> >> > >> >> thanks, > >> >> > >> >> Marek > >> >> > >> >> -- > >> >> as simple as primitive as possible > >> >> > ---------------------------------------------- > >> >> Marek Beliško - open-nandra > >> >> Ruská Nová Ves 219 > >> >> 08005 Prešov > >> >> Slovakia > >> >> http://open-nandra.com > >> > > >> > > >> > > >> > >> thanks, > >> > >> Marek > >> > >> -- > >> as simple as primitive as possible > >> ---------------------------------------------- > >> Marek Beliško - open-nandra > >> Ruská Nová Ves 219 > >> 08005 Prešov > >> Slovakia > >> http://open-nandra.com > > > > > > > > > > thanks, > > Marek > > > -- > as simple as primitive as possible > ---------------------------------------------- > Marek Beliško - open-nandra > Ruská Nová Ves 219 > 08005 Prešov > Slovakia > http://open-nandra.com -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ