* Is there any way to add an attribute under sysfs at the “platform” level?
@ 2017-06-18 14:38 Roman Storozhenko
2017-06-19 0:55 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Roman Storozhenko @ 2017-06-18 14:38 UTC (permalink / raw)
To: kernelnewbies
Hello everybody!
I am trying to modify "pcspkr" driver undere linux kernel source tree. I added a new line there:
sample_id_dir = kobject_create_and_add("devices/platform/pcspkr/sample", NULL);
It works and creates kobject without errors. I checked this in the driver code and in the dmesg output. But "sample" catalog isn't appear under "/sys/devices/platform/pcspkr/".
What is wrong with that code ?
Thanks in advance,
Roman Storozhenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Is there any way to add an attribute under sysfs at the “platform” level?
2017-06-18 14:38 Is there any way to add an attribute under sysfs at the “platform” level? Roman Storozhenko
@ 2017-06-19 0:55 ` Greg KH
2017-06-19 15:09 ` Roman Storozhenko
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2017-06-19 0:55 UTC (permalink / raw)
To: kernelnewbies
On Sun, Jun 18, 2017 at 05:38:36PM +0300, Roman Storozhenko wrote:
> Hello everybody!
>
> I am trying to modify "pcspkr" driver undere linux kernel source tree. I added a new line there:
>
> sample_id_dir = kobject_create_and_add("devices/platform/pcspkr/sample", NULL);
Ick, really? What are you trying to do with "raw" kobjects?
> It works and creates kobject without errors. I checked this in the driver code and in the dmesg output. But "sample" catalog isn't appear under "/sys/devices/platform/pcspkr/".
Are you sure? Odds are you really did create a kobject with that name,
but note, the name will have '/' characters in it :)
If you want a kobject in a specific directory, you have to give it the
parent kobject directory directly, you can not give a "path" to the
kobject name, sorry, that's not how it works.
The kobject documentation should help you out here, have you read it?
good luck!
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Is there any way to add an attribute under sysfs at the “platform” level?
2017-06-19 0:55 ` Greg KH
@ 2017-06-19 15:09 ` Roman Storozhenko
2017-06-19 15:25 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Roman Storozhenko @ 2017-06-19 15:09 UTC (permalink / raw)
To: kernelnewbies
On Mon, Jun 19, 2017 at 08:55:22AM +0800, Greg KH wrote:
> On Sun, Jun 18, 2017 at 05:38:36PM +0300, Roman Storozhenko wrote:
> > Hello everybody!
> >
> > I am trying to modify "pcspkr" driver undere linux kernel source tree. I added a new line there:
> >
> > sample_id_dir = kobject_create_and_add("devices/platform/pcspkr/sample", NULL);
>
> Ick, really? What are you trying to do with "raw" kobjects?
I am trying to add "read/write" attribute under
"devices/platform/pcspkr". Just for educational purposes. Didn't find another way to do it.
>
> > It works and creates kobject without errors. I checked this in the driver code and in the dmesg output. But "sample" catalog isn't appear under "/sys/devices/platform/pcspkr/".
>
> Are you sure? Odds are you really did create a kobject with that name,
> but note, the name will have '/' characters in it :)
>
> If you want a kobject in a specific directory, you have to give it the
> parent kobject directory directly, you can not give a "path" to the
> kobject name, sorry, that's not how it works.
>
> The kobject documentation should help you out here, have you read it?
>
> good luck!
I have read documentation about sysfs and kobject. Now I am going to
re-read it again.
Thanks, Greg.
>
> greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Is there any way to add an attribute under sysfs at the “platform” level?
2017-06-19 15:09 ` Roman Storozhenko
@ 2017-06-19 15:25 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2017-06-19 15:25 UTC (permalink / raw)
To: kernelnewbies
On Mon, Jun 19, 2017 at 06:09:28PM +0300, Roman Storozhenko wrote:
> On Mon, Jun 19, 2017 at 08:55:22AM +0800, Greg KH wrote:
> > On Sun, Jun 18, 2017 at 05:38:36PM +0300, Roman Storozhenko wrote:
> > > Hello everybody!
> > >
> > > I am trying to modify "pcspkr" driver undere linux kernel source tree. I added a new line there:
> > >
> > > sample_id_dir = kobject_create_and_add("devices/platform/pcspkr/sample", NULL);
> >
> > Ick, really? What are you trying to do with "raw" kobjects?
>
> I am trying to add "read/write" attribute under
> "devices/platform/pcspkr". Just for educational purposes. Didn't find another way to do it.
Using a kobject is not how to do that at all, attributes need to be
added to the structure that owns the directory. kobjects are a
directory themselves.
good luck!
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-19 15:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-18 14:38 Is there any way to add an attribute under sysfs at the “platform” level? Roman Storozhenko
2017-06-19 0:55 ` Greg KH
2017-06-19 15:09 ` Roman Storozhenko
2017-06-19 15:25 ` Greg KH
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).