[lkml]   [2010]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCHv4 1/4] procfs: Introduce socinfo under /proc
On Mon, May 10, 2010 at 05:22:48PM +0300, Eduardo Valentin wrote:
> On Mon, May 10, 2010 at 01:13:00PM +0200, ext Paul Mundt wrote:
> > You'll still need the show function, but all of the rest of this is just
> > duplicating what single_open() already does. If the socinfo string is
> > static you may also want to rework this a bit so you can just stash the
> > string in the proc_dir_entry private data. Combine this with something
> > like kstrdup() and you'll save yourself a bit of stack while you're at
> > it.
> While still here, about cleaning this, so, let me see if I got your point.
> Basically, the file under fs/proc/socinfo.c whould do the thing with single_open &
> single_release, as you stated. But then there is the .show and its data.
> One idea would then be to have a function:
> int register_socinfo_show(int (*show)(struct seq_file *, void *), void *data);
> Which would be exported to other parts of the kernel (something placed under
> include/linux/socinfo.h for instance). Then the soc core code
> (like arch/arm/mach-omap[1,2]) would then register its local show function and pass its data.
> This way I think we can avoid the exports inside .c files (as in this patch)
> and also pass the static char * needed during the show.
> What do you think?
Yes, you'll need something like that. kstrdup() also does an allocation,
but you're only going to be registering once and are unlikely to ever
unregister (particular since you have this configured as a bool) so that
doesn't really matter. On the other hand if the string itself is static
you can just pass that in with a static initializer, or have some sort of
opaque socinfo data structure that contains the strings you care about.
You'll always be able to get back at the pointer through the
proc_dir_entry private data.

 \ /
  Last update: 2010-05-12 10:15    [W:0.056 / U:1.144 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site