[PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata
On some architectures we need to setup pdev_archdata before we add the device. Waiting til a bus_notifier is too late since we might need the pdev_archdata in the bus notifier. One example is setting up of dma_mask pointers such that it can be used in a bus_notifier. We add noop version of arch_setup_pdev_archdata() in asm-generic/platform_device.h and allow the arch code to override with access the full definitions of struct device, struct platform_device, and struct pdev_archdata. Signed-off-by: Kumar Gala ga...@kernel.crashing.org --- arch/alpha/include/asm/platform_device.h |1 + arch/arm/include/asm/platform_device.h|1 + arch/avr32/include/asm/platform_device.h |1 + arch/blackfin/include/asm/platform_device.h |1 + arch/cris/include/asm/platform_device.h |1 + arch/frv/include/asm/platform_device.h|1 + arch/h8300/include/asm/platform_device.h |1 + arch/ia64/include/asm/platform_device.h |1 + arch/m32r/include/asm/platform_device.h |1 + arch/m68k/include/asm/platform_device.h |1 + arch/microblaze/include/asm/platform_device.h |1 + arch/mips/include/asm/platform_device.h |1 + arch/mn10300/include/asm/platform_device.h|1 + arch/parisc/include/asm/platform_device.h |1 + arch/powerpc/include/asm/platform_device.h|1 + arch/s390/include/asm/platform_device.h |1 + arch/score/include/asm/platform_device.h |1 + arch/sh/include/asm/platform_device.h |1 + arch/sparc/include/asm/platform_device.h |1 + arch/tile/include/asm/platform_device.h |1 + arch/unicore32/include/asm/platform_device.h |1 + arch/x86/include/asm/platform_device.h|1 + arch/xtensa/include/asm/platform_device.h |1 + drivers/base/platform.c |2 ++ include/asm-generic/platform_device.h | 11 +++ 25 files changed, 36 insertions(+), 0 deletions(-) create mode 100644 arch/alpha/include/asm/platform_device.h create mode 100644 arch/arm/include/asm/platform_device.h create mode 100644 arch/avr32/include/asm/platform_device.h create mode 100644 arch/blackfin/include/asm/platform_device.h create mode 100644 arch/cris/include/asm/platform_device.h create mode 100644 arch/frv/include/asm/platform_device.h create mode 100644 arch/h8300/include/asm/platform_device.h create mode 100644 arch/ia64/include/asm/platform_device.h create mode 100644 arch/m32r/include/asm/platform_device.h create mode 100644 arch/m68k/include/asm/platform_device.h create mode 100644 arch/microblaze/include/asm/platform_device.h create mode 100644 arch/mips/include/asm/platform_device.h create mode 100644 arch/mn10300/include/asm/platform_device.h create mode 100644 arch/parisc/include/asm/platform_device.h create mode 100644 arch/powerpc/include/asm/platform_device.h create mode 100644 arch/s390/include/asm/platform_device.h create mode 100644 arch/score/include/asm/platform_device.h create mode 100644 arch/sh/include/asm/platform_device.h create mode 100644 arch/sparc/include/asm/platform_device.h create mode 100644 arch/tile/include/asm/platform_device.h create mode 100644 arch/unicore32/include/asm/platform_device.h create mode 100644 arch/x86/include/asm/platform_device.h create mode 100644 arch/xtensa/include/asm/platform_device.h create mode 100644 include/asm-generic/platform_device.h diff --git a/arch/alpha/include/asm/platform_device.h b/arch/alpha/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++ b/arch/alpha/include/asm/platform_device.h @@ -0,0 +1 @@ +#include asm-generic/platform_device.h diff --git a/arch/arm/include/asm/platform_device.h b/arch/arm/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++ b/arch/arm/include/asm/platform_device.h @@ -0,0 +1 @@ +#include asm-generic/platform_device.h diff --git a/arch/avr32/include/asm/platform_device.h b/arch/avr32/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++ b/arch/avr32/include/asm/platform_device.h @@ -0,0 +1 @@ +#include asm-generic/platform_device.h diff --git a/arch/blackfin/include/asm/platform_device.h b/arch/blackfin/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++ b/arch/blackfin/include/asm/platform_device.h @@ -0,0 +1 @@ +#include asm-generic/platform_device.h diff --git a/arch/cris/include/asm/platform_device.h b/arch/cris/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++ b/arch/cris/include/asm/platform_device.h @@ -0,0 +1 @@ +#include asm-generic/platform_device.h diff --git a/arch/frv/include/asm/platform_device.h b/arch/frv/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++ b/arch/frv/include/asm/platform_device.h @@ -0,0 +1 @@ +#include
Re: [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata
On Wed, Jun 22, 2011 at 08:02, Kumar Gala wrote: --- /dev/null +++ b/include/asm-generic/platform_device.h @@ -0,0 +1,11 @@ missing header blob with explanation/copyright/license +/* + * an architecture can override to define arch_setup_pdev_archdata + */ +#ifndef arch_setup_pdev_archdata +static inline void arch_setup_pdev_archdata(struct platform_device *pdev) { } +#endif missing explanation of what the func actually does, and this header lacks a forward struct decl for platform_device -mike ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata
On some architectures we need to setup pdev_archdata before we add the device. Waiting til a bus_notifier is too late since we might need the pdev_archdata in the bus notifier. One example is setting up of dma_mask pointers such that it can be used in a bus_notifier. We add ARCH_HAS_PDEV_ARCHDATA_SETUP and a dummy asm/platform_device.h header to allow the arch code to have an inline implementation of arch_setup_pdev_archdata() and being able to access the full definitions of struct device, struct platform_device, and struct pdev_archdata. Signed-off-by: Kumar Gala ga...@kernel.crashing.org --- arch/alpha/include/asm/platform_device.h |1 + arch/arm/include/asm/platform_device.h|1 + arch/avr32/include/asm/platform_device.h |1 + arch/blackfin/include/asm/platform_device.h |1 + arch/cris/include/asm/platform_device.h |1 + arch/frv/include/asm/platform_device.h|1 + arch/h8300/include/asm/platform_device.h |1 + arch/ia64/include/asm/platform_device.h |1 + arch/m32r/include/asm/platform_device.h |1 + arch/m68k/include/asm/platform_device.h |1 + arch/microblaze/include/asm/platform_device.h |1 + arch/mips/include/asm/platform_device.h |1 + arch/mn10300/include/asm/platform_device.h|1 + arch/parisc/include/asm/platform_device.h |1 + arch/powerpc/include/asm/platform_device.h|1 + arch/s390/include/asm/platform_device.h |1 + arch/score/include/asm/platform_device.h |1 + arch/sh/include/asm/platform_device.h |1 + arch/sparc/include/asm/platform_device.h |1 + arch/x86/include/asm/platform_device.h|1 + arch/xtensa/include/asm/platform_device.h |1 + drivers/base/platform.c |4 include/asm-generic/platform_device.h |7 +++ 23 files changed, 32 insertions(+), 0 deletions(-) create mode 100644 arch/alpha/include/asm/platform_device.h create mode 100644 arch/arm/include/asm/platform_device.h create mode 100644 arch/avr32/include/asm/platform_device.h create mode 100644 arch/blackfin/include/asm/platform_device.h create mode 100644 arch/cris/include/asm/platform_device.h create mode 100644 arch/frv/include/asm/platform_device.h create mode 100644 arch/h8300/include/asm/platform_device.h create mode 100644 arch/ia64/include/asm/platform_device.h create mode 100644 arch/m32r/include/asm/platform_device.h create mode 100644 arch/m68k/include/asm/platform_device.h create mode 100644 arch/microblaze/include/asm/platform_device.h create mode 100644 arch/mips/include/asm/platform_device.h create mode 100644 arch/mn10300/include/asm/platform_device.h create mode 100644 arch/parisc/include/asm/platform_device.h create mode 100644 arch/powerpc/include/asm/platform_device.h create mode 100644 arch/s390/include/asm/platform_device.h create mode 100644 arch/score/include/asm/platform_device.h create mode 100644 arch/sh/include/asm/platform_device.h create mode 100644 arch/sparc/include/asm/platform_device.h create mode 100644 arch/x86/include/asm/platform_device.h create mode 100644 arch/xtensa/include/asm/platform_device.h create mode 100644 include/asm-generic/platform_device.h diff --git a/arch/alpha/include/asm/platform_device.h b/arch/alpha/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++ b/arch/alpha/include/asm/platform_device.h @@ -0,0 +1 @@ +#include asm-generic/platform_device.h diff --git a/arch/arm/include/asm/platform_device.h b/arch/arm/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++ b/arch/arm/include/asm/platform_device.h @@ -0,0 +1 @@ +#include asm-generic/platform_device.h diff --git a/arch/avr32/include/asm/platform_device.h b/arch/avr32/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++ b/arch/avr32/include/asm/platform_device.h @@ -0,0 +1 @@ +#include asm-generic/platform_device.h diff --git a/arch/blackfin/include/asm/platform_device.h b/arch/blackfin/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++ b/arch/blackfin/include/asm/platform_device.h @@ -0,0 +1 @@ +#include asm-generic/platform_device.h diff --git a/arch/cris/include/asm/platform_device.h b/arch/cris/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++ b/arch/cris/include/asm/platform_device.h @@ -0,0 +1 @@ +#include asm-generic/platform_device.h diff --git a/arch/frv/include/asm/platform_device.h b/arch/frv/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++ b/arch/frv/include/asm/platform_device.h @@ -0,0 +1 @@ +#include asm-generic/platform_device.h diff --git a/arch/h8300/include/asm/platform_device.h b/arch/h8300/include/asm/platform_device.h new file mode 100644 index 000..01452c3 --- /dev/null +++
Re: [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata
Hi Kumar, On Thu, 5 Aug 2010 10:15:45 -0500 Kumar Gala ga...@kernel.crashing.org wrote: --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -19,6 +19,7 @@ #include linux/err.h #include linux/slab.h #include linux/pm_runtime.h +#include asm/platform_device.h #include base.h @@ -170,6 +171,9 @@ struct platform_device *platform_device_alloc(const char *name, int id) pa-pdev.id = id; device_initialize(pa-pdev.dev); pa-pdev.dev.release = platform_device_release; +#ifdef ARCH_HAS_PDEV_ARCHDATA_SETUP + arch_setup_pdev_archdata(pa-pdev); +#endif } return pa ? pa-pdev : NULL; diff --git a/include/asm-generic/platform_device.h b/include/asm-generic/platform_device.h new file mode 100644 index 000..64806dc --- /dev/null +++ b/include/asm-generic/platform_device.h @@ -0,0 +1,7 @@ +#ifndef __ASM_GENERIC_PLATFORM_DEVICE_H_ +#define __ASM_GENERIC_PLATFORM_DEVICE_H_ +/* + * an architecture can override to define arch_setup_pdev_archdata + */ + +#endif /* __ASM_GENERIC_PLATFORM_DEVICE_H_ */ Why not do: #include linux/platform_device.h #ifndef arch_setup_pdev_archdata static inline void arch_setup_pdev_archdata(struct platform_device *pdev) { } #endif in asm-generic/platform-device.h and the the call in platform_device_alloc() can be unconditional. If the arch wants to override arch_setup_pdev_archdata, it defines the function and then does #define arch_setup_pdev_archdata arch_setup_pdev_archdata before still including asm-generic/platform_device.h -- Cheers, Stephen Rothwells...@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ pgpSkm1jKhLGJ.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata
On Aug 5, 2010, at 10:43 AM, Stephen Rothwell wrote: Hi Kumar, On Thu, 5 Aug 2010 10:15:45 -0500 Kumar Gala ga...@kernel.crashing.org wrote: --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -19,6 +19,7 @@ #include linux/err.h #include linux/slab.h #include linux/pm_runtime.h +#include asm/platform_device.h #include base.h @@ -170,6 +171,9 @@ struct platform_device *platform_device_alloc(const char *name, int id) pa-pdev.id = id; device_initialize(pa-pdev.dev); pa-pdev.dev.release = platform_device_release; +#ifdef ARCH_HAS_PDEV_ARCHDATA_SETUP +arch_setup_pdev_archdata(pa-pdev); +#endif } return pa ? pa-pdev : NULL; diff --git a/include/asm-generic/platform_device.h b/include/asm-generic/platform_device.h new file mode 100644 index 000..64806dc --- /dev/null +++ b/include/asm-generic/platform_device.h @@ -0,0 +1,7 @@ +#ifndef __ASM_GENERIC_PLATFORM_DEVICE_H_ +#define __ASM_GENERIC_PLATFORM_DEVICE_H_ +/* + * an architecture can override to define arch_setup_pdev_archdata + */ + +#endif /* __ASM_GENERIC_PLATFORM_DEVICE_H_ */ Why not do: #include linux/platform_device.h #ifndef arch_setup_pdev_archdata static inline void arch_setup_pdev_archdata(struct platform_device *pdev) { } #endif in asm-generic/platform-device.h and the the call in platform_device_alloc() can be unconditional. If the arch wants to override arch_setup_pdev_archdata, it defines the function and then does #define arch_setup_pdev_archdata arch_setup_pdev_archdata before still including asm-generic/platform_device.h I've got no issues with the style change. - k ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata
On Fri, Aug 06, 2010 at 01:43:51AM +1000, Stephen Rothwell wrote: Hi Kumar, On Thu, 5 Aug 2010 10:15:45 -0500 Kumar Gala ga...@kernel.crashing.org wrote: --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -19,6 +19,7 @@ #include linux/err.h #include linux/slab.h #include linux/pm_runtime.h +#include asm/platform_device.h #include base.h @@ -170,6 +171,9 @@ struct platform_device *platform_device_alloc(const char *name, int id) pa-pdev.id = id; device_initialize(pa-pdev.dev); pa-pdev.dev.release = platform_device_release; +#ifdef ARCH_HAS_PDEV_ARCHDATA_SETUP + arch_setup_pdev_archdata(pa-pdev); +#endif } return pa ? pa-pdev : NULL; diff --git a/include/asm-generic/platform_device.h b/include/asm-generic/platform_device.h new file mode 100644 index 000..64806dc --- /dev/null +++ b/include/asm-generic/platform_device.h @@ -0,0 +1,7 @@ +#ifndef __ASM_GENERIC_PLATFORM_DEVICE_H_ +#define __ASM_GENERIC_PLATFORM_DEVICE_H_ +/* + * an architecture can override to define arch_setup_pdev_archdata + */ + +#endif /* __ASM_GENERIC_PLATFORM_DEVICE_H_ */ Why not do: #include linux/platform_device.h #ifndef arch_setup_pdev_archdata static inline void arch_setup_pdev_archdata(struct platform_device *pdev) { } #endif in asm-generic/platform-device.h and the the call in platform_device_alloc() can be unconditional. If the arch wants to override arch_setup_pdev_archdata, it defines the function and then does #define arch_setup_pdev_archdata arch_setup_pdev_archdata before still including asm-generic/platform_device.h Yes, I'd prefer that method as well. thanks, greg k-h ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev