From: Rolf Eike Beer <eike-kernel@sf-tec.de>
To: linux-kernel@vger.kernel.org
Subject: Exporting array data in sysfs
Date: Mon, 18 Sep 2006 13:59:17 +0200 [thread overview]
Message-ID: <200609181359.31489.eike-kernel@sf-tec.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 1494 bytes --]
Hi,
I would like to put the contents of an array in sysfs files. I found no simple
way to do this, so here are my thoughts in hope someone can hand me a light.
-simple array (array of simple type like int, char* and so on)
needs:
.name, .read, .write, .num, .writenum
When exported a directory "name" is created, containing num()+1 entries. There
is one entry for each array entry plus the special entry "n". "cat n" gives
you the result of num, writing to num calls writenum to change the number of
array members. If writenum is NULL the array has fixed size.
read is read(struct whatever *, int, char *). The second argument gives the
array number, the last one the buffer to print to (as usual). write looks
similar, just as in existing sysfs interface (e.g. device_create_file()).
-complex array (array of struct)
This is even more tricky. You can't do this now if you don't know the number
of entries. If you do you can create a struct device_attribute (or similar)
for every entry and have different access functions that "know" their index.
This is horribly inefficient and ugly.
Sort of access struct could be:
.name is fmt-string containing %i (or %lli or something like this)
.members is an array of structs looking similar to what I described above for
the simple array. Now the index gives the index of the struct.
.num, .writenum as above
Nesting them is probably not worth it at all as it would look horrible. :)
Thoughts?
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next reply other threads:[~2006-09-18 11:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-18 11:59 Rolf Eike Beer [this message]
2006-09-18 12:44 ` Exporting array data in sysfs Greg KH
2006-09-18 13:41 ` Rolf Eike Beer
2006-09-18 13:56 ` Dmitry Torokhov
2006-09-18 14:22 ` Rolf Eike Beer
2006-09-18 14:59 ` Dmitry Torokhov
2006-09-18 15:18 ` Rolf Eike Beer
2006-09-18 15:41 ` Dmitry Torokhov
2006-09-18 15:57 ` Rolf Eike Beer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200609181359.31489.eike-kernel@sf-tec.de \
--to=eike-kernel@sf-tec.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox