* [PATCH] [POWERPC] Add machine initcall macros
@ 2007-12-01 0:24 Grant Likely
2007-12-01 5:10 ` Benjamin Herrenschmidt
2007-12-01 7:11 ` Michael Ellerman
0 siblings, 2 replies; 4+ messages in thread
From: Grant Likely @ 2007-12-01 0:24 UTC (permalink / raw)
To: linuxppc-dev, vitb, galak, olof, jwboyer, benh
From: Grant Likely <grant.likely@secretlab.ca>
The machine initcall macros allow initcalls to be registered which
test machine_is() before executing the initcall.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
Ben, is this the sort of thing you're considering?
g.
include/asm-powerpc/machdep.h | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h
index 6968f43..f24af06 100644
--- a/include/asm-powerpc/machdep.h
+++ b/include/asm-powerpc/machdep.h
@@ -326,5 +326,24 @@ static inline void log_error(char *buf, unsigned int err_type, int fatal)
ppc_md.log_error(buf, err_type, fatal);
}
+#define __define_machine_initcall(mach,level,fn,id) \
+ static int __init __machine_initcall_##mach##_##fn(void) { \
+ if (machine_is(mach)) return fn(); \
+ return 0; \
+ } \
+ __define_initcall(level,__machine_initcall_##mach##_##fn,id);
+
+#define machine_arch_initcall(mach,fn) __define_machine_initcall(mach,"3",fn,3)
+#define machine_arch_initcall_sync(mach,fn) __define_machine_initcall(mach,"3s",fn,3s)
+#define machine_subsys_initcall(mach,fn) __define_machine_initcall(mach,"4",fn,4)
+#define machine_subsys_initcall_sync(mach,fn) __define_machine_initcall(mach,"4s",fn,4s)
+#define machine_fs_initcall(mach,fn) __define_machine_initcall(mach,"5",fn,5)
+#define machine_fs_initcall_sync(mach,fn) __define_machine_initcall(mach,"5s",fn,5s)
+#define machine_rootfs_initcall(mach,fn) __define_machine_initcall(mach,"rootfs",fn,rootfs)
+#define machine_device_initcall(mach,fn) __define_machine_initcall(mach,"6",fn,6)
+#define machine_device_initcall_sync(mach,fn) __define_machine_initcall(mach,"6s",fn,6s)
+#define machine_late_initcall(mach,fn) __define_machine_initcall(mach,"7",fn,7)
+#define machine_late_initcall_sync(mach,fn) __define_machine_initcall(mach,"7s",fn,7s)
+
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_MACHDEP_H */
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] [POWERPC] Add machine initcall macros
2007-12-01 0:24 [PATCH] [POWERPC] Add machine initcall macros Grant Likely
@ 2007-12-01 5:10 ` Benjamin Herrenschmidt
2007-12-01 7:11 ` Michael Ellerman
1 sibling, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2007-12-01 5:10 UTC (permalink / raw)
To: Grant Likely; +Cc: olof, linuxppc-dev
On Fri, 2007-11-30 at 17:24 -0700, Grant Likely wrote:
> From: Grant Likely <grant.likely@secretlab.ca>
>
> The machine initcall macros allow initcalls to be registered which
> test machine_is() before executing the initcall.
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
>
> Ben, is this the sort of thing you're considering?
Exactly. You can add core and postcore while at it, I had use for them
in the past :-)
I'll look into turning that into magic ELF sections later, but in the
meantime, that gives us a nice solid API for use by BSPs.
Thanks !
Ben.
> g.
>
> include/asm-powerpc/machdep.h | 19 +++++++++++++++++++
> 1 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h
> index 6968f43..f24af06 100644
> --- a/include/asm-powerpc/machdep.h
> +++ b/include/asm-powerpc/machdep.h
> @@ -326,5 +326,24 @@ static inline void log_error(char *buf, unsigned int err_type, int fatal)
> ppc_md.log_error(buf, err_type, fatal);
> }
>
> +#define __define_machine_initcall(mach,level,fn,id) \
> + static int __init __machine_initcall_##mach##_##fn(void) { \
> + if (machine_is(mach)) return fn(); \
> + return 0; \
> + } \
> + __define_initcall(level,__machine_initcall_##mach##_##fn,id);
> +
> +#define machine_arch_initcall(mach,fn) __define_machine_initcall(mach,"3",fn,3)
> +#define machine_arch_initcall_sync(mach,fn) __define_machine_initcall(mach,"3s",fn,3s)
> +#define machine_subsys_initcall(mach,fn) __define_machine_initcall(mach,"4",fn,4)
> +#define machine_subsys_initcall_sync(mach,fn) __define_machine_initcall(mach,"4s",fn,4s)
> +#define machine_fs_initcall(mach,fn) __define_machine_initcall(mach,"5",fn,5)
> +#define machine_fs_initcall_sync(mach,fn) __define_machine_initcall(mach,"5s",fn,5s)
> +#define machine_rootfs_initcall(mach,fn) __define_machine_initcall(mach,"rootfs",fn,rootfs)
> +#define machine_device_initcall(mach,fn) __define_machine_initcall(mach,"6",fn,6)
> +#define machine_device_initcall_sync(mach,fn) __define_machine_initcall(mach,"6s",fn,6s)
> +#define machine_late_initcall(mach,fn) __define_machine_initcall(mach,"7",fn,7)
> +#define machine_late_initcall_sync(mach,fn) __define_machine_initcall(mach,"7s",fn,7s)
> +
> #endif /* __KERNEL__ */
> #endif /* _ASM_POWERPC_MACHDEP_H */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [POWERPC] Add machine initcall macros
2007-12-01 0:24 [PATCH] [POWERPC] Add machine initcall macros Grant Likely
2007-12-01 5:10 ` Benjamin Herrenschmidt
@ 2007-12-01 7:11 ` Michael Ellerman
2007-12-01 7:26 ` Benjamin Herrenschmidt
1 sibling, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2007-12-01 7:11 UTC (permalink / raw)
To: Grant Likely; +Cc: linuxppc-dev, olof
[-- Attachment #1: Type: text/plain, Size: 2679 bytes --]
On Fri, 2007-11-30 at 17:24 -0700, Grant Likely wrote:
> From: Grant Likely <grant.likely@secretlab.ca>
>
> The machine initcall macros allow initcalls to be registered which
> test machine_is() before executing the initcall.
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
>
> Ben, is this the sort of thing you're considering?
>
> g.
>
> include/asm-powerpc/machdep.h | 19 +++++++++++++++++++
> 1 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h
> index 6968f43..f24af06 100644
> --- a/include/asm-powerpc/machdep.h
> +++ b/include/asm-powerpc/machdep.h
> @@ -326,5 +326,24 @@ static inline void log_error(char *buf, unsigned int err_type, int fatal)
> ppc_md.log_error(buf, err_type, fatal);
> }
>
> +#define __define_machine_initcall(mach,level,fn,id) \
> + static int __init __machine_initcall_##mach##_##fn(void) { \
> + if (machine_is(mach)) return fn(); \
> + return 0; \
> + } \
> + __define_initcall(level,__machine_initcall_##mach##_##fn,id);
> +
> +#define machine_arch_initcall(mach,fn) __define_machine_initcall(mach,"3",fn,3)
> +#define machine_arch_initcall_sync(mach,fn) __define_machine_initcall(mach,"3s",fn,3s)
> +#define machine_subsys_initcall(mach,fn) __define_machine_initcall(mach,"4",fn,4)
> +#define machine_subsys_initcall_sync(mach,fn) __define_machine_initcall(mach,"4s",fn,4s)
> +#define machine_fs_initcall(mach,fn) __define_machine_initcall(mach,"5",fn,5)
> +#define machine_fs_initcall_sync(mach,fn) __define_machine_initcall(mach,"5s",fn,5s)
> +#define machine_rootfs_initcall(mach,fn) __define_machine_initcall(mach,"rootfs",fn,rootfs)
> +#define machine_device_initcall(mach,fn) __define_machine_initcall(mach,"6",fn,6)
> +#define machine_device_initcall_sync(mach,fn) __define_machine_initcall(mach,"6s",fn,6s)
> +#define machine_late_initcall(mach,fn) __define_machine_initcall(mach,"7",fn,7)
> +#define machine_late_initcall_sync(mach,fn) __define_machine_initcall(mach,"7s",fn,7s)
I can't think at the moment, it's Saturday, but is there some way we
could just make it a wrapper macro, so we don't need to redefine - and
keep in sync - all the different init call types?
So the usage would look something like:
arch_initcall(machine_initcall(foo, bar));
or
machine_initcall(foo, arch_initcall(bar));
cheers
--
Michael Ellerman
OzLabs, IBM Australia Development Lab
wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)
We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [POWERPC] Add machine initcall macros
2007-12-01 7:11 ` Michael Ellerman
@ 2007-12-01 7:26 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2007-12-01 7:26 UTC (permalink / raw)
To: michael; +Cc: linuxppc-dev, olof
On Sat, 2007-12-01 at 18:11 +1100, Michael Ellerman wrote:
> I can't think at the moment, it's Saturday, but is there some way we
> could just make it a wrapper macro, so we don't need to redefine - and
> keep in sync - all the different init call types?
>
> So the usage would look something like:
>
> arch_initcall(machine_initcall(foo, bar));
>
> or
>
> machine_initcall(foo, arch_initcall(bar));
Not really. I'd like to turn that into magic ELF sections ultimately, in
which case your trick above wouldn't work... besides, it's clumsy :-)
Ben.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-12-01 7:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-01 0:24 [PATCH] [POWERPC] Add machine initcall macros Grant Likely
2007-12-01 5:10 ` Benjamin Herrenschmidt
2007-12-01 7:11 ` Michael Ellerman
2007-12-01 7:26 ` Benjamin Herrenschmidt
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).