* Problems with adding a sysfs file
@ 2017-04-17 8:17 Abhishek Bhardwaj
2017-04-17 20:43 ` valdis.kletnieks at vt.edu
0 siblings, 1 reply; 4+ messages in thread
From: Abhishek Bhardwaj @ 2017-04-17 8:17 UTC (permalink / raw)
To: kernelnewbies
I followed this link to add a sysfs file
http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/
.
I set the driver.groups field and declared the attribute and attribute
groups required by the sysfs file. When I boot my kernel I see the
file but my store and show handlers don't get called when I try to cat
or echo to the file. Is there any step I'm missing ?. I also see that
a lot of drivers still use sysfs_create_file which is racy according
to the link I posted.
-
AB
^ permalink raw reply [flat|nested] 4+ messages in thread
* Problems with adding a sysfs file
2017-04-17 8:17 Problems with adding a sysfs file Abhishek Bhardwaj
@ 2017-04-17 20:43 ` valdis.kletnieks at vt.edu
2017-04-17 21:04 ` Abhishek Bhardwaj
0 siblings, 1 reply; 4+ messages in thread
From: valdis.kletnieks at vt.edu @ 2017-04-17 20:43 UTC (permalink / raw)
To: kernelnewbies
On Mon, 17 Apr 2017 01:17:08 -0700, Abhishek Bhardwaj said:
> I followed this link to add a sysfs file
> http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/
> .
>
> I set the driver.groups field and declared the attribute and attribute
> groups required by the sysfs file. When I boot my kernel I see the
> file but my store and show handlers don't get called when I try to cat
> or echo to the file. Is there any step I'm missing ?.
The traditional way to start debugging this is to add a line at the beginning
of your show and store routines:
printk(KERN_DEBUG "Now in our special sysfs show routine\n");
and see if it shows up in your dmesg or not. If not, your routine
is probably not being called. If it is, the problem is in the routine.
(You'd be surprised how often people say their routine isn't getting called,
when it in fact is, or vice versa..)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 484 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170417/a7185733/attachment.bin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Problems with adding a sysfs file
2017-04-17 20:43 ` valdis.kletnieks at vt.edu
@ 2017-04-17 21:04 ` Abhishek Bhardwaj
2017-04-18 0:05 ` Tobin C. Harding
0 siblings, 1 reply; 4+ messages in thread
From: Abhishek Bhardwaj @ 2017-04-17 21:04 UTC (permalink / raw)
To: kernelnewbies
I used a pr_debug and printk KERN_INFO ,before my original email , to
verify they weren't being called.
On Apr 17, 2017 1:43 PM, <valdis.kletnieks@vt.edu> wrote:
> On Mon, 17 Apr 2017 01:17:08 -0700, Abhishek Bhardwaj said:
> > I followed this link to add a sysfs file
> > http://kroah.com/log/blog/2013/06/26/how-to-create-a-
> sysfs-file-correctly/
> > .
> >
> > I set the driver.groups field and declared the attribute and attribute
> > groups required by the sysfs file. When I boot my kernel I see the
> > file but my store and show handlers don't get called when I try to cat
> > or echo to the file. Is there any step I'm missing ?.
>
> The traditional way to start debugging this is to add a line at the
> beginning
> of your show and store routines:
>
> printk(KERN_DEBUG "Now in our special sysfs show routine\n");
>
> and see if it shows up in your dmesg or not. If not, your routine
> is probably not being called. If it is, the problem is in the routine.
>
> (You'd be surprised how often people say their routine isn't getting
> called,
> when it in fact is, or vice versa..)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170417/0c1d3184/attachment.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Problems with adding a sysfs file
2017-04-17 21:04 ` Abhishek Bhardwaj
@ 2017-04-18 0:05 ` Tobin C. Harding
0 siblings, 0 replies; 4+ messages in thread
From: Tobin C. Harding @ 2017-04-18 0:05 UTC (permalink / raw)
To: kernelnewbies
On Mon, Apr 17, 2017 at 02:04:48PM -0700, Abhishek Bhardwaj wrote:
> I used a pr_debug and printk KERN_INFO ,before my original email , to
> verify they weren't being called.
You will have more success on kernel mailing lists if you do not top
post as you have done :)
> On Apr 17, 2017 1:43 PM, <valdis.kletnieks@vt.edu> wrote:
>
> > On Mon, 17 Apr 2017 01:17:08 -0700, Abhishek Bhardwaj said:
> > > I followed this link to add a sysfs file
> > > http://kroah.com/log/blog/2013/06/26/how-to-create-a-
> > sysfs-file-correctly/
> > > .
> > >
> > > I set the driver.groups field and declared the attribute and attribute
> > > groups required by the sysfs file. When I boot my kernel I see the
> > > file but my store and show handlers don't get called when I try to cat
> > > or echo to the file. Is there any step I'm missing ?.
> >
> > The traditional way to start debugging this is to add a line at the
> > beginning
> > of your show and store routines:
> >
> > printk(KERN_DEBUG "Now in our special sysfs show routine\n");
You could have put your response here, that way readers would have a
reference to you comment.
> > and see if it shows up in your dmesg or not. If not, your routine
> > is probably not being called. If it is, the problem is in the routine.
> >
> > (You'd be surprised how often people say their routine isn't getting
> > called,
> > when it in fact is, or vice versa..)
> >
Good luck,
Tobin.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-18 0:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-17 8:17 Problems with adding a sysfs file Abhishek Bhardwaj
2017-04-17 20:43 ` valdis.kletnieks at vt.edu
2017-04-17 21:04 ` Abhishek Bhardwaj
2017-04-18 0:05 ` Tobin C. Harding
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).