* [patch] add private data to notifier_block
@ 2006-03-21 19:42 Kristen Accardi
2006-03-22 18:00 ` Zach Brown
2006-03-22 19:04 ` Alan Stern
0 siblings, 2 replies; 6+ messages in thread
From: Kristen Accardi @ 2006-03-21 19:42 UTC (permalink / raw)
To: linux-kernel; +Cc: stern
While most current uses of notifier_block use a global struct, I would
like to be able to use it on a per device basis for drivers which have
multiple device instances. I would also like to be able to have a
private data struct associated with the notifier block so that per
device data can be easily accessed. This patch will modify the
notifier_block struct to add a void *, and will require no modifications
to any other users of the notifier_block.
Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
---
include/linux/notifier.h | 1 +
1 files changed, 1 insertion(+)
--- 2.6-git-kca.orig/include/linux/notifier.h
+++ 2.6-git-kca/include/linux/notifier.h
@@ -15,6 +15,7 @@ struct notifier_block
{
int (*notifier_call)(struct notifier_block *self, unsigned long, void *);
struct notifier_block *next;
+ void *data;
int priority;
};
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] add private data to notifier_block
2006-03-21 19:42 [patch] add private data to notifier_block Kristen Accardi
@ 2006-03-22 18:00 ` Zach Brown
2006-03-22 19:04 ` Alan Stern
1 sibling, 0 replies; 6+ messages in thread
From: Zach Brown @ 2006-03-22 18:00 UTC (permalink / raw)
To: Kristen Accardi; +Cc: linux-kernel, stern
Kristen Accardi wrote:
> device data can be easily accessed. This patch will modify the
> notifier_block struct to add a void *, and will require no modifications
> to any other users of the notifier_block.
> {
> int (*notifier_call)(struct notifier_block *self, unsigned long, void *);
> struct notifier_block *next;
> + void *data;
> int priority;
> };
Well, it might introduce warnings in users who weren't using named
initializers -- their bare priority initialization might now shift to
trying to initialize a pointer.
Though, that's probably a good thing as it gives an opportunity to
convert them. We also don't want to create a padded structure by
putting the void * after the int.
- z
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] add private data to notifier_block
2006-03-21 19:42 [patch] add private data to notifier_block Kristen Accardi
2006-03-22 18:00 ` Zach Brown
@ 2006-03-22 19:04 ` Alan Stern
2006-03-22 21:00 ` Kristen Accardi
1 sibling, 1 reply; 6+ messages in thread
From: Alan Stern @ 2006-03-22 19:04 UTC (permalink / raw)
To: Kristen Accardi; +Cc: linux-kernel
On Tue, 21 Mar 2006, Kristen Accardi wrote:
> While most current uses of notifier_block use a global struct, I would
> like to be able to use it on a per device basis for drivers which have
> multiple device instances. I would also like to be able to have a
> private data struct associated with the notifier block so that per
> device data can be easily accessed. This patch will modify the
> notifier_block struct to add a void *, and will require no modifications
> to any other users of the notifier_block.
>
> Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
>
> ---
> include/linux/notifier.h | 1 +
> 1 files changed, 1 insertion(+)
>
> --- 2.6-git-kca.orig/include/linux/notifier.h
> +++ 2.6-git-kca/include/linux/notifier.h
> @@ -15,6 +15,7 @@ struct notifier_block
> {
> int (*notifier_call)(struct notifier_block *self, unsigned long, void *);
> struct notifier_block *next;
> + void *data;
> int priority;
> };
I still think this isn't really needed. The same effect can be
accomplished by embedding a notifier_block struct within a larger
structure that also contains the data pointer.
On the other hand this isn't a terribly big change, so I don't actually
object to it.
Alan Stern
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] add private data to notifier_block
2006-03-22 19:04 ` Alan Stern
@ 2006-03-22 21:00 ` Kristen Accardi
2006-03-23 10:06 ` Jes Sorensen
0 siblings, 1 reply; 6+ messages in thread
From: Kristen Accardi @ 2006-03-22 21:00 UTC (permalink / raw)
To: Alan Stern; +Cc: linux-kernel
On Wed, 2006-03-22 at 14:04 -0500, Alan Stern wrote:
> On Tue, 21 Mar 2006, Kristen Accardi wrote:
>
> > While most current uses of notifier_block use a global struct, I would
> > like to be able to use it on a per device basis for drivers which have
> > multiple device instances. I would also like to be able to have a
> > private data struct associated with the notifier block so that per
> > device data can be easily accessed. This patch will modify the
> > notifier_block struct to add a void *, and will require no modifications
> > to any other users of the notifier_block.
> >
> > Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
> >
> > ---
> > include/linux/notifier.h | 1 +
> > 1 files changed, 1 insertion(+)
> >
> > --- 2.6-git-kca.orig/include/linux/notifier.h
> > +++ 2.6-git-kca/include/linux/notifier.h
> > @@ -15,6 +15,7 @@ struct notifier_block
> > {
> > int (*notifier_call)(struct notifier_block *self, unsigned long, void *);
> > struct notifier_block *next;
> > + void *data;
> > int priority;
> > };
>
> I still think this isn't really needed. The same effect can be
> accomplished by embedding a notifier_block struct within a larger
> structure that also contains the data pointer.
>
I thought of this, but felt it would make for less easy to read code.
But, that's just my personal style.
> On the other hand this isn't a terribly big change, so I don't actually
> object to it.
>
Thanks.
> Alan Stern
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] add private data to notifier_block
2006-03-22 21:00 ` Kristen Accardi
@ 2006-03-23 10:06 ` Jes Sorensen
2006-03-23 18:01 ` Kristen Accardi
0 siblings, 1 reply; 6+ messages in thread
From: Jes Sorensen @ 2006-03-23 10:06 UTC (permalink / raw)
To: Kristen Accardi; +Cc: Alan Stern, linux-kernel
>>>>> "Kristen" == Kristen Accardi <kristen.c.accardi@intel.com> writes:
Kristen> On Wed, 2006-03-22 at 14:04 -0500, Alan Stern wrote:
>> I still think this isn't really needed. The same effect can be
>> accomplished by embedding a notifier_block struct within a larger
>> structure that also contains the data pointer.
Kristen> I thought of this, but felt it would make for less easy to
Kristen> read code. But, that's just my personal style.
I'd have to vote for Alan's side here. Thats why we have the
containerof() stuff. It also means you can embed more than just a
pointer with the notifier block and it will generate more efficient
code when doing so.
Cheers,
Jes
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] add private data to notifier_block
2006-03-23 10:06 ` Jes Sorensen
@ 2006-03-23 18:01 ` Kristen Accardi
0 siblings, 0 replies; 6+ messages in thread
From: Kristen Accardi @ 2006-03-23 18:01 UTC (permalink / raw)
To: Jes Sorensen; +Cc: Alan Stern, linux-kernel
On Thu, 2006-03-23 at 05:06 -0500, Jes Sorensen wrote:
> >>>>> "Kristen" == Kristen Accardi <kristen.c.accardi@intel.com> writes:
>
> Kristen> On Wed, 2006-03-22 at 14:04 -0500, Alan Stern wrote:
> >> I still think this isn't really needed. The same effect can be
> >> accomplished by embedding a notifier_block struct within a larger
> >> structure that also contains the data pointer.
>
> Kristen> I thought of this, but felt it would make for less easy to
> Kristen> read code. But, that's just my personal style.
>
> I'd have to vote for Alan's side here. Thats why we have the
> containerof() stuff. It also means you can embed more than just a
> pointer with the notifier block and it will generate more efficient
> code when doing so.
>
> Cheers,
> Jes
Ok, I bow to peer pressure and will do this your way. :) You can ignore
this patch.
Thanks,
Kristen
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-03-23 17:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-21 19:42 [patch] add private data to notifier_block Kristen Accardi
2006-03-22 18:00 ` Zach Brown
2006-03-22 19:04 ` Alan Stern
2006-03-22 21:00 ` Kristen Accardi
2006-03-23 10:06 ` Jes Sorensen
2006-03-23 18:01 ` Kristen Accardi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox