public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Patrick Mochel <mochel@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: driverfs API Updates
Date: Fri, 09 Aug 2002 11:20:07 +1000	[thread overview]
Message-ID: <20020809015454.D0A274521@lists.samba.org> (raw)
In-Reply-To: Your message of "Thu, 08 Aug 2002 11:21:35 MST." <Pine.LNX.4.44.0208080914060.1241-100000@cherise.pdx.osdl.net>

In message <Pine.LNX.4.44.0208080914060.1241-100000@cherise.pdx.osdl.net> you w
rite:
> That said, this is what I want to do:
> 
> Define helpers for parsing and formatting types; e.g. show_int() and
> store_int(). Objects' show and store methods can use those for the exposed
> attribute.
> 
> Support single static attributes by having something like this:
> 
> struct int_attribute {
> 	struct attribute	attr;
> 	show_int_t		show;
> 	store_int_t		store;
> 	int			* data;
> };
> 
> INT_ATTR(frobbable,0644);

Ok, that makes sense, except I prefer to build the interface in
layers, something like:

	ATTRIBUTE(frobbable,int,0644)
	=> ATTRIBUTE_CALL(frobbable,0644,show_int,store_int)

This still allows you to define your own types...

> What do you think? It definitely looks a lot like your PARAM stuff, and I 
> need to look again at what you wrote to see if I can tie in any more of 
> it. 

I think you've got all the good bits now 8)

> Of course, they don't have to be exposed to userspace in order to access
> them. This is a little further down the road, but by placing them (or
> pointers to them) in a special section, we could access attributes at boot
> time or module load time, like module parameters. 

This was my idea with "000" perm attributes: they are explicitly only
settable at module/kernel init (eg. they and their set/show functions
can be declared __init).

> I'm thinking that we could macro-ize locking for single static variables 
> as well. We could have something like:
> 
> rwlock_t mylock;
> 
> INT_ATTR_LOCKED(frobbable,0644,mylock);
> 
> which could then generate 
> 
> int get_frobbable(void);
> 
> void set_frobbable(int val);

Hmmm, how about:

	ATTRIBUTE_LOCKED(frobbable,int,0644,mylock)
	=> ATTRIBUTE_CALL(frobbable,0644,mylock,show_int_lock,store_int_lock)

With PARAM()/sysfs, I hit the wall when I tried to handle spinlocks,
rwlocks, semaphores, rwsemaphores, and backed off until I knew which
ones were actually useful 8)

This is the nice thing about having people actually using the code is
you can tell when you've hit the 90% mark (the weird cases can always
use their own callbacks).  I think trial-and-error is the best way to
introduce these kind of convenience functions.

Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

      reply	other threads:[~2002-08-09  1:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-05 19:17 driverfs API Updates Patrick Mochel
2002-08-05 19:47 ` Kai Germaschewski
2002-08-05 20:17   ` Patrick Mochel
2002-08-05 23:38 ` Patrick Mansfield
2002-08-06 16:48   ` Patrick Mochel
2002-08-06 17:44 ` driverfs and ieee1394 Kristian Hogsberg
2002-08-19 19:28   ` Patrick Mochel
2002-08-08  3:44 ` driverfs API Updates Rusty Russell
2002-08-08 18:21   ` Patrick Mochel
2002-08-09  1:20     ` Rusty Russell [this message]

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=20020809015454.D0A274521@lists.samba.org \
    --to=rusty@rustcorp.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@osdl.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