2009-06-16 06:11:29

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 012/143] USB: move twl4030_usb's probe function to .devinit.text

Hi Greg,

On Mon, Jun 15, 2009 at 10:22:07PM -0700, Greg Kroah-Hartman wrote:
> A pointer to twl4030_usb_probe is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.
I wonder if this kind of error could be detected automatically. That is
at probe time check if the probe function is in the .init.text section.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |


2009-06-16 06:26:01

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 012/143] USB: move twl4030_usb's probe function to .devinit.text

On Tue, Jun 16, 2009 at 08:05:59AM +0200, Uwe Kleine-K?nig wrote:
> Hi Greg,
>
> On Mon, Jun 15, 2009 at 10:22:07PM -0700, Greg Kroah-Hartman wrote:
> > A pointer to twl4030_usb_probe is passed to the core via
> > platform_driver_register and so the function must not disappear when the
> > .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> > unbinding and binding a device to the driver via sysfs will result in an
> > oops as does a device being registered late.
> >
> > An alternative to this patch is using platform_driver_probe instead of
> > platform_driver_register plus removing the pointer to the probe function
> > from the struct platform_driver.
> I wonder if this kind of error could be detected automatically. That is
> at probe time check if the probe function is in the .init.text section.

There's nothing wrong with calling probe functions in the .init.text
section, _before_ we throw away the init.text section :)

So we would have to somehow know when that happens.

thanks,

greg k-h

2009-06-16 09:14:50

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 012/143] USB: move twl4030_usb's probe function to .devinit.text

Hi Greg,

On Mon, Jun 15, 2009 at 11:20:35PM -0700, Greg KH wrote:
> On Tue, Jun 16, 2009 at 08:05:59AM +0200, Uwe Kleine-K?nig wrote:
> > Hi Greg,
> >
> > On Mon, Jun 15, 2009 at 10:22:07PM -0700, Greg Kroah-Hartman wrote:
> > > A pointer to twl4030_usb_probe is passed to the core via
> > > platform_driver_register and so the function must not disappear when the
> > > .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> > > unbinding and binding a device to the driver via sysfs will result in an
> > > oops as does a device being registered late.
> > >
> > > An alternative to this patch is using platform_driver_probe instead of
> > > platform_driver_register plus removing the pointer to the probe function
> > > from the struct platform_driver.
> > I wonder if this kind of error could be detected automatically. That is
> > at probe time check if the probe function is in the .init.text section.
>
> There's nothing wrong with calling probe functions in the .init.text
> section, _before_ we throw away the init.text section :)
Ah, my fault:

I wonder if this kind of error could be detected automatically. That is
at *register* time check if the probe function is in the .init.text
section.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-06-16 16:30:40

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 012/143] USB: move twl4030_usb's probe function to .devinit.text

On Tue, Jun 16, 2009 at 11:14:44AM +0200, Uwe Kleine-K?nig wrote:
> Hi Greg,
>
> On Mon, Jun 15, 2009 at 11:20:35PM -0700, Greg KH wrote:
> > On Tue, Jun 16, 2009 at 08:05:59AM +0200, Uwe Kleine-K?nig wrote:
> > > Hi Greg,
> > >
> > > On Mon, Jun 15, 2009 at 10:22:07PM -0700, Greg Kroah-Hartman wrote:
> > > > A pointer to twl4030_usb_probe is passed to the core via
> > > > platform_driver_register and so the function must not disappear when the
> > > > .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> > > > unbinding and binding a device to the driver via sysfs will result in an
> > > > oops as does a device being registered late.
> > > >
> > > > An alternative to this patch is using platform_driver_probe instead of
> > > > platform_driver_register plus removing the pointer to the probe function
> > > > from the struct platform_driver.
> > > I wonder if this kind of error could be detected automatically. That is
> > > at probe time check if the probe function is in the .init.text section.
> >
> > There's nothing wrong with calling probe functions in the .init.text
> > section, _before_ we throw away the init.text section :)
> Ah, my fault:
>
> I wonder if this kind of error could be detected automatically. That is
> at *register* time check if the probe function is in the .init.text
> section.

But again, we can register devices with their probe functions in
.init.text and use them, before .init.text is thrown away, right?

So I don't see an easy way to check this and keep people from doing
stupid things...

thanks,

greg k-h

2009-06-16 17:59:21

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 012/143] USB: move twl4030_usb's probe function to .devinit.text

Hello,

On Tue, Jun 16, 2009 at 09:21:06AM -0700, Greg KH wrote:
> On Tue, Jun 16, 2009 at 11:14:44AM +0200, Uwe Kleine-K?nig wrote:
> > Hi Greg,
> >
> > On Mon, Jun 15, 2009 at 11:20:35PM -0700, Greg KH wrote:
> > > On Tue, Jun 16, 2009 at 08:05:59AM +0200, Uwe Kleine-K?nig wrote:
> > > > Hi Greg,
> > > >
> > > > On Mon, Jun 15, 2009 at 10:22:07PM -0700, Greg Kroah-Hartman wrote:
> > > > > A pointer to twl4030_usb_probe is passed to the core via
> > > > > platform_driver_register and so the function must not disappear when the
> > > > > .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> > > > > unbinding and binding a device to the driver via sysfs will result in an
> > > > > oops as does a device being registered late.
> > > > >
> > > > > An alternative to this patch is using platform_driver_probe instead of
> > > > > platform_driver_register plus removing the pointer to the probe function
> > > > > from the struct platform_driver.
> > > > I wonder if this kind of error could be detected automatically. That is
> > > > at probe time check if the probe function is in the .init.text section.
> > >
> > > There's nothing wrong with calling probe functions in the .init.text
> > > section, _before_ we throw away the init.text section :)
> > Ah, my fault:
> >
> > I wonder if this kind of error could be detected automatically. That is
> > at *register* time check if the probe function is in the .init.text
> > section.
>
> But again, we can register devices with their probe functions in
> .init.text and use them, before .init.text is thrown away, right?
Yes, but only if you unregister the driver before .init.text is thrown
away, right?

If your driver is still active while .init.text already disappeared a new
device makes your kernel oops.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-06-16 18:06:19

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 012/143] USB: move twl4030_usb's probe function to .devinit.text

On Tue, Jun 16, 2009 at 07:59:00PM +0200, Uwe Kleine-K?nig wrote:
> Hello,
>
> On Tue, Jun 16, 2009 at 09:21:06AM -0700, Greg KH wrote:
> > On Tue, Jun 16, 2009 at 11:14:44AM +0200, Uwe Kleine-K?nig wrote:
> > > Hi Greg,
> > >
> > > On Mon, Jun 15, 2009 at 11:20:35PM -0700, Greg KH wrote:
> > > > On Tue, Jun 16, 2009 at 08:05:59AM +0200, Uwe Kleine-K?nig wrote:
> > > > > Hi Greg,
> > > > >
> > > > > On Mon, Jun 15, 2009 at 10:22:07PM -0700, Greg Kroah-Hartman wrote:
> > > > > > A pointer to twl4030_usb_probe is passed to the core via
> > > > > > platform_driver_register and so the function must not disappear when the
> > > > > > .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> > > > > > unbinding and binding a device to the driver via sysfs will result in an
> > > > > > oops as does a device being registered late.
> > > > > >
> > > > > > An alternative to this patch is using platform_driver_probe instead of
> > > > > > platform_driver_register plus removing the pointer to the probe function
> > > > > > from the struct platform_driver.
> > > > > I wonder if this kind of error could be detected automatically. That is
> > > > > at probe time check if the probe function is in the .init.text section.
> > > >
> > > > There's nothing wrong with calling probe functions in the .init.text
> > > > section, _before_ we throw away the init.text section :)
> > > Ah, my fault:
> > >
> > > I wonder if this kind of error could be detected automatically. That is
> > > at *register* time check if the probe function is in the .init.text
> > > section.
> >
> > But again, we can register devices with their probe functions in
> > .init.text and use them, before .init.text is thrown away, right?
> Yes, but only if you unregister the driver before .init.text is thrown
> away, right?
>
> If your driver is still active while .init.text already disappeared a new
> device makes your kernel oops.

Yes, but for almost all platform devices, they can not have a new device
appear after init runs, as they are fixed to the motherboard.

Anyway, if you want to send a patch to dynamically catch this kind of
problem, that would be great.

thanks,

greg k-h

2009-06-16 18:23:18

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 012/143] USB: move twl4030_usb's probe function to .devinit.text

Hello,

On Tue, Jun 16, 2009 at 11:00:53AM -0700, Greg KH wrote:
> On Tue, Jun 16, 2009 at 07:59:00PM +0200, Uwe Kleine-K?nig wrote:
> > Hello,
> >
> > On Tue, Jun 16, 2009 at 09:21:06AM -0700, Greg KH wrote:
> > > On Tue, Jun 16, 2009 at 11:14:44AM +0200, Uwe Kleine-K?nig wrote:
> > > > Hi Greg,
> > > >
> > > > On Mon, Jun 15, 2009 at 11:20:35PM -0700, Greg KH wrote:
> > > > > On Tue, Jun 16, 2009 at 08:05:59AM +0200, Uwe Kleine-K?nig wrote:
> > > > > > Hi Greg,
> > > > > >
> > > > > > On Mon, Jun 15, 2009 at 10:22:07PM -0700, Greg Kroah-Hartman wrote:
> > > > > > > A pointer to twl4030_usb_probe is passed to the core via
> > > > > > > platform_driver_register and so the function must not disappear when the
> > > > > > > .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> > > > > > > unbinding and binding a device to the driver via sysfs will result in an
> > > > > > > oops as does a device being registered late.
> > > > > > >
> > > > > > > An alternative to this patch is using platform_driver_probe instead of
> > > > > > > platform_driver_register plus removing the pointer to the probe function
> > > > > > > from the struct platform_driver.
> > > > > > I wonder if this kind of error could be detected automatically. That is
> > > > > > at probe time check if the probe function is in the .init.text section.
> > > > >
> > > > > There's nothing wrong with calling probe functions in the .init.text
> > > > > section, _before_ we throw away the init.text section :)
> > > > Ah, my fault:
> > > >
> > > > I wonder if this kind of error could be detected automatically. That is
> > > > at *register* time check if the probe function is in the .init.text
> > > > section.
> > >
> > > But again, we can register devices with their probe functions in
> > > .init.text and use them, before .init.text is thrown away, right?
> > Yes, but only if you unregister the driver before .init.text is thrown
> > away, right?
> >
> > If your driver is still active while .init.text already disappeared a new
> > device makes your kernel oops.
>
> Yes, but for almost all platform devices, they can not have a new device
> appear after init runs, as they are fixed to the motherboard.
The same check could be implemented for drivers of the other bus types,
too.

> Anyway, if you want to send a patch to dynamically catch this kind of
> problem, that would be great.
I somehow feared that at one point someone wants a patch from me if I
ask if it's possible at all ... :-)

/me goes and searces if there is already a function to check if a
pointer points into .init.text.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-06-19 13:42:43

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] platform_driver_register: warn if probe is in .init.text

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/base/platform.c | 42 ++++++++++++++++++++++++++++++++++++------
include/linux/kernel.h | 2 ++
include/linux/module.h | 12 ++++++++++++
kernel/extable.c | 12 ++++++++++++
kernel/module.c | 36 ++++++++++++++++++++++++++++++++++++
5 files changed, 98 insertions(+), 6 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 81cb01b..851ba84 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -470,11 +470,7 @@ static void platform_drv_shutdown(struct device *_dev)
drv->shutdown(dev);
}

-/**
- * platform_driver_register
- * @drv: platform driver structure
- */
-int platform_driver_register(struct platform_driver *drv)
+static int __platform_driver_register(struct platform_driver *drv)
{
drv->driver.bus = &platform_bus_type;
if (drv->probe)
@@ -489,6 +485,40 @@ int platform_driver_register(struct platform_driver *drv)

return driver_register(&drv->driver);
}
+
+/**
+ * platform_driver_register
+ * @drv: platform driver structure
+ */
+int platform_driver_register(struct platform_driver *drv)
+{
+ int ret = __platform_driver_register(drv);
+
+#if defined(CONFIG_HOTPLUG)
+ /*
+ * drivers that are registered by platform_driver_register
+ * should not have their probe function in .init.text. The
+ * reason is that a probe can happen after .init.text is
+ * discarded which then results in an oops. The alternatives
+ * are using .devinit.text for the probe function or "register"
+ * with platform_driver_probe.
+ */
+ if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
+ pr_warning("oops-warning: probe function of platform driver %s"
+ " lives in .init.text\n", drv->driver.name);
+#else
+ /*
+ * without HOTPLUG probe functions can be discarded after the driver is
+ * loaded.
+ * There is a little chance for false positives, namely if the driver is
+ * registered after the .init sections are discarded.
+ */
+ if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
+ pr_info("probably the probe function of platform driver %s can"
+ " be moved to .init.text\n", drv->driver.name);
+#endif
+ return ret;
+}
EXPORT_SYMBOL_GPL(platform_driver_register);

/**
@@ -525,7 +555,7 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv,

/* temporary section violation during probe() */
drv->probe = probe;
- retval = code = platform_driver_register(drv);
+ retval = code = __platform_driver_register(drv);

/* Fixup that section violation, being paranoid about code scanning
* the list of drivers in order to probe new devices. Check to see
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index c5a71c3..5db1817 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -203,8 +203,10 @@ extern char *get_options(const char *str, int nints, int *ints);
extern unsigned long long memparse(const char *ptr, char **retptr);

extern int core_kernel_text(unsigned long addr);
+extern int core_kernel_init_text(unsigned long addr)
extern int __kernel_text_address(unsigned long addr);
extern int kernel_text_address(unsigned long addr);
+extern int kernel_init_text_address(unsigned long addr);
extern int func_ptr_is_kernel_text(void *ptr);

struct pid;
diff --git a/include/linux/module.h b/include/linux/module.h
index 505f20d..ff07937 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -379,9 +379,11 @@ static inline int module_is_live(struct module *mod)
}

struct module *__module_text_address(unsigned long addr);
+struct module *__module_init_text_address(unsigned long addr);
struct module *__module_address(unsigned long addr);
bool is_module_address(unsigned long addr);
bool is_module_text_address(unsigned long addr);
+bool is_module_init_text_address(unsigned long addr);

static inline int within_module_core(unsigned long addr, struct module *mod)
{
@@ -550,6 +552,11 @@ static inline struct module *__module_text_address(unsigned long addr)
return NULL;
}

+static inline struct module *__module_init_text_address(unsigned long addr)
+{
+ return NULL;
+}
+
static inline bool is_module_address(unsigned long addr)
{
return false;
@@ -560,6 +567,11 @@ static inline bool is_module_text_address(unsigned long addr)
return false;
}

+static inline bool is_module_init_text_address(unsigned long addr)
+{
+ return false;
+}
+
/* Get/put a kernel symbol (calls should be symmetric) */
#define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
#define symbol_put(x) do { } while(0)
diff --git a/kernel/extable.c b/kernel/extable.c
index 7f8f263..bfd7bda 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -66,6 +66,11 @@ int core_kernel_text(unsigned long addr)
addr <= (unsigned long)_etext)
return 1;

+ return core_kernel_init_text;
+}
+
+int core_kernel_init_text(unsigned long addr)
+{
if (system_state == SYSTEM_BOOTING &&
init_kernel_text(addr))
return 1;
@@ -98,6 +103,13 @@ int kernel_text_address(unsigned long addr)
return is_module_text_address(addr);
}

+int kernel_init_text_address(unsigned long addr)
+{
+ if (core_kernel_init_text(addr))
+ return 1;
+ return is_module_init_text_address(addr);
+}
+
/*
* On some architectures (PPC64, IA64) function pointers
* are actually only tokens to some data that then holds the
diff --git a/kernel/module.c b/kernel/module.c
index 215aaab..a637213 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2874,6 +2874,22 @@ bool is_module_text_address(unsigned long addr)
}

/*
+ * is_module_init_text_address - is this address inside a module's .init.text
+ * section?
+ * @addr: the address to check.
+ */
+bool is_module_init_text_address(unsigned long addr)
+{
+ bool ret;
+
+ preempt_disable();
+ ret = __module_init_text_address(addr) != NULL;
+ preempt_enable();
+
+ return ret;
+}
+
+/*
* __module_text_address - get the module whose code contains an address.
* @addr: the address.
*
@@ -2893,6 +2909,26 @@ struct module *__module_text_address(unsigned long addr)
}
EXPORT_SYMBOL_GPL(__module_text_address);

+/*
+ * __module_init_text_address - get the module whose .init.text contains an
+ * address.
+ * @addr: the address.
+ *
+ * Must be called with preempt disabled or module mutex held so that
+ * module doesn't get freed during this.
+ */
+struct module *__module_init_text_address(unsigned long addr)
+{
+ struct module *mod = __module_address(addr);
+ if (mod) {
+ /* Make sure it's within the .init.text section. */
+ if (!within(addr, mod->module_init, mod->init_text_size))
+ mod = NULL;
+ }
+ return mod;
+}
+EXPORT_SYMBOL_GPL(__module_init_text_address);
+
/* Don't grab lock, we're oopsing. */
void print_modules(void)
{
--
1.6.3.1

2009-06-19 14:15:47

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Fri, Jun 19, 2009 at 03:42:19PM +0200, Uwe Kleine-K?nig wrote:
> Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> ---
> drivers/base/platform.c | 42 ++++++++++++++++++++++++++++++++++++------
> include/linux/kernel.h | 2 ++
> include/linux/module.h | 12 ++++++++++++
> kernel/extable.c | 12 ++++++++++++
> kernel/module.c | 36 ++++++++++++++++++++++++++++++++++++
> 5 files changed, 98 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 81cb01b..851ba84 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -470,11 +470,7 @@ static void platform_drv_shutdown(struct device *_dev)
> drv->shutdown(dev);
> }
>
> -/**
> - * platform_driver_register
> - * @drv: platform driver structure
> - */
> -int platform_driver_register(struct platform_driver *drv)
> +static int __platform_driver_register(struct platform_driver *drv)
> {
> drv->driver.bus = &platform_bus_type;
> if (drv->probe)
> @@ -489,6 +485,40 @@ int platform_driver_register(struct platform_driver *drv)
>
> return driver_register(&drv->driver);
> }
> +
> +/**
> + * platform_driver_register
> + * @drv: platform driver structure
> + */
> +int platform_driver_register(struct platform_driver *drv)
> +{
> + int ret = __platform_driver_register(drv);
> +
> +#if defined(CONFIG_HOTPLUG)
> + /*
> + * drivers that are registered by platform_driver_register
> + * should not have their probe function in .init.text. The
> + * reason is that a probe can happen after .init.text is
> + * discarded which then results in an oops. The alternatives
> + * are using .devinit.text for the probe function or "register"
> + * with platform_driver_probe.
> + */

That's not true, remember, drivers built into the system, like platform
ones, can have their probe function in .init.text, as it will be called
before we discard .init.text, and will never be called again as the
device will never be "hot added" at any future time.

So this could trigger a lot of false positives :(

thanks,

greg k-h

2009-06-19 14:44:00

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hi Greg,

On Fri, Jun 19, 2009 at 07:11:28AM -0700, Greg KH wrote:
> On Fri, Jun 19, 2009 at 03:42:19PM +0200, Uwe Kleine-K?nig wrote:
> > Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> > ---
> > drivers/base/platform.c | 42 ++++++++++++++++++++++++++++++++++++------
> > include/linux/kernel.h | 2 ++
> > include/linux/module.h | 12 ++++++++++++
> > kernel/extable.c | 12 ++++++++++++
> > kernel/module.c | 36 ++++++++++++++++++++++++++++++++++++
> > 5 files changed, 98 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > index 81cb01b..851ba84 100644
> > --- a/drivers/base/platform.c
> > +++ b/drivers/base/platform.c
> > @@ -470,11 +470,7 @@ static void platform_drv_shutdown(struct device *_dev)
> > drv->shutdown(dev);
> > }
> >
> > -/**
> > - * platform_driver_register
> > - * @drv: platform driver structure
> > - */
> > -int platform_driver_register(struct platform_driver *drv)
> > +static int __platform_driver_register(struct platform_driver *drv)
> > {
> > drv->driver.bus = &platform_bus_type;
> > if (drv->probe)
> > @@ -489,6 +485,40 @@ int platform_driver_register(struct platform_driver *drv)
> >
> > return driver_register(&drv->driver);
> > }
> > +
> > +/**
> > + * platform_driver_register
> > + * @drv: platform driver structure
> > + */
> > +int platform_driver_register(struct platform_driver *drv)
> > +{
> > + int ret = __platform_driver_register(drv);
> > +
> > +#if defined(CONFIG_HOTPLUG)
> > + /*
> > + * drivers that are registered by platform_driver_register
> > + * should not have their probe function in .init.text. The
> > + * reason is that a probe can happen after .init.text is
> > + * discarded which then results in an oops. The alternatives
> > + * are using .devinit.text for the probe function or "register"
> > + * with platform_driver_probe.
> > + */
>
> That's not true, remember, drivers built into the system, like platform
> ones, can have their probe function in .init.text, as it will be called
> before we discard .init.text, and will never be called again as the
> device will never be "hot added" at any future time.
>
> So this could trigger a lot of false positives :(
IMHO this is not a false positive. You can still do

for f in unbind bind do echo $deviceid > /sys/bus/platform/drivers/$drivername/$f; done

This type of driver should use platform_driver_probe.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-06-29 07:55:43

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hi Greg,

On Fri, Jun 19, 2009 at 04:43:54PM +0200, Uwe Kleine-K?nig wrote:
> On Fri, Jun 19, 2009 at 07:11:28AM -0700, Greg KH wrote:
> > On Fri, Jun 19, 2009 at 03:42:19PM +0200, Uwe Kleine-K?nig wrote:
> > > Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> > > ---
> > > drivers/base/platform.c | 42 ++++++++++++++++++++++++++++++++++++------
> > > include/linux/kernel.h | 2 ++
> > > include/linux/module.h | 12 ++++++++++++
> > > kernel/extable.c | 12 ++++++++++++
> > > kernel/module.c | 36 ++++++++++++++++++++++++++++++++++++
> > > 5 files changed, 98 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > > index 81cb01b..851ba84 100644
> > > --- a/drivers/base/platform.c
> > > +++ b/drivers/base/platform.c
> > > @@ -470,11 +470,7 @@ static void platform_drv_shutdown(struct device *_dev)
> > > drv->shutdown(dev);
> > > }
> > >
> > > -/**
> > > - * platform_driver_register
> > > - * @drv: platform driver structure
> > > - */
> > > -int platform_driver_register(struct platform_driver *drv)
> > > +static int __platform_driver_register(struct platform_driver *drv)
> > > {
> > > drv->driver.bus = &platform_bus_type;
> > > if (drv->probe)
> > > @@ -489,6 +485,40 @@ int platform_driver_register(struct platform_driver *drv)
> > >
> > > return driver_register(&drv->driver);
> > > }
> > > +
> > > +/**
> > > + * platform_driver_register
> > > + * @drv: platform driver structure
> > > + */
> > > +int platform_driver_register(struct platform_driver *drv)
> > > +{
> > > + int ret = __platform_driver_register(drv);
> > > +
> > > +#if defined(CONFIG_HOTPLUG)
> > > + /*
> > > + * drivers that are registered by platform_driver_register
> > > + * should not have their probe function in .init.text. The
> > > + * reason is that a probe can happen after .init.text is
> > > + * discarded which then results in an oops. The alternatives
> > > + * are using .devinit.text for the probe function or "register"
> > > + * with platform_driver_probe.
> > > + */
> >
> > That's not true, remember, drivers built into the system, like platform
> > ones, can have their probe function in .init.text, as it will be called
> > before we discard .init.text, and will never be called again as the
> > device will never be "hot added" at any future time.
> >
> > So this could trigger a lot of false positives :(
> IMHO this is not a false positive. You can still do
>
> for f in unbind bind do echo $deviceid > /sys/bus/platform/drivers/$drivername/$f; done
>
> This type of driver should use platform_driver_probe.
Are you conviced and took the patch or did you give up to convince me?

I still think the patch is correct and I'd like to have it applied.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-11 03:36:18

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Mon, Jun 29, 2009 at 09:55:35AM +0200, Uwe Kleine-K?nig wrote:
> Hi Greg,
>
> On Fri, Jun 19, 2009 at 04:43:54PM +0200, Uwe Kleine-K?nig wrote:
> > On Fri, Jun 19, 2009 at 07:11:28AM -0700, Greg KH wrote:
> > > On Fri, Jun 19, 2009 at 03:42:19PM +0200, Uwe Kleine-K?nig wrote:
> > > > Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> > > > ---
> > > > drivers/base/platform.c | 42 ++++++++++++++++++++++++++++++++++++------
> > > > include/linux/kernel.h | 2 ++
> > > > include/linux/module.h | 12 ++++++++++++
> > > > kernel/extable.c | 12 ++++++++++++
> > > > kernel/module.c | 36 ++++++++++++++++++++++++++++++++++++
> > > > 5 files changed, 98 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> > > > index 81cb01b..851ba84 100644
> > > > --- a/drivers/base/platform.c
> > > > +++ b/drivers/base/platform.c
> > > > @@ -470,11 +470,7 @@ static void platform_drv_shutdown(struct device *_dev)
> > > > drv->shutdown(dev);
> > > > }
> > > >
> > > > -/**
> > > > - * platform_driver_register
> > > > - * @drv: platform driver structure
> > > > - */
> > > > -int platform_driver_register(struct platform_driver *drv)
> > > > +static int __platform_driver_register(struct platform_driver *drv)
> > > > {
> > > > drv->driver.bus = &platform_bus_type;
> > > > if (drv->probe)
> > > > @@ -489,6 +485,40 @@ int platform_driver_register(struct platform_driver *drv)
> > > >
> > > > return driver_register(&drv->driver);
> > > > }
> > > > +
> > > > +/**
> > > > + * platform_driver_register
> > > > + * @drv: platform driver structure
> > > > + */
> > > > +int platform_driver_register(struct platform_driver *drv)
> > > > +{
> > > > + int ret = __platform_driver_register(drv);
> > > > +
> > > > +#if defined(CONFIG_HOTPLUG)
> > > > + /*
> > > > + * drivers that are registered by platform_driver_register
> > > > + * should not have their probe function in .init.text. The
> > > > + * reason is that a probe can happen after .init.text is
> > > > + * discarded which then results in an oops. The alternatives
> > > > + * are using .devinit.text for the probe function or "register"
> > > > + * with platform_driver_probe.
> > > > + */
> > >
> > > That's not true, remember, drivers built into the system, like platform
> > > ones, can have their probe function in .init.text, as it will be called
> > > before we discard .init.text, and will never be called again as the
> > > device will never be "hot added" at any future time.
> > >
> > > So this could trigger a lot of false positives :(
> > IMHO this is not a false positive. You can still do
> >
> > for f in unbind bind do echo $deviceid > /sys/bus/platform/drivers/$drivername/$f; done
> >
> > This type of driver should use platform_driver_probe.
> Are you conviced and took the patch or did you give up to convince me?

Heh, no, sorry, it got burried in my queue.

> I still think the patch is correct and I'd like to have it applied.

Ok, let's test it out in the linux-next tree for a while to make sure it
works properly. Care to send me an updated version?

thanks,

greg k-h

2009-07-11 10:00:26

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hi Greg,

> > Are you conviced and took the patch or did you give up to convince me?
>
> Heh, no, sorry, it got burried in my queue.
>
> > I still think the patch is correct and I'd like to have it applied.
>
> Ok, let's test it out in the linux-next tree for a while to make sure it
> works properly. Care to send me an updated version?
I updated to latest Linus' master. It applies to linux-next from
Fri Jul 10 14:44:30 2009 +1000 as is.

Back some time I sent a series that fixes many of these bugs. I will
update it later today and resend.

Best regards and thanks,
Uwe

---->8----
From: Uwe Kleine-K?nig <[email protected]>
Subject: [PATCH] platform_driver_register: warn if probe is in .init.text

with HOTPLUG=y it's wrong to register a platform_driver whose probe
function lives in .init.text because the probe function can be called
(e.g. via sysfs or by registering a device late) after the init sections
are already discarded. This results in an oops.

So warn if such a driver is registered.

Without HOTPLUG the probe function can (and should) be discarded if the
driver is registered while the init sections are still available.
In this case warn if the probe function isn't discarded later. (As
described in the comments there is a small chance for a wrong warning.
But as HOTPLUG=n is unusual today and the situation is strage enough to
be cleaned up anyhow, I think this is OK.)

Signed-off-by: Uwe Kleine-K?nig <[email protected]>
---
drivers/base/platform.c | 42 ++++++++++++++++++++++++++++++++++++------
include/linux/kernel.h | 2 ++
include/linux/module.h | 12 ++++++++++++
kernel/extable.c | 12 ++++++++++++
kernel/module.c | 36 ++++++++++++++++++++++++++++++++++++
5 files changed, 98 insertions(+), 6 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 81cb01b..851ba84 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -470,11 +470,7 @@ static void platform_drv_shutdown(struct device *_dev)
drv->shutdown(dev);
}

-/**
- * platform_driver_register
- * @drv: platform driver structure
- */
-int platform_driver_register(struct platform_driver *drv)
+static int __platform_driver_register(struct platform_driver *drv)
{
drv->driver.bus = &platform_bus_type;
if (drv->probe)
@@ -489,6 +485,40 @@ int platform_driver_register(struct platform_driver *drv)

return driver_register(&drv->driver);
}
+
+/**
+ * platform_driver_register
+ * @drv: platform driver structure
+ */
+int platform_driver_register(struct platform_driver *drv)
+{
+ int ret = __platform_driver_register(drv);
+
+#if defined(CONFIG_HOTPLUG)
+ /*
+ * drivers that are registered by platform_driver_register
+ * should not have their probe function in .init.text. The
+ * reason is that a probe can happen after .init.text is
+ * discarded which then results in an oops. The alternatives
+ * are using .devinit.text for the probe function or "register"
+ * with platform_driver_probe.
+ */
+ if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
+ pr_warning("oops-warning: probe function of platform driver %s"
+ " lives in .init.text\n", drv->driver.name);
+#else
+ /*
+ * without HOTPLUG probe functions can be discarded after the driver is
+ * loaded.
+ * There is a little chance for false positives, namely if the driver is
+ * registered after the .init sections are discarded.
+ */
+ if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
+ pr_info("probably the probe function of platform driver %s can"
+ " be moved to .init.text\n", drv->driver.name);
+#endif
+ return ret;
+}
EXPORT_SYMBOL_GPL(platform_driver_register);

/**
@@ -525,7 +555,7 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv,

/* temporary section violation during probe() */
drv->probe = probe;
- retval = code = platform_driver_register(drv);
+ retval = code = __platform_driver_register(drv);

/* Fixup that section violation, being paranoid about code scanning
* the list of drivers in order to probe new devices. Check to see
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d6320a3..298e9bc 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -203,8 +203,10 @@ extern char *get_options(const char *str, int nints, int *ints);
extern unsigned long long memparse(const char *ptr, char **retptr);

extern int core_kernel_text(unsigned long addr);
+extern int core_kernel_init_text(unsigned long addr)
extern int __kernel_text_address(unsigned long addr);
extern int kernel_text_address(unsigned long addr);
+extern int kernel_init_text_address(unsigned long addr);
extern int func_ptr_is_kernel_text(void *ptr);

struct pid;
diff --git a/include/linux/module.h b/include/linux/module.h
index 098bdb7..93f47c4 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -385,9 +385,11 @@ static inline int module_is_live(struct module *mod)
}

struct module *__module_text_address(unsigned long addr);
+struct module *__module_init_text_address(unsigned long addr);
struct module *__module_address(unsigned long addr);
bool is_module_address(unsigned long addr);
bool is_module_text_address(unsigned long addr);
+bool is_module_init_text_address(unsigned long addr);

static inline int within_module_core(unsigned long addr, struct module *mod)
{
@@ -556,6 +558,11 @@ static inline struct module *__module_text_address(unsigned long addr)
return NULL;
}

+static inline struct module *__module_init_text_address(unsigned long addr)
+{
+ return NULL;
+}
+
static inline bool is_module_address(unsigned long addr)
{
return false;
@@ -566,6 +573,11 @@ static inline bool is_module_text_address(unsigned long addr)
return false;
}

+static inline bool is_module_init_text_address(unsigned long addr)
+{
+ return false;
+}
+
/* Get/put a kernel symbol (calls should be symmetric) */
#define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
#define symbol_put(x) do { } while(0)
diff --git a/kernel/extable.c b/kernel/extable.c
index 7f8f263..bfd7bda 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -66,6 +66,11 @@ int core_kernel_text(unsigned long addr)
addr <= (unsigned long)_etext)
return 1;

+ return core_kernel_init_text;
+}
+
+int core_kernel_init_text(unsigned long addr)
+{
if (system_state == SYSTEM_BOOTING &&
init_kernel_text(addr))
return 1;
@@ -98,6 +103,13 @@ int kernel_text_address(unsigned long addr)
return is_module_text_address(addr);
}

+int kernel_init_text_address(unsigned long addr)
+{
+ if (core_kernel_init_text(addr))
+ return 1;
+ return is_module_init_text_address(addr);
+}
+
/*
* On some architectures (PPC64, IA64) function pointers
* are actually only tokens to some data that then holds the
diff --git a/kernel/module.c b/kernel/module.c
index 0a04983..f1fbeb0 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2890,6 +2890,22 @@ bool is_module_text_address(unsigned long addr)
}

/*
+ * is_module_init_text_address - is this address inside a module's .init.text
+ * section?
+ * @addr: the address to check.
+ */
+bool is_module_init_text_address(unsigned long addr)
+{
+ bool ret;
+
+ preempt_disable();
+ ret = __module_init_text_address(addr) != NULL;
+ preempt_enable();
+
+ return ret;
+}
+
+/*
* __module_text_address - get the module whose code contains an address.
* @addr: the address.
*
@@ -2909,6 +2925,26 @@ struct module *__module_text_address(unsigned long addr)
}
EXPORT_SYMBOL_GPL(__module_text_address);

+/*
+ * __module_init_text_address - get the module whose .init.text contains an
+ * address.
+ * @addr: the address.
+ *
+ * Must be called with preempt disabled or module mutex held so that
+ * module doesn't get freed during this.
+ */
+struct module *__module_init_text_address(unsigned long addr)
+{
+ struct module *mod = __module_address(addr);
+ if (mod) {
+ /* Make sure it's within the .init.text section. */
+ if (!within(addr, mod->module_init, mod->init_text_size))
+ mod = NULL;
+ }
+ return mod;
+}
+EXPORT_SYMBOL_GPL(__module_init_text_address);
+
/* Don't grab lock, we're oopsing. */
void print_modules(void)
{
--
tg: (f00caa7..) t/platsection/warn_in_probe (depends on: linus/master)

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-11 17:24:31

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Sat, Jul 11, 2009 at 12:00:14PM +0200, Uwe Kleine-K?nig wrote:
> Hi Greg,
>
> > > Are you conviced and took the patch or did you give up to convince me?
> >
> > Heh, no, sorry, it got burried in my queue.
> >
> > > I still think the patch is correct and I'd like to have it applied.
> >
> > Ok, let's test it out in the linux-next tree for a while to make sure it
> > works properly. Care to send me an updated version?
> I updated to latest Linus' master. It applies to linux-next from
> Fri Jul 10 14:44:30 2009 +1000 as is.

Thanks, I'll apply it later today to my trees.

> Back some time I sent a series that fixes many of these bugs. I will
> update it later today and resend.

Thanks, that would be good to have, to keep the noise down for devices
we already know about.

thanks,

greg k-h

2009-07-11 19:01:40

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Sat, Jul 11, 2009 at 12:00:14PM +0200, Uwe Kleine-König wrote:
> Hi Greg,
>
> > > Are you conviced and took the patch or did you give up to convince me?
> >
> > Heh, no, sorry, it got burried in my queue.
> >
> > > I still think the patch is correct and I'd like to have it applied.
> >
> > Ok, let's test it out in the linux-next tree for a while to make sure it
> > works properly. Care to send me an updated version?
> I updated to latest Linus' master. It applies to linux-next from
> Fri Jul 10 14:44:30 2009 +1000 as is.
>
> Back some time I sent a series that fixes many of these bugs. I will
> update it later today and resend.
>
> Best regards and thanks,
> Uwe
>
> ---->8----
> From: Uwe Kleine-König <[email protected]>
> Subject: [PATCH] platform_driver_register: warn if probe is in .init.text
>
> with HOTPLUG=y it's wrong to register a platform_driver whose probe
> function lives in .init.text because the probe function can be called
> (e.g. via sysfs or by registering a device late) after the init sections
> are already discarded. This results in an oops.
>
> So warn if such a driver is registered.
>
> Without HOTPLUG the probe function can (and should) be discarded if the
> driver is registered while the init sections are still available.
> In this case warn if the probe function isn't discarded later. (As
> described in the comments there is a small chance for a wrong warning.
> But as HOTPLUG=n is unusual today and the situation is strage enough to
> be cleaned up anyhow, I think this is OK.)
>
> Signed-off-by: Uwe Kleine-König <[email protected]>

This code kills the build in very bad ways :(

So much so that the error messages scroll away, but it starts out with:

In file included from /home/gregkh/work/linux/gregkh-2.6/arch/x86/include/asm/percpu.h:45,
from /home/gregkh/work/linux/gregkh-2.6/arch/x86/include/asm/current.h:5,
from /home/gregkh/work/linux/gregkh-2.6/arch/x86/include/asm/processor.h:15,
from /home/gregkh/work/linux/gregkh-2.6/arch/x86/include/asm/atomic_32.h:6,
from /home/gregkh/work/linux/gregkh-2.6/arch/x86/include/asm/atomic.h:2,
from include/linux/crypto.h:20,
from arch/x86/kernel/asm-offsets_32.c:7,
from arch/x86/kernel/asm-offsets.c:2:
include/linux/kernel.h: In function ‘core_kernel_init_text’:
include/linux/kernel.h:207: error: storage class specified for parameter ‘__kernel_text_address’
include/linux/kernel.h:208: error: storage class specified for parameter ‘kernel_text_address’
include/linux/kernel.h:209: error: storage class specified for parameter ‘kernel_init_text_address’
include/linux/kernel.h:210: error: storage class specified for parameter ‘func_ptr_is_kernel_text’
include/linux/kernel.h:212: warning: empty declaration


Care to respin this?

thanks,

greg k-h

2009-07-11 20:46:41

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hello Greg,

On Sat, Jul 11, 2009 at 11:59:20AM -0700, Greg KH wrote:
> On Sat, Jul 11, 2009 at 12:00:14PM +0200, Uwe Kleine-K?nig wrote:
> > Hi Greg,
> >
> > > > Are you conviced and took the patch or did you give up to convince me?
> > >
> > > Heh, no, sorry, it got burried in my queue.
> > >
> > > > I still think the patch is correct and I'd like to have it applied.
> > >
> > > Ok, let's test it out in the linux-next tree for a while to make sure it
> > > works properly. Care to send me an updated version?
> > I updated to latest Linus' master. It applies to linux-next from
> > Fri Jul 10 14:44:30 2009 +1000 as is.
> >
> > Back some time I sent a series that fixes many of these bugs. I will
> > update it later today and resend.
> >
> > Best regards and thanks,
> > Uwe
> >
> > ---->8----
> > From: Uwe Kleine-K?nig <[email protected]>
> > Subject: [PATCH] platform_driver_register: warn if probe is in .init.text
> >
> > with HOTPLUG=y it's wrong to register a platform_driver whose probe
> > function lives in .init.text because the probe function can be called
> > (e.g. via sysfs or by registering a device late) after the init sections
> > are already discarded. This results in an oops.
> >
> > So warn if such a driver is registered.
> >
> > Without HOTPLUG the probe function can (and should) be discarded if the
> > driver is registered while the init sections are still available.
> > In this case warn if the probe function isn't discarded later. (As
> > described in the comments there is a small chance for a wrong warning.
> > But as HOTPLUG=n is unusual today and the situation is strage enough to
> > be cleaned up anyhow, I think this is OK.)
> >
> > Signed-off-by: Uwe Kleine-K?nig <[email protected]>
>
> This code kills the build in very bad ways :(
it's just a ; that didn't made it into the new version. Don't know why.

If you squash the patch below into the patch I sent it should work
again.

Sorry
Uwe

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 298e9bc..2d48087 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -203,7 +203,7 @@ extern char *get_options(const char *str, int nints, int *ints);
extern unsigned long long memparse(const char *ptr, char **retptr);

extern int core_kernel_text(unsigned long addr);
-extern int core_kernel_init_text(unsigned long addr)
+extern int core_kernel_init_text(unsigned long addr);
extern int __kernel_text_address(unsigned long addr);
extern int kernel_text_address(unsigned long addr);
extern int kernel_init_text_address(unsigned long addr);

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-11 20:53:37

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move cfag12864bfb's probe function to .devinit.text

A pointer to cfag12864bfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Miguel Ojeda <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Avuton Olrich <[email protected]>
Cc: Antonino Daplas <[email protected]>
---
drivers/auxdisplay/cfag12864bfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/auxdisplay/cfag12864bfb.c b/drivers/auxdisplay/cfag12864bfb.c
index fe3a865..b0ca5a4 100644
--- a/drivers/auxdisplay/cfag12864bfb.c
+++ b/drivers/auxdisplay/cfag12864bfb.c
@@ -81,7 +81,7 @@ static struct fb_ops cfag12864bfb_ops = {
.fb_mmap = cfag12864bfb_mmap,
};

-static int __init cfag12864bfb_probe(struct platform_device *device)
+static int __devinit cfag12864bfb_probe(struct platform_device *device)
{
int ret = -EINVAL;
struct fb_info *info = framebuffer_alloc(0, &device->dev);
--
1.6.3.1

2009-07-11 20:53:54

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move arcfb's probe function to .devinit.text

A pointer to arcfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/arcfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
index c343169..01554d6 100644
--- a/drivers/video/arcfb.c
+++ b/drivers/video/arcfb.c
@@ -504,7 +504,7 @@ static struct fb_ops arcfb_ops = {
.fb_ioctl = arcfb_ioctl,
};

-static int __init arcfb_probe(struct platform_device *dev)
+static int __devinit arcfb_probe(struct platform_device *dev)
{
struct fb_info *info;
int retval = -ENOMEM;
--
1.6.3.1

2009-07-11 20:54:13

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move am79c961's probe function to .devinit.text

A pointer to am79c961_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Roel Kluin <[email protected]>
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: Andrew Morton <[email protected]>
---
drivers/net/arm/am79c961a.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index 627bc75..51b19f2 100644
--- a/drivers/net/arm/am79c961a.c
+++ b/drivers/net/arm/am79c961a.c
@@ -680,7 +680,7 @@ static const struct net_device_ops am79c961_netdev_ops = {
#endif
};

-static int __init am79c961_probe(struct platform_device *pdev)
+static int __devinit am79c961_probe(struct platform_device *pdev)
{
struct resource *res;
struct net_device *dev;
--
1.6.3.1

2009-07-11 20:54:32

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move epson1355fb's probe function to .devinit.text

A pointer to epson1355fb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Russell King <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Roland Stigge <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
---
drivers/video/epson1355fb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/epson1355fb.c b/drivers/video/epson1355fb.c
index 2735b79..6d755bb 100644
--- a/drivers/video/epson1355fb.c
+++ b/drivers/video/epson1355fb.c
@@ -602,7 +602,7 @@ static int epson1355fb_remove(struct platform_device *dev)
return 0;
}

-int __init epson1355fb_probe(struct platform_device *dev)
+int __devinit epson1355fb_probe(struct platform_device *dev)
{
struct epson1355_par *default_par;
struct fb_info *info;
--
1.6.3.1

2009-07-11 20:54:46

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move leds-clevo-mail's probe function to .devinit.text

A pointer to clevo_mail_led_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Richard Purdie <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Márton Németh <[email protected]>
---
drivers/leds/leds-clevo-mail.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
index 1813c84..8ee83ce 100644
--- a/drivers/leds/leds-clevo-mail.c
+++ b/drivers/leds/leds-clevo-mail.c
@@ -145,7 +145,7 @@ static struct led_classdev clevo_mail_led = {
.flags = LED_CORE_SUSPENDRESUME,
};

-static int __init clevo_mail_led_probe(struct platform_device *pdev)
+static int __devinit clevo_mail_led_probe(struct platform_device *pdev)
{
return led_classdev_register(&pdev->dev, &clevo_mail_led);
}
--
1.6.3.1

2009-07-11 20:54:57

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move sh_mobile_lcdc_fb's probe function to .devinit.text

A pointer to sh_mobile_lcdc_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Magnus Damm <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/sh_mobile_lcdcfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index 8f24564..d2bfbde 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -733,7 +733,7 @@ static struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = {

static int sh_mobile_lcdc_remove(struct platform_device *pdev);

-static int __init sh_mobile_lcdc_probe(struct platform_device *pdev)
+static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
{
struct fb_info *info;
struct sh_mobile_lcdc_priv *priv;
--
1.6.3.1

2009-07-11 20:55:13

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move cobalt-lcd's probe function to .devinit.text

A pointer to cobalt_lcdfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Yoichi Yuasa <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Antonino Daplas <[email protected]>
Acked-by: Ralf Baechle <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/cobalt_lcdfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/cobalt_lcdfb.c b/drivers/video/cobalt_lcdfb.c
index 108b89e..5eb61b5 100644
--- a/drivers/video/cobalt_lcdfb.c
+++ b/drivers/video/cobalt_lcdfb.c
@@ -287,7 +287,7 @@ static struct fb_ops cobalt_lcd_fbops = {
.fb_cursor = cobalt_lcdfb_cursor,
};

-static int __init cobalt_lcdfb_probe(struct platform_device *dev)
+static int __devinit cobalt_lcdfb_probe(struct platform_device *dev)
{
struct fb_info *info;
struct resource *res;
--
1.6.3.1

2009-07-11 20:55:31

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move snirm_53c710's probe function to .devinit.text

A pointer to snirm710_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Kay Sievers <[email protected]>
Cc: David Brownell <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
---
drivers/scsi/sni_53c710.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/sni_53c710.c b/drivers/scsi/sni_53c710.c
index 37b3359..56cf0bb 100644
--- a/drivers/scsi/sni_53c710.c
+++ b/drivers/scsi/sni_53c710.c
@@ -64,7 +64,7 @@ static struct scsi_host_template snirm710_template = {
.module = THIS_MODULE,
};

-static int __init snirm710_probe(struct platform_device *dev)
+static int __devinit snirm710_probe(struct platform_device *dev)
{
unsigned long base;
struct NCR_700_Host_Parameters *hostdata;
--
1.6.3.1

2009-07-11 20:55:47

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move xtsonic's probe function to .devinit.text

A pointer to xtsonic_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/net/xtsonic.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/xtsonic.c b/drivers/net/xtsonic.c
index 5a4ad15..0c44135 100644
--- a/drivers/net/xtsonic.c
+++ b/drivers/net/xtsonic.c
@@ -239,7 +239,7 @@ out:
* Actually probing is superfluous but we're paranoid.
*/

-int __init xtsonic_probe(struct platform_device *pdev)
+int __devinit xtsonic_probe(struct platform_device *pdev)
{
struct net_device *dev;
struct sonic_local *lp;
--
1.6.3.1

2009-07-11 20:55:59

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move corgi-ssp's probe function to .devinit.text

A pointer to corgi_ssp_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (when having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Eric Miao <[email protected]>
Cc: Russell King <[email protected]>
Cc: Paul Sokolovsky <[email protected]>
Cc: Richard Purdie <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Andrew Morton <[email protected]>
---
arch/arm/mach-pxa/corgi_ssp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-pxa/corgi_ssp.c b/arch/arm/mach-pxa/corgi_ssp.c
index a5ee707..1d9bc11 100644
--- a/arch/arm/mach-pxa/corgi_ssp.c
+++ b/arch/arm/mach-pxa/corgi_ssp.c
@@ -204,7 +204,7 @@ void __init corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo)
ssp_machinfo = machinfo;
}

-static int __init corgi_ssp_probe(struct platform_device *dev)
+static int __devinit corgi_ssp_probe(struct platform_device *dev)
{
int ret;

--
1.6.3.1

2009-07-11 20:56:13

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move acornfb's probe function to .devinit.text

A pointer to acornfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: [email protected]
Cc: Andrew Morton <[email protected]>
---
drivers/video/acornfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c
index 0bcc59e..43d7d50 100644
--- a/drivers/video/acornfb.c
+++ b/drivers/video/acornfb.c
@@ -1221,7 +1221,7 @@ free_unused_pages(unsigned int virtual_start, unsigned int virtual_end)
printk("acornfb: freed %dK memory\n", mb_freed);
}

-static int __init acornfb_probe(struct platform_device *dev)
+static int __devinit acornfb_probe(struct platform_device *dev)
{
unsigned long size;
u_int h_sync, v_sync;
--
1.6.3.1

2009-07-11 20:56:32

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move jornada_ssp's probe function to .devinit.text

A pointer to jornada_ssp_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Kristoffer Ericson <[email protected]>
Cc: Russell King <[email protected]>
Cc: Andrew Morton <[email protected]>
---
arch/arm/mach-sa1100/jornada720_ssp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-sa1100/jornada720_ssp.c b/arch/arm/mach-sa1100/jornada720_ssp.c
index 506a5e5..9b6dee5 100644
--- a/arch/arm/mach-sa1100/jornada720_ssp.c
+++ b/arch/arm/mach-sa1100/jornada720_ssp.c
@@ -130,7 +130,7 @@ void jornada_ssp_end(void)
};
EXPORT_SYMBOL(jornada_ssp_end);

-static int __init jornada_ssp_probe(struct platform_device *dev)
+static int __devinit jornada_ssp_probe(struct platform_device *dev)
{
int ret;

--
1.6.3.1

2009-07-11 20:56:45

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move vfb's probe function to .devinit.text

A pointer to vfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Frans Pop <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/vfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/vfb.c b/drivers/video/vfb.c
index 050d432..b8ab995 100644
--- a/drivers/video/vfb.c
+++ b/drivers/video/vfb.c
@@ -479,7 +479,7 @@ static int __init vfb_setup(char *options)
* Initialisation
*/

-static int __init vfb_probe(struct platform_device *dev)
+static int __devinit vfb_probe(struct platform_device *dev)
{
struct fb_info *info;
int retval = -ENOMEM;
--
1.6.3.1

2009-07-11 20:56:57

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move w100fb's probe function to .devinit.text

A pointer to w100fb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Philipp Zabel <[email protected]>
Cc: Ian Molton <[email protected]>
Cc: Richard Purdie <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Alberto Mardegan <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/w100fb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
index 2376f68..5d22395 100644
--- a/drivers/video/w100fb.c
+++ b/drivers/video/w100fb.c
@@ -628,7 +628,7 @@ static int w100fb_resume(struct platform_device *dev)
#endif


-int __init w100fb_probe(struct platform_device *pdev)
+int __devinit w100fb_probe(struct platform_device *pdev)
{
int err = -EIO;
struct w100fb_mach_info *inf;
--
1.6.3.1

2009-07-11 20:57:17

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move efifb's probe function to .devinit.text

A pointer to efifb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Peter Jones <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Jaya Kumar <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Maciej W. Rozycki <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Chandramouli Narayanan <[email protected]>
Cc: Huang Ying <[email protected]>
---
drivers/video/efifb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
index eb12182..2161f21 100644
--- a/drivers/video/efifb.c
+++ b/drivers/video/efifb.c
@@ -201,7 +201,7 @@ static int __init efifb_setup(char *options)
return 0;
}

-static int __init efifb_probe(struct platform_device *dev)
+static int __devinit efifb_probe(struct platform_device *dev)
{
struct fb_info *info;
int err;
--
1.6.3.1

2009-07-11 20:57:30

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move orion_nand's probe function to .devinit.text

A pointer to orion_nand_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Lennert Buytenhek <[email protected]>
Cc: Saeed Bishara <[email protected]>
Cc: Jörn Engel <[email protected]>
Cc: Nicolas Pitre <[email protected]>
Cc: Tzachi Perelstein <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/mtd/nand/orion_nand.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 7ad9722..748112c 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -69,7 +69,7 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
buf[i++] = readb(io_base);
}

-static int __init orion_nand_probe(struct platform_device *pdev)
+static int __devinit orion_nand_probe(struct platform_device *pdev)
{
struct mtd_info *mtd;
struct nand_chip *nc;
--
1.6.3.1

2009-07-11 20:57:42

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move s3c241xfb's probe function to .devinit.text

Pointers to s3c2410fb_probe and s3c2412fb_probe are passed to the core
via platform_driver_register and so the functions must not disappear
when the .init sections are discarded. Otherwise (if also having
HOTPLUG=y) unbinding and binding a device to one of the drivers via
sysfs will result in an oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Russell King <[email protected]>
Cc: Ben Dooks <[email protected]>
Cc: Arnaud Patard <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Vincent Sanders <[email protected]>
---
drivers/video/s3c2410fb.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c
index 7da0027..b8269bd 100644
--- a/drivers/video/s3c2410fb.c
+++ b/drivers/video/s3c2410fb.c
@@ -1002,12 +1002,12 @@ dealloc_fb:
return ret;
}

-static int __init s3c2410fb_probe(struct platform_device *pdev)
+static int __devinit s3c2410fb_probe(struct platform_device *pdev)
{
return s3c24xxfb_probe(pdev, DRV_S3C2410);
}

-static int __init s3c2412fb_probe(struct platform_device *pdev)
+static int __devinit s3c2412fb_probe(struct platform_device *pdev)
{
return s3c24xxfb_probe(pdev, DRV_S3C2412);
}
--
1.6.3.1

2009-07-11 20:57:55

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move gbefb's probe function to .devinit.text

A pointer to gbefb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Roel Kluin <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Kaj-Michael Lang <[email protected]>
Cc: Martin Michlmayr <[email protected]>
Cc: Joshua Kinard <[email protected]>
---
drivers/video/gbefb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/gbefb.c b/drivers/video/gbefb.c
index 1a83709..f30e6b7 100644
--- a/drivers/video/gbefb.c
+++ b/drivers/video/gbefb.c
@@ -1128,7 +1128,7 @@ static int __init gbefb_setup(char *options)
return 0;
}

-static int __init gbefb_probe(struct platform_device *p_dev)
+static int __devinit gbefb_probe(struct platform_device *p_dev)
{
int i, ret = 0;
struct fb_info *info;
--
1.6.3.1

2009-07-11 20:58:15

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move hp-wmi's probe function to .devinit.text

A pointer to hp_wmi_bios_setup is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Frans Pop <[email protected]>
Cc: Larry Finger <[email protected]>
Cc: Len Brown <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: Matthew Garrett <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/platform/x86/hp-wmi.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index ca50856..f1f7090 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -51,7 +51,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
#define HPWMI_WIRELESS_QUERY 0x5
#define HPWMI_HOTKEY_QUERY 0xc

-static int __init hp_wmi_bios_setup(struct platform_device *device);
+static int __devinit hp_wmi_bios_setup(struct platform_device *device);
static int __exit hp_wmi_bios_remove(struct platform_device *device);
static int hp_wmi_resume_handler(struct platform_device *device);

@@ -425,7 +425,7 @@ static void cleanup_sysfs(struct platform_device *device)
device_remove_file(&device->dev, &dev_attr_tablet);
}

-static int __init hp_wmi_bios_setup(struct platform_device *device)
+static int __devinit hp_wmi_bios_setup(struct platform_device *device)
{
int err;
int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
--
1.6.3.1

2009-07-11 20:58:30

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move sgiseeq's probe function to .devinit.text

A pointer to sgiseeq_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Wang Chen <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Jeff Garzik <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Acked-by: Ralf Baechle <[email protected]>
---
drivers/net/sgiseeq.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
index 5fb88ca..53fa4f6 100644
--- a/drivers/net/sgiseeq.c
+++ b/drivers/net/sgiseeq.c
@@ -720,7 +720,7 @@ static const struct net_device_ops sgiseeq_netdev_ops = {
.ndo_validate_addr = eth_validate_addr,
};

-static int __init sgiseeq_probe(struct platform_device *pdev)
+static int __devinit sgiseeq_probe(struct platform_device *pdev)
{
struct sgiseeq_platform_data *pd = pdev->dev.platform_data;
struct hpc3_regs *hpcregs = pd->hpc;
--
1.6.3.1

2009-07-11 20:58:41

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move sharpsl-pm's probe function to .devinit.text

A pointer to sharpsl_pm_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Dmitry Baryshkov <[email protected]>
Cc: Russell King <[email protected]>
Acked-by: Eric Miao <[email protected]>
Cc: Andrew Morton <[email protected]>
---
arch/arm/mach-pxa/sharpsl_pm.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c
index 2546c06..16a3873 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.c
+++ b/arch/arm/mach-pxa/sharpsl_pm.c
@@ -899,7 +899,7 @@ static struct platform_suspend_ops sharpsl_pm_ops = {
};
#endif

-static int __init sharpsl_pm_probe(struct platform_device *pdev)
+static int __devinit sharpsl_pm_probe(struct platform_device *pdev)
{
int ret;

--
1.6.3.1

2009-07-11 20:58:54

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move q40fb's probe function to .devinit.text

A pointer to q40fb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/q40fb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/q40fb.c b/drivers/video/q40fb.c
index 4beac1d..de40a62 100644
--- a/drivers/video/q40fb.c
+++ b/drivers/video/q40fb.c
@@ -85,7 +85,7 @@ static struct fb_ops q40fb_ops = {
.fb_imageblit = cfb_imageblit,
};

-static int __init q40fb_probe(struct platform_device *dev)
+static int __devinit q40fb_probe(struct platform_device *dev)
{
struct fb_info *info;

--
1.6.3.1

2009-07-11 20:59:38

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move vga16fb's probe function to .devinit.text

A pointer to vga16fb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Roel Kluin <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/vga16fb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c
index 5b29389..76d8dae 100644
--- a/drivers/video/vga16fb.c
+++ b/drivers/video/vga16fb.c
@@ -1293,7 +1293,7 @@ static int vga16fb_setup(char *options)
}
#endif

-static int __init vga16fb_probe(struct platform_device *dev)
+static int __devinit vga16fb_probe(struct platform_device *dev)
{
struct fb_info *info;
struct vga16fb_par *par;
--
1.6.3.1

2009-07-11 20:59:27

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move macsonic's probe function to .devinit.text

A pointer to mac_sonic_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

Various other functions that are called by mac_sonic_probe need to move
to .devinit.text, too.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Jeff Garzik <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: Finn Thain <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/net/macsonic.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c
index acd143d..8f492c7 100644
--- a/drivers/net/macsonic.c
+++ b/drivers/net/macsonic.c
@@ -179,7 +179,7 @@ static const struct net_device_ops macsonic_netdev_ops = {
.ndo_set_mac_address = eth_mac_addr,
};

-static int __init macsonic_init(struct net_device *dev)
+static int __devinit macsonic_init(struct net_device *dev)
{
struct sonic_local* lp = netdev_priv(dev);

@@ -223,7 +223,7 @@ static int __init macsonic_init(struct net_device *dev)
return 0;
}

-static int __init mac_onboard_sonic_ethernet_addr(struct net_device *dev)
+static int __devinit mac_onboard_sonic_ethernet_addr(struct net_device *dev)
{
struct sonic_local *lp = netdev_priv(dev);
const int prom_addr = ONBOARD_SONIC_PROM_BASE;
@@ -288,7 +288,7 @@ static int __init mac_onboard_sonic_ethernet_addr(struct net_device *dev)
} else return 0;
}

-static int __init mac_onboard_sonic_probe(struct net_device *dev)
+static int __devinit mac_onboard_sonic_probe(struct net_device *dev)
{
/* Bwahahaha */
static int once_is_more_than_enough;
@@ -409,7 +409,7 @@ static int __init mac_onboard_sonic_probe(struct net_device *dev)
return macsonic_init(dev);
}

-static int __init mac_nubus_sonic_ethernet_addr(struct net_device *dev,
+static int __devinit mac_nubus_sonic_ethernet_addr(struct net_device *dev,
unsigned long prom_addr,
int id)
{
@@ -424,7 +424,7 @@ static int __init mac_nubus_sonic_ethernet_addr(struct net_device *dev,
return 0;
}

-static int __init macsonic_ident(struct nubus_dev *ndev)
+static int __devinit macsonic_ident(struct nubus_dev *ndev)
{
if (ndev->dr_hw == NUBUS_DRHW_ASANTE_LC &&
ndev->dr_sw == NUBUS_DRSW_SONIC_LC)
@@ -449,7 +449,7 @@ static int __init macsonic_ident(struct nubus_dev *ndev)
return -1;
}

-static int __init mac_nubus_sonic_probe(struct net_device *dev)
+static int __devinit mac_nubus_sonic_probe(struct net_device *dev)
{
static int slots;
struct nubus_dev* ndev = NULL;
@@ -562,7 +562,7 @@ static int __init mac_nubus_sonic_probe(struct net_device *dev)
return macsonic_init(dev);
}

-static int __init mac_sonic_probe(struct platform_device *pdev)
+static int __devinit mac_sonic_probe(struct platform_device *pdev)
{
struct net_device *dev;
struct sonic_local *lp;
--
1.6.3.1

2009-07-11 20:59:50

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move hitfb's probe function to .devinit.text

A pointer to hitfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Andriy Skulysh <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/hitfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c
index e7116a6..3016cd2 100644
--- a/drivers/video/hitfb.c
+++ b/drivers/video/hitfb.c
@@ -325,7 +325,7 @@ static struct fb_ops hitfb_ops = {
.fb_imageblit = cfb_imageblit,
};

-static int __init hitfb_probe(struct platform_device *dev)
+static int __devinit hitfb_probe(struct platform_device *dev)
{
unsigned short lcdclor, ldr3, ldvndr;
struct fb_info *info;
--
1.6.3.1

2009-07-11 20:59:10

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move sa11x0-fb's probe function to .devinit.text

A pointer to sa1100fb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Russell King <[email protected]>
Cc: Matthias Kaehlcke <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Pavel Machek <[email protected]>
Cc: Christoph Hellwig <[email protected]>
---
drivers/video/sa1100fb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c
index 10ddad8..19c012b 100644
--- a/drivers/video/sa1100fb.c
+++ b/drivers/video/sa1100fb.c
@@ -1435,7 +1435,7 @@ static struct sa1100fb_info * __init sa1100fb_init_fbinfo(struct device *dev)
return fbi;
}

-static int __init sa1100fb_probe(struct platform_device *pdev)
+static int __devinit sa1100fb_probe(struct platform_device *pdev)
{
struct sa1100fb_info *fbi;
int ret, irq;
--
1.6.3.1

2009-07-11 21:00:24

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move sh_flctl's probe function to .devinit.text

A pointer to flctl_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Yoshihiro Shimoda <[email protected]>
Cc: David Woodhouse <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/mtd/nand/sh_flctl.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index 2bc8966..1898423 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -769,7 +769,7 @@ static int flctl_chip_init_tail(struct mtd_info *mtd)
return 0;
}

-static int __init flctl_probe(struct platform_device *pdev)
+static int __devinit flctl_probe(struct platform_device *pdev)
{
struct resource *res;
struct sh_flctl *flctl;
--
1.6.3.1

2009-07-11 21:00:04

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move hgafb's probe function to .devinit.text

A pointer to hgafb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Anton Vorontsov <[email protected]>
Cc: Antonino Daplas <[email protected]>
---
drivers/video/hgafb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/hgafb.c b/drivers/video/hgafb.c
index 0129c04..db9b785 100644
--- a/drivers/video/hgafb.c
+++ b/drivers/video/hgafb.c
@@ -551,7 +551,7 @@ static struct fb_ops hgafb_ops = {
* Initialization
*/

-static int __init hgafb_probe(struct platform_device *pdev)
+static int __devinit hgafb_probe(struct platform_device *pdev)
{
struct fb_info *info;

--
1.6.3.1

2009-07-11 21:00:43

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move hp680-bl's probe function to .devinit.text

A pointer to hp680bl_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Akinobu Mita <[email protected]>
Cc: Richard Purdie <[email protected]>
Cc: Paul Mundt <[email protected]>
Acked-by: Kristoffer Ericson <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andriy Skulysh <[email protected]>
Cc: Antonino Daplas <[email protected]>
---
drivers/video/backlight/hp680_bl.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index 5be55a2..7fb4eef 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -103,7 +103,7 @@ static struct backlight_ops hp680bl_ops = {
.update_status = hp680bl_set_intensity,
};

-static int __init hp680bl_probe(struct platform_device *pdev)
+static int __devinit hp680bl_probe(struct platform_device *pdev)
{
struct backlight_device *bd;

--
1.6.3.1

2009-07-11 21:00:54

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move meth's probe function to .devinit.text

A pointer to meth_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Jeff Garzik <[email protected]>
Acked-by: Ralf Baechle <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/net/meth.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index 5d04d94..0dddb02 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -784,7 +784,7 @@ static const struct net_device_ops meth_netdev_ops = {
/*
* The init function.
*/
-static int __init meth_probe(struct platform_device *pdev)
+static int __devinit meth_probe(struct platform_device *pdev)
{
struct net_device *dev;
struct meth_private *priv;
--
1.6.3.1

2009-07-11 21:01:15

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move omap24xxcam's probe function to .devinit.text

A pointer to omap24xxcam_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Sakari Ailus <[email protected]>
Acked-by: Trilok Soni <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/media/video/omap24xxcam.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/omap24xxcam.c b/drivers/media/video/omap24xxcam.c
index 5fc4ac0..3fc84b7 100644
--- a/drivers/media/video/omap24xxcam.c
+++ b/drivers/media/video/omap24xxcam.c
@@ -1737,7 +1737,7 @@ static struct v4l2_int_device omap24xxcam = {
*
*/

-static int __init omap24xxcam_probe(struct platform_device *pdev)
+static int __devinit omap24xxcam_probe(struct platform_device *pdev)
{
struct omap24xxcam_device *cam;
struct resource *mem;
--
1.6.3.1

2009-07-11 21:01:27

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move omap_udc's probe function to .devinit.text

A pointer to omap_udc_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Philipp Zabel <[email protected]>
Cc: David Brownell <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Tony Lindgren <[email protected]>
Cc: Russell King <[email protected]>
Cc: Dmitry Baryshkov <[email protected]>
---
drivers/usb/gadget/omap_udc.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index a2db0e1..351cb24 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2800,7 +2800,7 @@ omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv)
return 0;
}

-static int __init omap_udc_probe(struct platform_device *pdev)
+static int __devinit omap_udc_probe(struct platform_device *pdev)
{
int status = -ENODEV;
int hmc;
--
1.6.3.1

2009-07-11 21:01:40

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move at91_ether's probe function to .devinit.text

A pointer to at91ether_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: David Brownell <[email protected]>
Cc: Jeff Garzik <[email protected]>
Cc: Paulius Zaleckas <[email protected]>
Cc: Marc Pignat <[email protected]>
Cc: Andrew Victor <[email protected]>
Cc: Roel Kluin <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/net/arm/at91_ether.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index 2e7419a..0c8860e 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -1119,7 +1119,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
/*
* Detect MAC and PHY and perform initialization
*/
-static int __init at91ether_probe(struct platform_device *pdev)
+static int __devinit at91ether_probe(struct platform_device *pdev)
{
unsigned int phyid1, phyid2;
int detected = -1;
--
1.6.3.1

2009-07-11 21:01:52

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move mmci-omap-hs's probe function to .devinit.text

A pointer to omap_mmc_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Jean Pihet <[email protected]>
Cc: Tony Lindgren <[email protected]>
Cc: Pierre Ossman <[email protected]>
Cc: Andy Lowe <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: David Brownell <[email protected]>
Cc: Madhusudhan Chikkature<[email protected]>
---
drivers/mmc/host/omap_hsmmc.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 1cf9cfb..dc9a430 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -967,7 +967,7 @@ static struct mmc_host_ops mmc_omap_ops = {
/* NYET -- enable_sdio_irq */
};

-static int __init omap_mmc_probe(struct platform_device *pdev)
+static int __devinit omap_mmc_probe(struct platform_device *pdev)
{
struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;
struct mmc_host *mmc;
--
1.6.3.1

2009-07-11 21:02:09

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move i2c_omap's probe function to .devinit.text

A pointer to omap_i2c_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Kalle Jokiniemi <[email protected]>
Cc: Tony Lindgren <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Richard Woodruff <[email protected]>
Cc: chandra shekhar <[email protected]>
Cc: Jason P Marini <[email protected]>
Cc: Syed Mohammed Khasim <[email protected]>
Cc: Jarkko Nikula <[email protected]>
Cc: Juha Yrjola <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/i2c/busses/i2c-omap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index ad8d201..1ae5ae4 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -784,7 +784,7 @@ static const struct i2c_algorithm omap_i2c_algo = {
.functionality = omap_i2c_func,
};

-static int __init
+static int __devinit
omap_i2c_probe(struct platform_device *pdev)
{
struct omap_i2c_dev *dev;
--
1.6.3.1

2009-07-11 21:02:28

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move stk17ta8's probe function to .devinit.text

A pointer to stk17ta8_rtc_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Anton Vorontsov <[email protected]>
Cc: Alessandro Zummo <[email protected]>
Cc: David Brownell <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Hannes Eder <[email protected]>
Cc: Jiri Kosina <[email protected]>
Cc: David Brownell <[email protected]>
---
drivers/rtc/rtc-stk17ta8.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index 7d1547b..d491eb2 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -286,7 +286,7 @@ static struct bin_attribute stk17ta8_nvram_attr = {
.write = stk17ta8_nvram_write,
};

-static int __init stk17ta8_rtc_probe(struct platform_device *pdev)
+static int __devinit stk17ta8_rtc_probe(struct platform_device *pdev)
{
struct rtc_device *rtc;
struct resource *res;
--
1.6.3.1

2009-07-11 21:02:40

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move vesafb's probe function to .devinit.text

A pointer to vesafb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: James Simmons <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Antonino Daplas <[email protected]>
---
drivers/video/vesafb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
index bd37ee1..ef4128c 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -226,7 +226,7 @@ static int __init vesafb_setup(char *options)
return 0;
}

-static int __init vesafb_probe(struct platform_device *dev)
+static int __devinit vesafb_probe(struct platform_device *dev)
{
struct fb_info *info;
int i, err;
--
1.6.3.1

2009-07-11 21:02:52

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move sgiwd93's probe function to .devinit.text

A pointer to sgiwd93_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Dmitri Vorobiev <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Acked-by: Ralf Baechle <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: peter fuerst <[email protected]>
Cc: Henrik Kretzschmar <[email protected]>
---
drivers/scsi/sgiwd93.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c
index 0807b26..fef0e3c 100644
--- a/drivers/scsi/sgiwd93.c
+++ b/drivers/scsi/sgiwd93.c
@@ -226,7 +226,7 @@ static struct scsi_host_template sgiwd93_template = {
.use_clustering = DISABLE_CLUSTERING,
};

-static int __init sgiwd93_probe(struct platform_device *pdev)
+static int __devinit sgiwd93_probe(struct platform_device *pdev)
{
struct sgiwd93_platform_data *pd = pdev->dev.platform_data;
unsigned char *wdregs = pd->wdregs;
--
1.6.3.1

2009-07-11 21:03:11

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move sgivwfb's probe function to .devinit.text

A pointer to sgivwfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Adrian Bunk <[email protected]>
Cc: Christoph Hellwig <[email protected]>
---
drivers/video/sgivwfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/sgivwfb.c b/drivers/video/sgivwfb.c
index bba5371..aff893e 100644
--- a/drivers/video/sgivwfb.c
+++ b/drivers/video/sgivwfb.c
@@ -745,7 +745,7 @@ int __init sgivwfb_setup(char *options)
/*
* Initialisation
*/
-static int __init sgivwfb_probe(struct platform_device *dev)
+static int __devinit sgivwfb_probe(struct platform_device *dev)
{
struct sgivw_par *par;
struct fb_info *info;
--
1.6.3.1

2009-07-11 21:03:27

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move omap_hdq's probe function to .devinit.text

A pointer to omap_hdq_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Stanley.Miao <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Madhusudhan Chikkature <[email protected]>
Cc: Felipe Balbi <[email protected]>
---
drivers/w1/masters/omap_hdq.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
index a7e3b70..ac09735 100644
--- a/drivers/w1/masters/omap_hdq.c
+++ b/drivers/w1/masters/omap_hdq.c
@@ -72,7 +72,7 @@ struct hdq_data {
int init_trans;
};

-static int __init omap_hdq_probe(struct platform_device *pdev);
+static int __devinit omap_hdq_probe(struct platform_device *pdev);
static int omap_hdq_remove(struct platform_device *pdev);

static struct platform_driver omap_hdq_driver = {
@@ -558,7 +558,7 @@ static void omap_w1_write_byte(void *_hdq, u8 byte)
return;
}

-static int __init omap_hdq_probe(struct platform_device *pdev)
+static int __devinit omap_hdq_probe(struct platform_device *pdev)
{
struct hdq_data *hdq_data;
struct resource *res;
--
1.6.3.1

2009-07-11 21:03:39

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move jazzsonic's probe function to .devinit.text

A pointer to jazz_sonic_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

As noticed by Geert Uytterhoeven sonic_probe1 is called by
jazz_sonic_probe, so the former has to move to .devinit.text, too.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Ralf Baechle <[email protected]>
Cc: Jeff Garzik <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: Finn Thain <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/net/jazzsonic.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index d12106b..8baf595 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -108,7 +108,7 @@ static const struct net_device_ops sonic_netdev_ops = {
.ndo_set_mac_address = eth_mac_addr,
};

-static int __init sonic_probe1(struct net_device *dev)
+static int __devinit sonic_probe1(struct net_device *dev)
{
static unsigned version_printed;
unsigned int silicon_revision;
@@ -211,7 +211,7 @@ out:
* Probe for a SONIC ethernet controller on a Mips Jazz board.
* Actually probing is superfluous but we're paranoid.
*/
-static int __init jazz_sonic_probe(struct platform_device *pdev)
+static int __devinit jazz_sonic_probe(struct platform_device *pdev)
{
struct net_device *dev;
struct sonic_local *lp;
--
1.6.3.1

2009-07-11 21:03:52

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move sb1250-mac's probe function to .devinit.text

A pointer to sbmac_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Weiwei Wang <[email protected]>
Cc: Jeff Garzik <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: Stephen Hemminger <[email protected]>
Cc: Maciej W. Rozycki <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/net/sb1250-mac.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index d8c9cf1..96b37b9 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -2688,7 +2688,7 @@ static int sbmac_poll(struct napi_struct *napi, int budget)
}


-static int __init sbmac_probe(struct platform_device *pldev)
+static int __devinit sbmac_probe(struct platform_device *pldev)
{
struct net_device *dev;
struct sbmac_softc *sc;
--
1.6.3.1

2009-07-11 21:04:08

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] move h1940-bt's probe function to .devinit.text

A pointer to h1940bt_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnaud Patard <[email protected]>
Cc: Ben Dooks <[email protected]>
Cc: Andrew Morton <[email protected]>
---
arch/arm/mach-s3c2410/h1940-bluetooth.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-s3c2410/h1940-bluetooth.c b/arch/arm/mach-s3c2410/h1940-bluetooth.c
index 5aabf11..194c2eb 100644
--- a/arch/arm/mach-s3c2410/h1940-bluetooth.c
+++ b/arch/arm/mach-s3c2410/h1940-bluetooth.c
@@ -86,7 +86,7 @@ static DEVICE_ATTR(enable, 0644,
h1940bt_show,
h1940bt_store);

-static int __init h1940bt_probe(struct platform_device *pdev)
+static int __devinit h1940bt_probe(struct platform_device *pdev)
{
/* Configures BT serial port GPIOs */
s3c2410_gpio_cfgpin(S3C2410_GPH(0), S3C2410_GPH0_nCTS0);
--
1.6.3.1

2009-07-11 22:26:25

by Ian molton

[permalink] [raw]
Subject: Re: [PATCH] move w100fb's probe function to .devinit.text


Acked-by: Ian Molton <[email protected]>

Uwe Kleine-König wrote:
> A pointer to w100fb_probe is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.
>
> Signed-off-by: Uwe Kleine-König <[email protected]>
> Cc: Philipp Zabel <[email protected]>
> Cc: Ian Molton <[email protected]>
> Cc: Richard Purdie <[email protected]>
> Cc: Antonino Daplas <[email protected]>
> Cc: Alberto Mardegan <[email protected]>
> Cc: Andrew Morton <[email protected]>
> ---
> drivers/video/w100fb.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
> index 2376f68..5d22395 100644
> --- a/drivers/video/w100fb.c
> +++ b/drivers/video/w100fb.c
> @@ -628,7 +628,7 @@ static int w100fb_resume(struct platform_device *dev)
> #endif
>
>
> -int __init w100fb_probe(struct platform_device *pdev)
> +int __devinit w100fb_probe(struct platform_device *pdev)
> {
> int err = -EIO;
> struct w100fb_mach_info *inf;

2009-07-11 22:27:56

by David Brownell

[permalink] [raw]
Subject: Re: [PATCH] move at91_ether's probe function to .devinit.text

On Saturday 11 July 2009, Uwe Kleine-K?nig wrote:
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.

And that's the preferred fix I was expecting to see.

NAK on this version.

2009-07-11 22:29:30

by David Brownell

[permalink] [raw]
Subject: Re: [PATCH] move mmci-omap-hs's probe function to .devinit.text

On Saturday 11 July 2009, Uwe Kleine-K?nig wrote:
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.

And that's the preferred fix ... NAK on this one.

In fact its quite rare for any SoC device to be hotpluggable,
so your default stance in such cases should be to switch over
to platform_driver_probe() instead of doing like this.

2009-07-11 22:30:54

by David Brownell

[permalink] [raw]
Subject: Re: [PATCH] move omap_udc's probe function to .devinit.text

On Saturday 11 July 2009, Uwe Kleine-K?nig wrote:
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.

Repeat -- NAK on this. Use platform_driver_probe() instead.

I really don't like this series of patches. It's just adding
bloat to kernels, in chunks of up to a page per patch.

2009-07-12 00:37:12

by Maciej W. Rozycki

[permalink] [raw]
Subject: Re: [PATCH] move sb1250-mac's probe function to .devinit.text

On Sat, 11 Jul 2009, Uwe Kleine-K?nig wrote:

> A pointer to sbmac_probe is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.
>
> Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> Cc: Weiwei Wang <[email protected]>
> Cc: Jeff Garzik <[email protected]>
> Cc: David S. Miller <[email protected]>
> Cc: Stephen Hemminger <[email protected]>
> Cc: Maciej W. Rozycki <[email protected]>
> Cc: Andrew Morton <[email protected]>
> ---
> drivers/net/sb1250-mac.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)

Acked-by: Maciej W. Rozycki <[email protected]>

Fine by me, thanks.

Maciej

2009-07-12 08:35:28

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] move omap_udc's probe function to .devinit.text

Hello David,

On Sat, Jul 11, 2009 at 03:30:44PM -0700, David Brownell wrote:
> On Saturday 11 July 2009, Uwe Kleine-K?nig wrote:
> > An alternative to this patch is using platform_driver_probe instead of
> > platform_driver_register plus removing the pointer to the probe function
> > from the struct platform_driver.
>
> Repeat -- NAK on this. Use platform_driver_probe() instead.
>
> I really don't like this series of patches. It's just adding
> bloat to kernels, in chunks of up to a page per patch.
I'm aware that in some cases platform_driver_probe is better. But as I
don't have access to most of the affected platforms I consider it saver.
That's why I choosed this way. The problem with platform_driver_probe
is that if a device is added only after the driver is probed the
device isn't bound.

So if you say you can test it, it's totally OK for me to go the other
way.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-12 08:48:41

by Russell King

[permalink] [raw]
Subject: Re: [PATCH] move omap_udc's probe function to .devinit.text

On Sun, Jul 12, 2009 at 10:35:10AM +0200, Uwe Kleine-K?nig wrote:
> Hello David,
>
> On Sat, Jul 11, 2009 at 03:30:44PM -0700, David Brownell wrote:
> > On Saturday 11 July 2009, Uwe Kleine-K?nig wrote:
> > > An alternative to this patch is using platform_driver_probe instead of
> > > platform_driver_register plus removing the pointer to the probe function
> > > from the struct platform_driver.
> >
> > Repeat -- NAK on this. Use platform_driver_probe() instead.
> >
> > I really don't like this series of patches. It's just adding
> > bloat to kernels, in chunks of up to a page per patch.
> I'm aware that in some cases platform_driver_probe is better. But as I
> don't have access to most of the affected platforms I consider it saver.
> That's why I choosed this way. The problem with platform_driver_probe
> is that if a device is added only after the driver is probed the
> device isn't bound.

Your approach is perfectly fine, and safe. You're not adding any
additional bloat which isn't already there. If it were adding any
bloat (which it isn't), it certainly is not "in chunks of up to a
page per patch".

Overall, this patch is an improvement, so all these get my ack, and
they should be applied as is.

Using platform_driver_probe() does allow you to reduce the kernel
footprint still further, but that requires knowledge of the platforms
affected (knowing that the platform devices are present before the
drivers get probed.)

I'll apply the ones for drivers I look after later today.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of:

2009-07-12 09:30:48

by David Brownell

[permalink] [raw]
Subject: Re: [PATCH] move omap_udc's probe function to .devinit.text

On Sunday 12 July 2009, Russell King wrote:
> Your approach is perfectly fine, and safe. ?You're not adding any
> additional bloat which isn't already there.

He is most certainly increasing the runtime footprint needessly.
Runtime footprint which previously was *NOT* present.

That's known as "bloat".

And also known as "adding".


> If it were adding any
> bloat (which it isn't), it certainly is not "in chunks of up to a
> page per patch".

Oddly, the init section of the $SUBJECT driver is about 3600 bytes.
That's what ... almost a (4K) page, wouldn't you say?

It's got a lot of one-time hardware init that was explicitly pushed
into the init section so it would stay out of the runtime image.


> Overall, this patch is an improvement, so all these get my ack, and
> they should be applied as is.

The $SUBJECT patch is most certainly NOT an improvement.

It still has a solid NAK, since it's adding almost a page of bloat.


> Using platform_driver_probe() does allow you to reduce the kernel
> footprint still further, but that requires knowledge of the platforms
> affected (knowing that the platform devices are present before the
> drivers get probed.)

And as I've pointed out before ... that's exactly how platform
drivers work on most platforms. Very specifically, I've pointed
out previously to Uwe, it's how the OMAP code works.

So it's kind of perplexing to still see patches sent along which
make the situation worse.

2009-07-12 09:38:06

by David Brownell

[permalink] [raw]
Subject: Re: [PATCH] move omap_udc's probe function to .devinit.text

On Sunday 12 July 2009, Uwe Kleine-K?nig wrote:
>
> > Repeat -- NAK on this. ?Use platform_driver_probe() instead.
> >
> > I really don't like this series of patches. ?It's just adding
> > bloat to kernels, in chunks of up to a page per patch.
>
> I'm aware that in some cases platform_driver_probe is better.

Make that "most cases". It's rare that platform devices get
hotplugged. Mostly they're set up at system init ... often
it's all done by the time arch_initcall() finishes.


> But as I
> don't have access to most of the affected platforms I consider it saver.
> That's why I choosed this way.

You do have access to the source tree, and a powerful little
tool called "grep -r" ... which can easily tell you where the
devices for those platforms are defined. And thus let you see
if a given one happens to be one of the exceptional cases where
platform_driver_probe() won't work.


> The problem with platform_driver_probe
> is that if a device is added only after the driver is probed the
> device isn't bound.

That's rarely a problem though; it certainly isn't in the case of
the $SUBJECT driver, and others on that platform. I've pointed
that out to you before.


2009-07-12 13:18:08

by Russell King

[permalink] [raw]
Subject: Re: [PATCH] move omap_udc's probe function to .devinit.text

On Sun, Jul 12, 2009 at 09:47:34AM +0100, Russell King wrote:
> Your approach is perfectly fine, and safe. You're not adding any
> additional bloat which isn't already there. If it were adding any
> bloat (which it isn't), it certainly is not "in chunks of up to a
> page per patch".

Here is the effect of applying the am79c961 patch:

text data bss dec hex filename
2553829 76608 78560 2708997 295605 vmlinux.patched
2553285 76608 78560 2708453 2953e5 vmlinux

that's an extra 500 bytes, but wait a moment before criticising that.
Let's look at where these came from:

before:
1 .text.head 00000240 c0008000 c0008000 00010000 2**5
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .init 00016dc0 c0008240 c0008240 00010240 2**5
CONTENTS, ALLOC, LOAD, CODE
3 .text 002455a4 c001f000 c001f000 00027000 2**5
CONTENTS, ALLOC, LOAD, READONLY, CODE
4 __ksymtab 00004198 c0265000 c0265000 0026d000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA

after:
1 .text.head 00000240 c0008000 c0008000 00010000 2**5
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .init 00016dc0 c0008240 c0008240 00010240 2**5
CONTENTS, ALLOC, LOAD, CODE
3 .text 002457c4 c001f000 c001f000 00027000 2**5
CONTENTS, ALLOC, LOAD, READONLY, CODE
4 __ksymtab 00004198 c0265000 c0265000 0026d000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA

Notice that the VMA of __ksymtab hasn't changed, which follows on from
the text section. What's happened is that we've merely moved some text
from the .init section to the .text section, and in this case we haven't
changed the overall file size, nor the number of pages used for each
section.

To nack these patches based upon every patch adding one page to the kernel
size is clearly overstating the effect. The effect is that in some
configurations, it moves some text out of .init into .text, and can
increase the size of the kernel kept in memory after boot time. It's
certainly no where near "one page per patch" though, and the overall
size of the kernel may only change +/- one page through doing this -
eg, you might move enough text out of .init so that shrinks by one
page without making .text expand by a page.

I don't think this is a strong enough reason to reject any of these
patches. David's approach is an enhancement whereas your patches
are a bug fix.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of:

2009-07-12 20:07:15

by David Brownell

[permalink] [raw]
Subject: Re: [PATCH] move omap_udc's probe function to .devinit.text

On Sunday 12 July 2009, Russell King wrote:
> Here is the effect of applying the am79c961 patch:

Observe: $SUBJECT is an entirely separate patch.

My NAKs were quite specific.

2009-07-12 20:48:17

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] move omap_udc's probe function to .devinit.text

On Sat, Jul 11, 2009 at 03:30:44PM -0700, David Brownell wrote:
> On Saturday 11 July 2009, Uwe Kleine-K?nig wrote:
> > An alternative to this patch is using platform_driver_probe instead of
> > platform_driver_register plus removing the pointer to the probe function
> > from the struct platform_driver.
>
> Repeat -- NAK on this. Use platform_driver_probe() instead.
Oh, I just noticed that this patch is a relict. The driver was changed
to use platform_driver_probe in
864e28b4f24106b799e991fa136fa6fa2b638a68.

As my old patch just applied anyhow I didn't notice that.

And I just found another similar problem.
E.g. clevo_mail_led_probe is defined to live in .init.text and uses
platform_driver_probe, but as it's referenced in the driver struct my
script matched this file.

(Is it wrong (wrong as in "worth to be fixed") to reference the probe
function in the driver struct when platform_driver_probe is used? If so
at least

drivers/serial/msm_serial.c
drivers/i2c/busses/i2c-imx.c

are effected, too. Patches at

http://news.gmane.org/find-root.php?group=gmane.linux.ports.arm.kernel&article=62319

)

The other patches are not affected.

@Greg: Please just drop these two patches:

[PATCH] move omap_udc's probe function to .devinit.text
[PATCH] move leds-clevo-mail's probe function to .devinit.text

Sorry for the unconvenience.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-12 22:12:28

by David Brownell

[permalink] [raw]
Subject: Re: [PATCH] move omap_udc's probe function to .devinit.text

On Sunday 12 July 2009, Uwe Kleine-K?nig wrote:
> On Sat, Jul 11, 2009 at 03:30:44PM -0700, David Brownell wrote:
> > Repeat -- NAK on this. Use platform_driver_probe() instead.
>
> Oh, I just noticed that this patch is a relict. The driver was changed
> to use platform_driver_probe in
> 864e28b4f24106b799e991fa136fa6fa2b638a68.

Good.


> And I just found another similar problem.
> E.g. clevo_mail_led_probe is defined to live in .init.text and uses
> platform_driver_probe, but as it's referenced in the driver struct my
> script matched this file.
>
> (Is it wrong (wrong as in "worth to be fixed") to reference the probe
> function in the driver struct when platform_driver_probe is used?

Wrong, but not dangerous ... so fix, but at low priority.
At least, low until the DEBUG_SECTION_MISMATCH stuff gets
re-enabled.

When platform_driver_probe() returns, that driver field willl
have changed to something safe.


> If so
> at least
>
> drivers/serial/msm_serial.c
> drivers/i2c/busses/i2c-imx.c
>
> are effected, too. Patches at
>
> http://news.gmane.org/find-root.php?group=gmane.linux.ports.arm.kernel&article=62319
>
> )
>
> The other patches are not affected.
>
> @Greg: Please just drop these two patches:
>
> [PATCH] move omap_udc's probe function to .devinit.text
> [PATCH] move leds-clevo-mail's probe function to .devinit.text

... and the others I NAKed too.


>
> Sorry for the unconvenience.
>
> Best regards
> Uwe
>
> --
> Pengutronix e.K. | Uwe Kleine-K?nig |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
>
>

2009-07-12 22:21:42

by David Brownell

[permalink] [raw]
Subject: Re: [PATCH] move omap_udc's probe function to .devinit.text

On Sunday 12 July 2009, Russell King wrote:
> ?David's approach is an enhancement whereas your patches
> are a bug fix.

Not an enhancement. Uwe's current approach causes regressions
in terms of kernel runtime footprint. That is, pages will newly
be made to sit around doing *nothing* forever, when they could
have been used to get Real Work done. And, pre-patches, they
would have been getting Real Work done.

If it weren't a regression I wouldn't have objected.

A few years back, I measured the impact of having probe() and
friends in a section -- init{,data} vs devinit{,data} -- that gets
removed. Most drivers were in the 1K-2K range. $SUBJECT was
larger than most, but there were some with even more discardable
init logic.

All that adds up. There's no point to commiting patches that
do things wrong *and* waste space, then need to fix things up
again later when it's easy to do it right in the first place.

2009-07-13 08:44:15

by Eric Miao

[permalink] [raw]
Subject: Re: [PATCH] move corgi-ssp's probe function to .devinit.text

Uwe Kleine-König wrote:
> A pointer to corgi_ssp_probe is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (when having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.
>

This corgi_ssp.c and corgi_lcd.c will be obsoleted soon, the only user
corgi_ts.c has been marked as deprecated, and will be remove once the
ssp cleanup work is done, so further fixes to these files are pointless.

2009-07-13 09:01:13

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] move corgi-ssp's probe function to .devinit.text

On Mon, Jul 13, 2009 at 04:44:01PM +0800, Eric Miao wrote:
> Uwe Kleine-K?nig wrote:
> > A pointer to corgi_ssp_probe is passed to the core via
> > platform_driver_register and so the function must not disappear when the
> > .init sections are discarded. Otherwise (when having HOTPLUG=y)
> > unbinding and binding a device to the driver via sysfs will result in an
> > oops as does a device being registered late.
> >
> > An alternative to this patch is using platform_driver_probe instead of
> > platform_driver_register plus removing the pointer to the probe function
> > from the struct platform_driver.
> >
>
> This corgi_ssp.c and corgi_lcd.c will be obsoleted soon, the only user
> corgi_ts.c has been marked as deprecated, and will be remove once the
> ssp cleanup work is done, so further fixes to these files are pointless.
OK, dropped. I hope that either the drivers will be gone when I respin
this series or I still remember having dropped the patches :-)

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-13 09:10:42

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] move omap_udc's probe function to .devinit.text

Hello David,

On Sun, Jul 12, 2009 at 03:21:30PM -0700, David Brownell wrote:
> On Sunday 12 July 2009, Russell King wrote:
> > ?David's approach is an enhancement whereas your patches
> > are a bug fix.
>
> Not an enhancement. Uwe's current approach causes regressions
> in terms of kernel runtime footprint. That is, pages will newly
> be made to sit around doing *nothing* forever, when they could
> have been used to get Real Work done. And, pre-patches, they
> would have been getting Real Work done.
>
> If it weren't a regression I wouldn't have objected.
IMHO my patches primarily fix possible oopses. I see your point that
platform_driver_probe has some advantages, but I consider it too
time-consuming to check for each of the initially 60+ patches when the
respecting devices are registered.

My intention is to point out a problem plus provide a safe fix.

> All that adds up. There's no point to commiting patches that
> do things wrong *and* waste space, then need to fix things up
> again later when it's easy to do it right in the first place.

Obviously it's arguable if it's wrong or not. I consider it at least
better than doing nothing.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-13 09:12:49

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] don't add clevo_mail_led_driver's probe function to the driver struct

clevo_mail_led_driver is registered using platform_driver_probe which
takes care for the probe function itself. So don't pass it in the
driver struct, too.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Márton Németh <[email protected]>
Cc: Richard Purdie <[email protected]>
---
Hello,

I'm a bit uncertain if this patch is really useful. There is no
difference in runtime behaviour because platform_driver_probe just
overwrites the .probe member. Nevertheless it's a section violation
that hurts my eye and triggers a false positive for my script that finds
drivers using probe functions in .init.text and
platform_driver_register.

Care? Don't care?

Best regards
Uwe

drivers/leds/leds-clevo-mail.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
index 1813c84..5b36ae2 100644
--- a/drivers/leds/leds-clevo-mail.c
+++ b/drivers/leds/leds-clevo-mail.c
@@ -157,7 +157,6 @@ static int clevo_mail_led_remove(struct platform_device *pdev)
}

static struct platform_driver clevo_mail_led_driver = {
- .probe = clevo_mail_led_probe,
.remove = clevo_mail_led_remove,
.driver = {
.name = KBUILD_MODNAME,
--
tg: (7638d53..) t/noprobecbforplatformdriverprobe/clevo_mail_led_driver (depends on: linus/master)

2009-07-13 13:52:22

by Peter Jones

[permalink] [raw]
Subject: Re: [PATCH] move efifb's probe function to .devinit.text

On 07/11/2009 04:52 PM, Uwe Kleine-König wrote:
> A pointer to efifb_probe is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.

Looks good to me:

Acked-by: Peter Jones <[email protected]>

>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.
>
> Signed-off-by: Uwe Kleine-König <[email protected]>
> Cc: Peter Jones <[email protected]>
> Cc: Krzysztof Helt <[email protected]>
> Cc: Geert Uytterhoeven <[email protected]>
> Cc: Jaya Kumar <[email protected]>
> Cc: Ralf Baechle <[email protected]>
> Cc: Maciej W. Rozycki <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Chandramouli Narayanan <[email protected]>
> Cc: Huang Ying <[email protected]>
> ---
> drivers/video/efifb.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
> index eb12182..2161f21 100644
> --- a/drivers/video/efifb.c
> +++ b/drivers/video/efifb.c
> @@ -201,7 +201,7 @@ static int __init efifb_setup(char *options)
> return 0;
> }
>
> -static int __init efifb_probe(struct platform_device *dev)
> +static int __devinit efifb_probe(struct platform_device *dev)
> {
> struct fb_info *info;
> int err;


--
Peter

In computer science, about the only thing we can prove is that traveling
salesmen can't find their way from one place to another effeciently, and
that unix hackers can't really decode 40-bit keys by harnessing all the
computers in the lab. And the hackers do it anyway, and the salesmen still
make their rounds.
-- Ron Jeffries, WikiWikiWeb

2009-07-13 19:55:28

by Nicolas Pitre

[permalink] [raw]
Subject: Re: [PATCH] move orion_nand's probe function to .devinit.text

On Sat, 11 Jul 2009, Uwe Kleine-König wrote:

> A pointer to orion_nand_probe is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.

For those kind of platform devices I'd prefer the alternative.


Nicolas

2009-07-13 21:31:59

by David Brownell

[permalink] [raw]
Subject: Re: [PATCH] move omap_udc's probe function to .devinit.text

On Monday 13 July 2009, Uwe Kleine-K?nig wrote:
> > If it weren't a regression I wouldn't have objected.
>
> IMHO my patches primarily fix possible oopses. ?I see your point that
> platform_driver_probe has some advantages,

The point is that your specific change caused a type
of regresssion ... I said nothing about "advantages",
just that your approach creates footprint regressions.


> but I consider it too
> time-consuming to check for each of the initially 60+ patches when the
> respecting devices are registered.

As a rule, preventing regressions is part of the task
description for any patch series.

Now, accidents do happen. But you had *ALREADY* gotten
NAKs for many of these patches, specifically on the
basis that they were causing these regressions. You
saved zero time by re-submitting known-broken patches.

2009-07-14 08:09:54

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] move orion_nand's probe function to .devinit.text

Hi Nicolas,

On Mon, Jul 13, 2009 at 03:37:23PM -0400, Nicolas Pitre wrote:
> On Sat, 11 Jul 2009, Uwe Kleine-K?nig wrote:
>
> > A pointer to orion_nand_probe is passed to the core via
> > platform_driver_register and so the function must not disappear when the
> > .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> > unbinding and binding a device to the driver via sysfs will result in an
> > oops as does a device being registered late.
> >
> > An alternative to this patch is using platform_driver_probe instead of
> > platform_driver_register plus removing the pointer to the probe function
> > from the struct platform_driver.
>
> For those kind of platform devices I'd prefer the alternative.
Can I interpret that as your intend to implement and test it?

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-14 16:25:29

by Nicolas Pitre

[permalink] [raw]
Subject: Re: [PATCH] move orion_nand's probe function to .devinit.text

On Tue, 14 Jul 2009, Uwe Kleine-K?nig wrote:

> Hi Nicolas,
>
> On Mon, Jul 13, 2009 at 03:37:23PM -0400, Nicolas Pitre wrote:
> > On Sat, 11 Jul 2009, Uwe Kleine-K?nig wrote:
> >
> > > A pointer to orion_nand_probe is passed to the core via
> > > platform_driver_register and so the function must not disappear when the
> > > .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> > > unbinding and binding a device to the driver via sysfs will result in an
> > > oops as does a device being registered late.
> > >
> > > An alternative to this patch is using platform_driver_probe instead of
> > > platform_driver_register plus removing the pointer to the probe function
> > > from the struct platform_driver.
> >
> > For those kind of platform devices I'd prefer the alternative.
> Can I interpret that as your intend to implement and test it?

"Eventually", yes. This is however a low priority for me.


Nicolas

2009-07-14 17:17:43

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] move orion_nand's probe function to .devinit.text

Hi Nicolas,

On Tue, Jul 14, 2009 at 12:12:46PM -0400, Nicolas Pitre wrote:
> > > > An alternative to this patch is using platform_driver_probe instead of
> > > > platform_driver_register plus removing the pointer to the probe function
> > > > from the struct platform_driver.
> > >
> > > For those kind of platform devices I'd prefer the alternative.
> > Can I interpret that as your intend to implement and test it?
>
> "Eventually", yes. This is however a low priority for me.
For me, too. I just keep the patch in my queue that it doesn't get
dropped.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-16 23:15:21

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Sat, Jul 11, 2009 at 10:46:31PM +0200, Uwe Kleine-K?nig wrote:
> Hello Greg,
>
> On Sat, Jul 11, 2009 at 11:59:20AM -0700, Greg KH wrote:
> > On Sat, Jul 11, 2009 at 12:00:14PM +0200, Uwe Kleine-K?nig wrote:
> > > Hi Greg,
> > >
> > > > > Are you conviced and took the patch or did you give up to convince me?
> > > >
> > > > Heh, no, sorry, it got burried in my queue.
> > > >
> > > > > I still think the patch is correct and I'd like to have it applied.
> > > >
> > > > Ok, let's test it out in the linux-next tree for a while to make sure it
> > > > works properly. Care to send me an updated version?
> > > I updated to latest Linus' master. It applies to linux-next from
> > > Fri Jul 10 14:44:30 2009 +1000 as is.
> > >
> > > Back some time I sent a series that fixes many of these bugs. I will
> > > update it later today and resend.
> > >
> > > Best regards and thanks,
> > > Uwe
> > >
> > > ---->8----
> > > From: Uwe Kleine-K?nig <[email protected]>
> > > Subject: [PATCH] platform_driver_register: warn if probe is in .init.text
> > >
> > > with HOTPLUG=y it's wrong to register a platform_driver whose probe
> > > function lives in .init.text because the probe function can be called
> > > (e.g. via sysfs or by registering a device late) after the init sections
> > > are already discarded. This results in an oops.
> > >
> > > So warn if such a driver is registered.
> > >
> > > Without HOTPLUG the probe function can (and should) be discarded if the
> > > driver is registered while the init sections are still available.
> > > In this case warn if the probe function isn't discarded later. (As
> > > described in the comments there is a small chance for a wrong warning.
> > > But as HOTPLUG=n is unusual today and the situation is strage enough to
> > > be cleaned up anyhow, I think this is OK.)
> > >
> > > Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> >
> > This code kills the build in very bad ways :(
> it's just a ; that didn't made it into the new version. Don't know why.
>
> If you squash the patch below into the patch I sent it should work
> again.

I don't have the original anymore :(

As it seemed that a lot of people who controlled the problem drivers
didn't like the patches, what are you considering doing now?

thanks,

greg k-h

2009-07-17 08:34:52

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hello Greg,

> > > This code kills the build in very bad ways :(
> > it's just a ; that didn't made it into the new version. Don't know why.
> >
> > If you squash the patch below into the patch I sent it should work
> > again.
>
> I don't have the original anymore :(
See below. I changed the wording of the output in the !HOTPLUG case to
say .devinit.text instead of .init.text and fixed a typo in the commit
log. Other than that the patch is unchanged.

> As it seemed that a lot of people who controlled the problem drivers
> didn't like the patches, what are you considering doing now?
Hmm, there are only two people that expressed not being completly happy
with my suggestions.

I think I will just drop the a patches for now and later just point out
the problem. (At least for David's nacked drivers I feel little urge to
implement the alternative fix.)

And maybe if the "warn if probe is in .init.text" patch is merged the
people seeing the problem become more numerous which I hope will either
increase the positive feedback for the other patches or someone else
will propose a patch implementing the alternative. (Maybe I should just
BUG() instead of only printing a warning :-)

Best regards and thanks for your ping on the subject
Uwe

--->8---
From: Uwe Kleine-K?nig <[email protected]>
Subject: platform_driver_register: warn if probe is in .init.text

with HOTPLUG=y it's wrong to register a platform_driver who's probe
function lives in .init.text because the probe function can be called
(e.g. via sysfs or by registering a device late) after the init sections
are already discarded. This results in an oops.

So warn if such a driver is registered.

Without HOTPLUG the probe function can (and should) be discarded if the
driver is registered while the init sections are still available.
In this case warn if the probe function isn't discarded later. (As
described in the comments there is a small chance for a wrong warning.
But as HOTPLUG=n is unusual today and the situation is strage enough to
be cleaned up anyhow, I think this is OK.)

Signed-off-by: Uwe Kleine-K?nig <[email protected]>
---
drivers/base/platform.c | 43 +++++++++++++++++++++++++++++++++++++------
include/linux/kernel.h | 2 ++
include/linux/module.h | 12 ++++++++++++
kernel/extable.c | 12 ++++++++++++
kernel/module.c | 36 ++++++++++++++++++++++++++++++++++++
5 files changed, 99 insertions(+), 6 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 81cb01b..68ef8cc 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -470,11 +470,7 @@ static void platform_drv_shutdown(struct device *_dev)
drv->shutdown(dev);
}

-/**
- * platform_driver_register
- * @drv: platform driver structure
- */
-int platform_driver_register(struct platform_driver *drv)
+static int __platform_driver_register(struct platform_driver *drv)
{
drv->driver.bus = &platform_bus_type;
if (drv->probe)
@@ -489,6 +485,41 @@ int platform_driver_register(struct platform_driver *drv)

return driver_register(&drv->driver);
}
+
+/**
+ * platform_driver_register
+ * @drv: platform driver structure
+ */
+int platform_driver_register(struct platform_driver *drv)
+{
+ int ret = __platform_driver_register(drv);
+
+#if defined(CONFIG_HOTPLUG)
+ /*
+ * drivers that are registered by platform_driver_register
+ * should not have their probe function in .init.text. The
+ * reason is that a probe can happen after .init.text is
+ * discarded which then results in an oops. The alternatives
+ * are using .devinit.text for the probe function or "register"
+ * with platform_driver_probe.
+ */
+ if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
+ pr_warning("oops-warning: probe function of platform driver %s"
+ " lives in .init.text\n", drv->driver.name);
+#else
+ /*
+ * without HOTPLUG probe functions can be discarded after the driver is
+ * loaded.
+ * There is a little chance for false positives, namely if the driver is
+ * registered after the .init sections are discarded.
+ */
+ if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
+ pr_info("probably the probe function of platform driver %s can"
+ " be moved to .devinit.text\n",
+ drv->driver.name);
+#endif
+ return ret;
+}
EXPORT_SYMBOL_GPL(platform_driver_register);

/**
@@ -525,7 +556,7 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv,

/* temporary section violation during probe() */
drv->probe = probe;
- retval = code = platform_driver_register(drv);
+ retval = code = __platform_driver_register(drv);

/* Fixup that section violation, being paranoid about code scanning
* the list of drivers in order to probe new devices. Check to see
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d6320a3..2d48087 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -203,8 +203,10 @@ extern char *get_options(const char *str, int nints, int *ints);
extern unsigned long long memparse(const char *ptr, char **retptr);

extern int core_kernel_text(unsigned long addr);
+extern int core_kernel_init_text(unsigned long addr);
extern int __kernel_text_address(unsigned long addr);
extern int kernel_text_address(unsigned long addr);
+extern int kernel_init_text_address(unsigned long addr);
extern int func_ptr_is_kernel_text(void *ptr);

struct pid;
diff --git a/include/linux/module.h b/include/linux/module.h
index 098bdb7..93f47c4 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -385,9 +385,11 @@ static inline int module_is_live(struct module *mod)
}

struct module *__module_text_address(unsigned long addr);
+struct module *__module_init_text_address(unsigned long addr);
struct module *__module_address(unsigned long addr);
bool is_module_address(unsigned long addr);
bool is_module_text_address(unsigned long addr);
+bool is_module_init_text_address(unsigned long addr);

static inline int within_module_core(unsigned long addr, struct module *mod)
{
@@ -556,6 +558,11 @@ static inline struct module *__module_text_address(unsigned long addr)
return NULL;
}

+static inline struct module *__module_init_text_address(unsigned long addr)
+{
+ return NULL;
+}
+
static inline bool is_module_address(unsigned long addr)
{
return false;
@@ -566,6 +573,11 @@ static inline bool is_module_text_address(unsigned long addr)
return false;
}

+static inline bool is_module_init_text_address(unsigned long addr)
+{
+ return false;
+}
+
/* Get/put a kernel symbol (calls should be symmetric) */
#define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
#define symbol_put(x) do { } while(0)
diff --git a/kernel/extable.c b/kernel/extable.c
index 7f8f263..bfd7bda 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -66,6 +66,11 @@ int core_kernel_text(unsigned long addr)
addr <= (unsigned long)_etext)
return 1;

+ return core_kernel_init_text;
+}
+
+int core_kernel_init_text(unsigned long addr)
+{
if (system_state == SYSTEM_BOOTING &&
init_kernel_text(addr))
return 1;
@@ -98,6 +103,13 @@ int kernel_text_address(unsigned long addr)
return is_module_text_address(addr);
}

+int kernel_init_text_address(unsigned long addr)
+{
+ if (core_kernel_init_text(addr))
+ return 1;
+ return is_module_init_text_address(addr);
+}
+
/*
* On some architectures (PPC64, IA64) function pointers
* are actually only tokens to some data that then holds the
diff --git a/kernel/module.c b/kernel/module.c
index 0a04983..f1fbeb0 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2890,6 +2890,22 @@ bool is_module_text_address(unsigned long addr)
}

/*
+ * is_module_init_text_address - is this address inside a module's .init.text
+ * section?
+ * @addr: the address to check.
+ */
+bool is_module_init_text_address(unsigned long addr)
+{
+ bool ret;
+
+ preempt_disable();
+ ret = __module_init_text_address(addr) != NULL;
+ preempt_enable();
+
+ return ret;
+}
+
+/*
* __module_text_address - get the module whose code contains an address.
* @addr: the address.
*
@@ -2909,6 +2925,26 @@ struct module *__module_text_address(unsigned long addr)
}
EXPORT_SYMBOL_GPL(__module_text_address);

+/*
+ * __module_init_text_address - get the module whose .init.text contains an
+ * address.
+ * @addr: the address.
+ *
+ * Must be called with preempt disabled or module mutex held so that
+ * module doesn't get freed during this.
+ */
+struct module *__module_init_text_address(unsigned long addr)
+{
+ struct module *mod = __module_address(addr);
+ if (mod) {
+ /* Make sure it's within the .init.text section. */
+ if (!within(addr, mod->module_init, mod->init_text_size))
+ mod = NULL;
+ }
+ return mod;
+}
+EXPORT_SYMBOL_GPL(__module_init_text_address);
+
/* Don't grab lock, we're oopsing. */
void print_modules(void)
{
--
1.6.3.3

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-21 15:22:55

by Finn Thain

[permalink] [raw]
Subject: Re: [PATCH] move macsonic's probe function to .devinit.text



On Sat, 11 Jul 2009, Uwe Kleine-K?nig wrote:

> A pointer to mac_sonic_probe is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.

This patch works for me (tested on a Quadra 630). I still get an oops on
rmmod, but that's a separate issue. I'll send a patch for that.

Finn

>
> Various other functions that are called by mac_sonic_probe need to move
> to .devinit.text, too.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.
>
> Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> Cc: Jeff Garzik <[email protected]>
> Cc: David S. Miller <[email protected]>
> Cc: Finn Thain <[email protected]>
> Cc: Geert Uytterhoeven <[email protected]>
> Cc: Andrew Morton <[email protected]>
> ---
> drivers/net/macsonic.c | 14 +++++++-------
> 1 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c
> index acd143d..8f492c7 100644
> --- a/drivers/net/macsonic.c
> +++ b/drivers/net/macsonic.c
> @@ -179,7 +179,7 @@ static const struct net_device_ops macsonic_netdev_ops = {
> .ndo_set_mac_address = eth_mac_addr,
> };
>
> -static int __init macsonic_init(struct net_device *dev)
> +static int __devinit macsonic_init(struct net_device *dev)
> {
> struct sonic_local* lp = netdev_priv(dev);
>
> @@ -223,7 +223,7 @@ static int __init macsonic_init(struct net_device *dev)
> return 0;
> }
>
> -static int __init mac_onboard_sonic_ethernet_addr(struct net_device *dev)
> +static int __devinit mac_onboard_sonic_ethernet_addr(struct net_device *dev)
> {
> struct sonic_local *lp = netdev_priv(dev);
> const int prom_addr = ONBOARD_SONIC_PROM_BASE;
> @@ -288,7 +288,7 @@ static int __init mac_onboard_sonic_ethernet_addr(struct net_device *dev)
> } else return 0;
> }
>
> -static int __init mac_onboard_sonic_probe(struct net_device *dev)
> +static int __devinit mac_onboard_sonic_probe(struct net_device *dev)
> {
> /* Bwahahaha */
> static int once_is_more_than_enough;
> @@ -409,7 +409,7 @@ static int __init mac_onboard_sonic_probe(struct net_device *dev)
> return macsonic_init(dev);
> }
>
> -static int __init mac_nubus_sonic_ethernet_addr(struct net_device *dev,
> +static int __devinit mac_nubus_sonic_ethernet_addr(struct net_device *dev,
> unsigned long prom_addr,
> int id)
> {
> @@ -424,7 +424,7 @@ static int __init mac_nubus_sonic_ethernet_addr(struct net_device *dev,
> return 0;
> }
>
> -static int __init macsonic_ident(struct nubus_dev *ndev)
> +static int __devinit macsonic_ident(struct nubus_dev *ndev)
> {
> if (ndev->dr_hw == NUBUS_DRHW_ASANTE_LC &&
> ndev->dr_sw == NUBUS_DRSW_SONIC_LC)
> @@ -449,7 +449,7 @@ static int __init macsonic_ident(struct nubus_dev *ndev)
> return -1;
> }
>
> -static int __init mac_nubus_sonic_probe(struct net_device *dev)
> +static int __devinit mac_nubus_sonic_probe(struct net_device *dev)
> {
> static int slots;
> struct nubus_dev* ndev = NULL;
> @@ -562,7 +562,7 @@ static int __init mac_nubus_sonic_probe(struct net_device *dev)
> return macsonic_init(dev);
> }
>
> -static int __init mac_sonic_probe(struct platform_device *pdev)
> +static int __devinit mac_sonic_probe(struct platform_device *pdev)
> {
> struct net_device *dev;
> struct sonic_local *lp;
>

2009-07-21 19:20:54

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] move macsonic's probe function to .devinit.text

From: Finn Thain <[email protected]>
Date: Wed, 22 Jul 2009 01:14:36 +1000 (EST)

>
>
> On Sat, 11 Jul 2009, Uwe Kleine-K?nig wrote:
>
>> A pointer to mac_sonic_probe is passed to the core via
>> platform_driver_register and so the function must not disappear when
>> the .init sections are discarded. Otherwise (if also having
>> HOTPLUG=y) unbinding and binding a device to the driver via sysfs will
>> result in an oops as does a device being registered late.
>
> This patch works for me (tested on a Quadra 630). I still get an oops
> on rmmod, but that's a separate issue. I'll send a patch for that.

Applied, but Uwe _please_ post networking patches to
[email protected] so that they get properly logged
and tracked at:

http://patchwork.ozlabs.org/project/netdev/list/

Thank you.

2009-07-21 19:21:03

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] move macsonic's probe function to .devinit.text

Hi Finn,

On Wed, Jul 22, 2009 at 01:14:36AM +1000, Finn Thain wrote:
> On Sat, 11 Jul 2009, Uwe Kleine-K?nig wrote:
>
>> A pointer to mac_sonic_probe is passed to the core via
>> platform_driver_register and so the function must not disappear when
>> the .init sections are discarded. Otherwise (if also having HOTPLUG=y)
>> unbinding and binding a device to the driver via sysfs will result in
>> an oops as does a device being registered late.
>
> This patch works for me (tested on a Quadra 630). I still get an oops on
> rmmod, but that's a separate issue. I'll send a patch for that.
Thanks, I'll add a

Tested-by: Finn Thain <[email protected]>

to the patch description.

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-21 19:40:42

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] move macsonic's probe function to .devinit.text

Hi David,

On Tue, Jul 21, 2009 at 12:20:58PM -0700, David Miller wrote:
> From: Finn Thain <[email protected]>
> Date: Wed, 22 Jul 2009 01:14:36 +1000 (EST)
>
> > On Sat, 11 Jul 2009, Uwe Kleine-K?nig wrote:
> >
> >> A pointer to mac_sonic_probe is passed to the core via
> >> platform_driver_register and so the function must not disappear when
> >> the .init sections are discarded. Otherwise (if also having
> >> HOTPLUG=y) unbinding and binding a device to the driver via sysfs will
> >> result in an oops as does a device being registered late.
> >
> > This patch works for me (tested on a Quadra 630). I still get an oops
> > on rmmod, but that's a separate issue. I'll send a patch for that.
>
> Applied, but Uwe _please_ post networking patches to
> [email protected] so that they get properly logged
> and tracked at:
There are 8 patches in this series that touch drivers/net, only one of
them had a Cc: to netdev.

The diffstat of my series for drivers/net is
drivers/net/arm/am79c961a.c | 2 +-
drivers/net/arm/at91_ether.c | 2 +-
drivers/net/jazzsonic.c | 4 ++--
drivers/net/macsonic.c | 14 +++++++-------
drivers/net/meth.c | 2 +-
drivers/net/sb1250-mac.c | 2 +-
drivers/net/sgiseeq.c | 2 +-
drivers/net/xtsonic.c | 2 +-
8 files changed, 15 insertions(+), 15 deletions(-)

drivers/net/arm/at91_ether.c got a NACK by David Brownell---he wants the
alternative to be implemented.
drivers/net/arm/am79c961a.c got the Cc to netdev@
You now took drivers/net/macsonic.c.

Should I repost the remaining 5 to netdev@?

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-21 19:41:53

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] move macsonic's probe function to .devinit.text

From: Uwe Kleine-K?nig <[email protected]>
Date: Tue, 21 Jul 2009 21:40:36 +0200

> Should I repost the remaining 5 to netdev@?

You should for at least the ones that don't require changes,
but once you fix those other one's up based upon feedback you
should make sure netdev at least gets CC:'d when you post
those too.

2009-07-21 20:11:57

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] register at91_ether using platform_driver_probe

at91ether_probe lives in .init.text, so using platform_driver_register
to register it is wrong because binding a device after the init memory
is discarded (e.g. via sysfs) results in an oops.

As requested by David Brownell platform_driver_probe is used instead of
moving the probe function to .devinit.text as proposed initially.
This saves some memory, but devices registered after the driver is
probed are not bound (probably there are none) and binding via sysfs
isn't possible.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: David Brownell <[email protected]>
Cc: [email protected]
Cc: Paulius Zaleckas <[email protected]>
Cc: Marc Pignat <[email protected]>
Cc: Andrew Victor <[email protected]>
Cc: Roel Kluin <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>

---
drivers/net/arm/at91_ether.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index 2e7419a..5041d10 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -1228,7 +1228,6 @@ static int at91ether_resume(struct platform_device *pdev)
#endif

static struct platform_driver at91ether_driver = {
- .probe = at91ether_probe,
.remove = __devexit_p(at91ether_remove),
.suspend = at91ether_suspend,
.resume = at91ether_resume,
@@ -1240,7 +1239,7 @@ static struct platform_driver at91ether_driver = {

static int __init at91ether_init(void)
{
- return platform_driver_register(&at91ether_driver);
+ return platform_driver_probe(&at91ether_driver, at91ether_probe);
}

static void __exit at91ether_exit(void)
--
tg: (4b0a840..) t/platsection/at91ether_driver (depends on: linus/master)

2009-07-21 20:36:33

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] register mmci-omap-hs using platform_driver_probe

omap_mmc_probe lives in .init.text, so using platform_driver_register
to register it is wrong because binding a device after the init memory
is discarded (e.g. via sysfs) results in an oops.

As requested by David Brownell platform_driver_probe is used instead of
moving the probe function to .devinit.text as proposed initially.
This saves some memory, but devices registered after the driver is
probed are not bound (probably there are none) and binding via sysfs
isn't possible.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Jean Pihet <[email protected]>
Cc: Tony Lindgren <[email protected]>
Cc: Pierre Ossman <[email protected]>
Cc: Andy Lowe <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: David Brownell <[email protected]>
Cc: Madhusudhan Chikkature<[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>

---
drivers/mmc/host/omap_hsmmc.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 1cf9cfb..40d9830 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1307,7 +1307,6 @@ clk_en_err:
#endif

static struct platform_driver omap_mmc_driver = {
- .probe = omap_mmc_probe,
.remove = omap_mmc_remove,
.suspend = omap_mmc_suspend,
.resume = omap_mmc_resume,
@@ -1320,7 +1319,7 @@ static struct platform_driver omap_mmc_driver = {
static int __init omap_mmc_init(void)
{
/* Register the MMC driver */
- return platform_driver_register(&omap_mmc_driver);
+ return platform_driver_probe(&omap_mmc_driver, omap_mmc_probe);
}

static void __exit omap_mmc_cleanup(void)
--
tg: (4b0a840..) t/platsection/omap_mmc_driver (depends on: linus/master)

2009-07-21 20:46:45

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] register orion_nand using platform_driver_probe

orion_nand_probe lives in .init.text, so using platform_driver_register
to register it is wrong because binding a device after the init memory
is discarded (e.g. via sysfs) results in an oops.

As requested by Nicolas Pitre platform_driver_probe is used instead of
moving the probe function to .devinit.text as proposed initially.
This saves some memory, but devices registered after the driver is
probed are not bound (probably there are none) and binding via sysfs
isn't possible.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Lennert Buytenhek <[email protected]>
Cc: Saeed Bishara <[email protected]>
Cc: Jörn Engel <[email protected]>
Cc: Nicolas Pitre <[email protected]>
Cc: Tzachi Perelstein <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: David Woodhouse <[email protected]>
Cc: [email protected]

---
drivers/mtd/nand/orion_nand.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 7ad9722..cb9d13b 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -171,7 +171,6 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
}

static struct platform_driver orion_nand_driver = {
- .probe = orion_nand_probe,
.remove = __devexit_p(orion_nand_remove),
.driver = {
.name = "orion_nand",
@@ -181,7 +180,7 @@ static struct platform_driver orion_nand_driver = {

static int __init orion_nand_init(void)
{
- return platform_driver_register(&orion_nand_driver);
+ return platform_driver_probe(&orion_nand_driver, orion_nand_probe);
}

static void __exit orion_nand_exit(void)
--
tg: (4b0a840..) t/platsection/orion_nand_driver (depends on: linus/master)

2009-07-21 22:26:57

by Nicolas Pitre

[permalink] [raw]
Subject: Re: [PATCH] register orion_nand using platform_driver_probe

On Tue, 21 Jul 2009, Uwe Kleine-König wrote:

> orion_nand_probe lives in .init.text, so using platform_driver_register
> to register it is wrong because binding a device after the init memory
> is discarded (e.g. via sysfs) results in an oops.
>
> As requested by Nicolas Pitre platform_driver_probe is used instead of
> moving the probe function to .devinit.text as proposed initially.
> This saves some memory, but devices registered after the driver is
> probed are not bound (probably there are none) and binding via sysfs
> isn't possible.
>
> Signed-off-by: Uwe Kleine-König <[email protected]>
> Cc: Lennert Buytenhek <[email protected]>
> Cc: Saeed Bishara <[email protected]>
> Cc: Jörn Engel <[email protected]>
> Cc: Nicolas Pitre <[email protected]>
> Cc: Tzachi Perelstein <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: David Woodhouse <[email protected]>
> Cc: [email protected]

Acked-by: Nicolas Pitre <[email protected]>

Thanks. BTW Tzachi's email address is no longer valid.

> ---
> drivers/mtd/nand/orion_nand.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
> index 7ad9722..cb9d13b 100644
> --- a/drivers/mtd/nand/orion_nand.c
> +++ b/drivers/mtd/nand/orion_nand.c
> @@ -171,7 +171,6 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
> }
>
> static struct platform_driver orion_nand_driver = {
> - .probe = orion_nand_probe,
> .remove = __devexit_p(orion_nand_remove),
> .driver = {
> .name = "orion_nand",
> @@ -181,7 +180,7 @@ static struct platform_driver orion_nand_driver = {
>
> static int __init orion_nand_init(void)
> {
> - return platform_driver_register(&orion_nand_driver);
> + return platform_driver_probe(&orion_nand_driver, orion_nand_probe);
> }
>
> static void __exit orion_nand_exit(void)
> --
> tg: (4b0a840..) t/platsection/orion_nand_driver (depends on: linus/master)
>

2009-07-22 05:17:44

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] register orion_nand using platform_driver_probe

Hi Nicolas,

On Tue, Jul 21, 2009 at 06:26:50PM -0400, Nicolas Pitre wrote:
> On Tue, 21 Jul 2009, Uwe Kleine-K?nig wrote:
>
> > orion_nand_probe lives in .init.text, so using platform_driver_register
> > to register it is wrong because binding a device after the init memory
> > is discarded (e.g. via sysfs) results in an oops.
> >
> > As requested by Nicolas Pitre platform_driver_probe is used instead of
> > moving the probe function to .devinit.text as proposed initially.
> > This saves some memory, but devices registered after the driver is
> > probed are not bound (probably there are none) and binding via sysfs
> > isn't possible.
> >
> > Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> > Cc: Lennert Buytenhek <[email protected]>
> > Cc: Saeed Bishara <[email protected]>
> > Cc: J?rn Engel <[email protected]>
> > Cc: Nicolas Pitre <[email protected]>
> > Cc: Tzachi Perelstein <[email protected]>
> > Cc: Andrew Morton <[email protected]>
> > Cc: Greg Kroah-Hartman <[email protected]>
> > Cc: David Woodhouse <[email protected]>
> > Cc: [email protected]
>
> Acked-by: Nicolas Pitre <[email protected]>
Did you test if all devices bind as expected?

> Thanks. BTW Tzachi's email address is no longer valid.
Yes, I got a mail from Marvell's mailer daemon stating the same. :-)

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-07-22 17:37:38

by David Brownell

[permalink] [raw]
Subject: Re: [PATCH] register at91_ether using platform_driver_probe

On Tuesday 21 July 2009, Uwe Kleine-K?nig wrote:
> at91ether_probe lives in .init.text, so using platform_driver_register
> to register it is wrong because binding a device after the init memory
> is discarded (e.g. via sysfs) results in an oops.
>
> As requested by David Brownell platform_driver_probe is used instead of
> moving the probe function to .devinit.text as proposed initially.
> This saves some memory, but devices registered after the driver is
> probed are not bound (probably there are none) and binding via sysfs
> isn't possible.

Right, these devices do not hotplug.

>
> Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> Cc: David Brownell <[email protected]>

Acked-by: David Brownell <[email protected]>

.... and thanks for doing it this way. :)

> Cc: [email protected]
> Cc: Paulius Zaleckas <[email protected]>
> Cc: Marc Pignat <[email protected]>
> Cc: Andrew Victor <[email protected]>
> Cc: Roel Kluin <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
>
> ---
> drivers/net/arm/at91_ether.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
> index 2e7419a..5041d10 100644
> --- a/drivers/net/arm/at91_ether.c
> +++ b/drivers/net/arm/at91_ether.c
> @@ -1228,7 +1228,6 @@ static int at91ether_resume(struct platform_device *pdev)
> #endif
>
> static struct platform_driver at91ether_driver = {
> - .probe = at91ether_probe,
> .remove = __devexit_p(at91ether_remove),
> .suspend = at91ether_suspend,
> .resume = at91ether_resume,
> @@ -1240,7 +1239,7 @@ static struct platform_driver at91ether_driver = {
>
> static int __init at91ether_init(void)
> {
> - return platform_driver_register(&at91ether_driver);
> + return platform_driver_probe(&at91ether_driver, at91ether_probe);
> }
>
> static void __exit at91ether_exit(void)
> --
> tg: (4b0a840..) t/platsection/at91ether_driver (depends on: linus/master)
>
>


2009-07-22 17:38:10

by David Brownell

[permalink] [raw]
Subject: Re: [PATCH] register mmci-omap-hs using platform_driver_probe

On Tuesday 21 July 2009, Uwe Kleine-K?nig wrote:
> omap_mmc_probe lives in .init.text, so using platform_driver_register
> to register it is wrong because binding a device after the init memory
> is discarded (e.g. via sysfs) results in an oops.
>
> As requested by David Brownell platform_driver_probe is used instead of
> moving the probe function to .devinit.text as proposed initially.
> This saves some memory, but devices registered after the driver is
> probed are not bound (probably there are none) and binding via sysfs
> isn't possible.
>
> Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> Cc: Jean Pihet <[email protected]>
> Cc: Tony Lindgren <[email protected]>
> Cc: Pierre Ossman <[email protected]>
> Cc: Andy Lowe <[email protected]>
> Cc: Adrian Hunter <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: David Brownell <[email protected]>

Acked-by: David Brownell <[email protected]>

> Cc: Madhusudhan Chikkature<[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
>
> ---
> drivers/mmc/host/omap_hsmmc.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 1cf9cfb..40d9830 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -1307,7 +1307,6 @@ clk_en_err:
> #endif
>
> static struct platform_driver omap_mmc_driver = {
> - .probe = omap_mmc_probe,
> .remove = omap_mmc_remove,
> .suspend = omap_mmc_suspend,
> .resume = omap_mmc_resume,
> @@ -1320,7 +1319,7 @@ static struct platform_driver omap_mmc_driver = {
> static int __init omap_mmc_init(void)
> {
> /* Register the MMC driver */
> - return platform_driver_register(&omap_mmc_driver);
> + return platform_driver_probe(&omap_mmc_driver, omap_mmc_probe);
> }
>
> static void __exit omap_mmc_cleanup(void)
> --
> tg: (4b0a840..) t/platsection/omap_mmc_driver (depends on: linus/master)
>
>


2009-07-22 17:46:27

by Andrew Victor

[permalink] [raw]
Subject: Re: [PATCH] register at91_ether using platform_driver_probe

hi,

> at91ether_probe lives in .init.text, so using platform_driver_register
> to register it is wrong because binding a device after the init memory
> is discarded (e.g. via sysfs) results in an oops.
>
> As requested by David Brownell platform_driver_probe is used instead of
> moving the probe function to .devinit.text as proposed initially.
> This saves some memory, but devices registered after the driver is
> probed are not bound (probably there are none) and binding via sysfs
> isn't possible.


Acked-by: Andrew Victor <[email protected]>

2009-07-22 18:24:51

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] register at91_ether using platform_driver_probe

From: Andrew Victor <[email protected]>
Date: Wed, 22 Jul 2009 19:46:24 +0200

> hi,
>
>> at91ether_probe lives in .init.text, so using platform_driver_register
>> to register it is wrong because binding a device after the init memory
>> is discarded (e.g. via sysfs) results in an oops.
>>
>> As requested by David Brownell platform_driver_probe is used instead of
>> moving the probe function to .devinit.text as proposed initially.
>> This saves some memory, but devices registered after the driver is
>> probed are not bound (probably there are none) and binding via sysfs
>> isn't possible.
>
>
> Acked-by: Andrew Victor <[email protected]>

Applied, thanks everyone.

2009-09-07 14:19:40

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hi Greg,

On Sat, Jul 11, 2009 at 10:05:48AM -0700, Greg KH wrote:
> On Sat, Jul 11, 2009 at 12:00:14PM +0200, Uwe Kleine-K?nig wrote:
> > Hi Greg,
> >
> > > > Are you conviced and took the patch or did you give up to convince me?
> > >
> > > Heh, no, sorry, it got burried in my queue.
> > >
> > > > I still think the patch is correct and I'd like to have it applied.
> > >
> > > Ok, let's test it out in the linux-next tree for a while to make sure it
> > > works properly. Care to send me an updated version?
> > I updated to latest Linus' master. It applies to linux-next from
> > Fri Jul 10 14:44:30 2009 +1000 as is.
>
> Thanks, I'll apply it later today to my trees.
ping?!

> > Back some time I sent a series that fixes many of these bugs. I will
> > update it later today and resend.
>
> Thanks, that would be good to have, to keep the noise down for devices
> we already know about.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-09-19 23:09:58

by Woodhouse, David

[permalink] [raw]
Subject: Re: [PATCH] move sh_flctl's probe function to .devinit.text

On Sat, 2009-07-11 at 13:52 -0700, Uwe Kleine-König wrote:
> A pointer to flctl_probe is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.

... which is what you did for orion_nand, so let's do that for sh_flctl
too.

http://git.infradead.org/mtd-2.6.git/commitdiff/894572a3635

--
David Woodhouse Open Source Technology Centre
[email protected] Intel Corporation

2009-09-21 07:43:17

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] move sh_flctl's probe function to .devinit.text

Hello,

On Sat, Sep 19, 2009 at 04:09:54PM -0700, David Woodhouse wrote:
> On Sat, 2009-07-11 at 13:52 -0700, Uwe Kleine-K?nig wrote:
> > A pointer to flctl_probe is passed to the core via
> > platform_driver_register and so the function must not disappear when the
> > .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> > unbinding and binding a device to the driver via sysfs will result in an
> > oops as does a device being registered late.
> >
> > An alternative to this patch is using platform_driver_probe instead of
> > platform_driver_register plus removing the pointer to the probe function
> > from the struct platform_driver.
>
> ... which is what you did for orion_nand, so let's do that for sh_flctl
> too.
>
> http://git.infradead.org/mtd-2.6.git/commitdiff/894572a3635
Ah, you already did it, fine. If you want (and still can) you can add
my Acked-by:

Best regards, thanks
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-09-21 07:54:44

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hello Greg,

On Sat, Jul 11, 2009 at 10:05:48AM -0700, Greg KH wrote:
> On Sat, Jul 11, 2009 at 12:00:14PM +0200, Uwe Kleine-K?nig wrote:
> > Hi Greg,
> >
> > > > Are you conviced and took the patch or did you give up to convince me?
> > >
> > > Heh, no, sorry, it got burried in my queue.
I assume this is normal for you? :-)

> > > > I still think the patch is correct and I'd like to have it applied.
> > >
> > > Ok, let's test it out in the linux-next tree for a while to make sure it
> > > works properly. Care to send me an updated version?
> > I updated to latest Linus' master. It applies to linux-next from
> > Fri Jul 10 14:44:30 2009 +1000 as is.
>
> Thanks, I'll apply it later today to my trees.
>
> > Back some time I sent a series that fixes many of these bugs. I will
> > update it later today and resend.
>
> Thanks, that would be good to have, to keep the noise down for devices
> we already know about.
As of today I don't see my patches in linux-next. Are you still
interested? Can I ease taking the patches for you somehow? E.g. by
sending a tar containing a quilt series?

Do you think it would be more sensible to convert the drivers to use
platform_driver_probe as this is what some commentors request.
The downside is that these can result in regressions (i.e. no driver
binding if the device is created after the driver is registered).
So this would be merge-window material.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2009-10-09 15:25:32

by Jiri Kosina

[permalink] [raw]
Subject: Re: [PATCH] move stk17ta8's probe function to .devinit.text

On Sat, 11 Jul 2009, Uwe Kleine-König wrote:

> A pointer to stk17ta8_rtc_probe is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.
>
> Signed-off-by: Uwe Kleine-König <[email protected]>
> Cc: Anton Vorontsov <[email protected]>
> Cc: Alessandro Zummo <[email protected]>
> Cc: David Brownell <[email protected]>
> Cc: Paul Mundt <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Hannes Eder <[email protected]>
> Cc: Jiri Kosina <[email protected]>
> Cc: David Brownell <[email protected]>
> ---
> drivers/rtc/rtc-stk17ta8.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
> index 7d1547b..d491eb2 100644
> --- a/drivers/rtc/rtc-stk17ta8.c
> +++ b/drivers/rtc/rtc-stk17ta8.c
> @@ -286,7 +286,7 @@ static struct bin_attribute stk17ta8_nvram_attr = {
> .write = stk17ta8_nvram_write,
> };
>
> -static int __init stk17ta8_rtc_probe(struct platform_device *pdev)
> +static int __devinit stk17ta8_rtc_probe(struct platform_device *pdev)
> {
> struct rtc_device *rtc;
> struct resource *res;

This seems to get lost ... should I take it through my tree, or is anyone
going to merge it? Andrew? Alessandro?

--
Jiri Kosina
SUSE Labs, Novell Inc.

2009-10-09 18:34:10

by Alessandro Zummo

[permalink] [raw]
Subject: Re: [PATCH] move stk17ta8's probe function to .devinit.text

On Fri, 9 Oct 2009 17:24:51 +0200 (CEST)
Jiri Kosina <[email protected]> wrote:

> > -static int __init stk17ta8_rtc_probe(struct platform_device *pdev)
> > +static int __devinit stk17ta8_rtc_probe(struct platform_device *pdev)
> > {
> > struct rtc_device *rtc;
> > struct resource *res;
>
> This seems to get lost ... should I take it through my tree, or is anyone
> going to merge it? Andrew? Alessandro?

Did you sent it to the rtc mailing list? I can't find it in patchwork.
You can carry it in your tree.

Acked-by: Alessandro Zummo <[email protected]>

--

Best regards,

Alessandro Zummo,
Tower Technologies - Torino, Italy

http://www.towertech.it

2009-10-09 21:23:40

by Jiri Kosina

[permalink] [raw]
Subject: Re: [PATCH] move stk17ta8's probe function to .devinit.text

On Fri, 9 Oct 2009, Alessandro Zummo wrote:

> > > -static int __init stk17ta8_rtc_probe(struct platform_device *pdev)
> > > +static int __devinit stk17ta8_rtc_probe(struct platform_device *pdev)
> > > {
> > > struct rtc_device *rtc;
> > > struct resource *res;
> >
> > This seems to get lost ... should I take it through my tree, or is anyone
> > going to merge it? Andrew? Alessandro?
> Did you sent it to the rtc mailing list? I can't find it in patchwork.

It was probably sent only to you personally ...

> You can carry it in your tree.
> Acked-by: Alessandro Zummo <[email protected]>

Queued, thanks.

--
Jiri Kosina
SUSE Labs, Novell Inc.

2009-10-09 21:55:55

by Alessandro Zummo

[permalink] [raw]
Subject: Re: [PATCH] move stk17ta8's probe function to .devinit.text

On Fri, 9 Oct 2009 23:22:52 +0200 (CEST)
Jiri Kosina <[email protected]> wrote:

> It was probably sent only to you personally ...

Always Cc the mailing list, that way it will enter patchwork.
I'm bad enough at patch tracking and patchwork gives a nice help ;)


--

Best regards,

Alessandro Zummo,
Tower Technologies - Torino, Italy

http://www.towertech.it

2010-01-22 17:06:48

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hello,

On Mon, Sep 07, 2009 at 04:19:41PM +0200, Uwe Kleine-K?nig wrote:
> Hi Greg,
>
> On Sat, Jul 11, 2009 at 10:05:48AM -0700, Greg KH wrote:
> > On Sat, Jul 11, 2009 at 12:00:14PM +0200, Uwe Kleine-K?nig wrote:
> > > Hi Greg,
> > >
> > > > > Are you conviced and took the patch or did you give up to convince me?
> > > >
> > > > Heh, no, sorry, it got burried in my queue.
> > > >
> > > > > I still think the patch is correct and I'd like to have it applied.
> > > >
> > > > Ok, let's test it out in the linux-next tree for a while to make sure it
> > > > works properly. Care to send me an updated version?
> > > I updated to latest Linus' master. It applies to linux-next from
> > > Fri Jul 10 14:44:30 2009 +1000 as is.
> >
> > Thanks, I'll apply it later today to my trees.
> ping?!
>
> > > Back some time I sent a series that fixes many of these bugs. I will
> > > update it later today and resend.
> >
> > Thanks, that would be good to have, to keep the noise down for devices
> > we already know about.
ping? I assume you don't have the original mails anymore, so should I
resend?

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2010-01-22 17:40:34

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Fri, Jan 22, 2010 at 06:06:41PM +0100, Uwe Kleine-K?nig wrote:
> Hello,
>
> On Mon, Sep 07, 2009 at 04:19:41PM +0200, Uwe Kleine-K?nig wrote:
> > Hi Greg,
> >
> > On Sat, Jul 11, 2009 at 10:05:48AM -0700, Greg KH wrote:
> > > On Sat, Jul 11, 2009 at 12:00:14PM +0200, Uwe Kleine-K?nig wrote:
> > > > Hi Greg,
> > > >
> > > > > > Are you conviced and took the patch or did you give up to convince me?
> > > > >
> > > > > Heh, no, sorry, it got burried in my queue.
> > > > >
> > > > > > I still think the patch is correct and I'd like to have it applied.
> > > > >
> > > > > Ok, let's test it out in the linux-next tree for a while to make sure it
> > > > > works properly. Care to send me an updated version?
> > > > I updated to latest Linus' master. It applies to linux-next from
> > > > Fri Jul 10 14:44:30 2009 +1000 as is.
> > >
> > > Thanks, I'll apply it later today to my trees.
> > ping?!
> >
> > > > Back some time I sent a series that fixes many of these bugs. I will
> > > > update it later today and resend.
> > >
> > > Thanks, that would be good to have, to keep the noise down for devices
> > > we already know about.
> ping? I assume you don't have the original mails anymore, so should I
> resend?

Yes, sorry.

thanks,

greg k-h

2010-01-22 19:49:29

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] platform_driver_register: warn if probe is in .init.text

Signed-off-by: Uwe Kleine-König <[email protected]>
---
drivers/base/platform.c | 42 ++++++++++++++++++++++++++++++++++++------
include/linux/kernel.h | 2 ++
include/linux/module.h | 12 ++++++++++++
kernel/extable.c | 12 ++++++++++++
kernel/module.c | 36 ++++++++++++++++++++++++++++++++++++
5 files changed, 98 insertions(+), 6 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 58efaf2..92d2a75 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -472,11 +472,7 @@ static void platform_drv_shutdown(struct device *_dev)
drv->shutdown(dev);
}

-/**
- * platform_driver_register
- * @drv: platform driver structure
- */
-int platform_driver_register(struct platform_driver *drv)
+static int __platform_driver_register(struct platform_driver *drv)
{
drv->driver.bus = &platform_bus_type;
if (drv->probe)
@@ -488,6 +484,40 @@ int platform_driver_register(struct platform_driver *drv)

return driver_register(&drv->driver);
}
+
+/**
+ * platform_driver_register
+ * @drv: platform driver structure
+ */
+int platform_driver_register(struct platform_driver *drv)
+{
+ int ret = __platform_driver_register(drv);
+
+#if defined(CONFIG_HOTPLUG)
+ /*
+ * drivers that are registered by platform_driver_register
+ * should not have their probe function in .init.text. The
+ * reason is that a probe can happen after .init.text is
+ * discarded which then results in an oops. The alternatives
+ * are using .devinit.text for the probe function or "register"
+ * with platform_driver_probe.
+ */
+ if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
+ pr_warning("oops-warning: probe function of platform driver %s"
+ " lives in .init.text\n", drv->driver.name);
+#else
+ /*
+ * without HOTPLUG probe functions can be discarded after the driver is
+ * loaded.
+ * There is a little chance for false positives, namely if the driver is
+ * registered after the .init sections are discarded.
+ */
+ if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
+ pr_info("probably the probe function of platform driver %s can"
+ " be moved to .init.text\n", drv->driver.name);
+#endif
+ return ret;
+}
EXPORT_SYMBOL_GPL(platform_driver_register);

/**
@@ -527,7 +557,7 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv,

/* temporary section violation during probe() */
drv->probe = probe;
- retval = code = platform_driver_register(drv);
+ retval = code = __platform_driver_register(drv);

/*
* Fixup that section violation, being paranoid about code scanning
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 328bca6..dc8b191 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -203,8 +203,10 @@ extern char *get_options(const char *str, int nints, int *ints);
extern unsigned long long memparse(const char *ptr, char **retptr);

extern int core_kernel_text(unsigned long addr);
+extern int core_kernel_init_text(unsigned long addr)
extern int __kernel_text_address(unsigned long addr);
extern int kernel_text_address(unsigned long addr);
+extern int kernel_init_text_address(unsigned long addr);
extern int func_ptr_is_kernel_text(void *ptr);

struct pid;
diff --git a/include/linux/module.h b/include/linux/module.h
index 6cb1a3c..00a8bc3 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -391,9 +391,11 @@ static inline int module_is_live(struct module *mod)
}

struct module *__module_text_address(unsigned long addr);
+struct module *__module_init_text_address(unsigned long addr);
struct module *__module_address(unsigned long addr);
bool is_module_address(unsigned long addr);
bool is_module_text_address(unsigned long addr);
+bool is_module_init_text_address(unsigned long addr);

static inline int within_module_core(unsigned long addr, struct module *mod)
{
@@ -566,6 +568,11 @@ static inline struct module *__module_text_address(unsigned long addr)
return NULL;
}

+static inline struct module *__module_init_text_address(unsigned long addr)
+{
+ return NULL;
+}
+
static inline bool is_module_address(unsigned long addr)
{
return false;
@@ -576,6 +583,11 @@ static inline bool is_module_text_address(unsigned long addr)
return false;
}

+static inline bool is_module_init_text_address(unsigned long addr)
+{
+ return false;
+}
+
/* Get/put a kernel symbol (calls should be symmetric) */
#define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
#define symbol_put(x) do { } while(0)
diff --git a/kernel/extable.c b/kernel/extable.c
index 7f8f263..bfd7bda 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -66,6 +66,11 @@ int core_kernel_text(unsigned long addr)
addr <= (unsigned long)_etext)
return 1;

+ return core_kernel_init_text;
+}
+
+int core_kernel_init_text(unsigned long addr)
+{
if (system_state == SYSTEM_BOOTING &&
init_kernel_text(addr))
return 1;
@@ -98,6 +103,13 @@ int kernel_text_address(unsigned long addr)
return is_module_text_address(addr);
}

+int kernel_init_text_address(unsigned long addr)
+{
+ if (core_kernel_init_text(addr))
+ return 1;
+ return is_module_init_text_address(addr);
+}
+
/*
* On some architectures (PPC64, IA64) function pointers
* are actually only tokens to some data that then holds the
diff --git a/kernel/module.c b/kernel/module.c
index f82386b..219827d 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2922,6 +2922,22 @@ bool is_module_text_address(unsigned long addr)
}

/*
+ * is_module_init_text_address - is this address inside a module's .init.text
+ * section?
+ * @addr: the address to check.
+ */
+bool is_module_init_text_address(unsigned long addr)
+{
+ bool ret;
+
+ preempt_disable();
+ ret = __module_init_text_address(addr) != NULL;
+ preempt_enable();
+
+ return ret;
+}
+
+/*
* __module_text_address - get the module whose code contains an address.
* @addr: the address.
*
@@ -2941,6 +2957,26 @@ struct module *__module_text_address(unsigned long addr)
}
EXPORT_SYMBOL_GPL(__module_text_address);

+/*
+ * __module_init_text_address - get the module whose .init.text contains an
+ * address.
+ * @addr: the address.
+ *
+ * Must be called with preempt disabled or module mutex held so that
+ * module doesn't get freed during this.
+ */
+struct module *__module_init_text_address(unsigned long addr)
+{
+ struct module *mod = __module_address(addr);
+ if (mod) {
+ /* Make sure it's within the .init.text section. */
+ if (!within(addr, mod->module_init, mod->init_text_size))
+ mod = NULL;
+ }
+ return mod;
+}
+EXPORT_SYMBOL_GPL(__module_init_text_address);
+
/* Don't grab lock, we're oopsing. */
void print_modules(void)
{
--
1.6.6

2010-01-22 23:49:47

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hi Uwe,

On Fri, Jan 22, 2010 at 08:49:18PM +0100, Uwe Kleine-K?nig wrote:
> +int platform_driver_register(struct platform_driver *drv)
> +{
> + int ret = __platform_driver_register(drv);
> +
> +#if defined(CONFIG_HOTPLUG)
> + /*
> + * drivers that are registered by platform_driver_register
> + * should not have their probe function in .init.text. The
> + * reason is that a probe can happen after .init.text is
> + * discarded which then results in an oops. The alternatives
> + * are using .devinit.text for the probe function or "register"
> + * with platform_driver_probe.
> + */


What about CONFIG_MODULE case (without hotplug)? The driver may be
compiled in (and thus probe will be discarded) but device might be
created by a loadable module which is loaded later.

> + if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
> + pr_warning("oops-warning: probe function of platform driver %s"
> + " lives in .init.text\n", drv->driver.name);
> +#else
> + /*
> + * without HOTPLUG probe functions can be discarded after the driver is
> + * loaded.
> + * There is a little chance for false positives, namely if the driver is
> + * registered after the .init sections are discarded.
> + */
> + if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
> + pr_info("probably the probe function of platform driver %s can"
> + " be moved to .init.text\n", drv->driver.name);

It really depends on the user's (or rather builder's) local
configuration so how can we make this suggestion?

Thanks.

--
Dmitry

2010-01-23 09:49:19

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Helle Dmitry,

On Fri, Jan 22, 2010 at 03:49:37PM -0800, Dmitry Torokhov wrote:
> On Fri, Jan 22, 2010 at 08:49:18PM +0100, Uwe Kleine-K?nig wrote:
> > +int platform_driver_register(struct platform_driver *drv)
> > +{
> > + int ret = __platform_driver_register(drv);
> > +
> > +#if defined(CONFIG_HOTPLUG)
> > + /*
> > + * drivers that are registered by platform_driver_register
> > + * should not have their probe function in .init.text. The
> > + * reason is that a probe can happen after .init.text is
> > + * discarded which then results in an oops. The alternatives
> > + * are using .devinit.text for the probe function or "register"
> > + * with platform_driver_probe.
> > + */
>
>
> What about CONFIG_MODULE case (without hotplug)? The driver may be
> compiled in (and thus probe will be discarded) but device might be
> created by a loadable module which is loaded later.
I don't see the problem here. If the driver is registered using
platform_driver_register and the probe function lives in .init.text it
doesn't matter where the device comes from. If there is one you can
unbind and bind at a later time when .init is already discarded. No?

More general, using platform_driver_register the pointer to the probe
function have to stay valid as it is saved for later use, so it must not
be an .init pointer.

> > + if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
> > + pr_warning("oops-warning: probe function of platform driver %s"
> > + " lives in .init.text\n", drv->driver.name);
> > +#else
> > + /*
> > + * without HOTPLUG probe functions can be discarded after the driver is
> > + * loaded.
> > + * There is a little chance for false positives, namely if the driver is
> > + * registered after the .init sections are discarded.
> > + */
> > + if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
> > + pr_info("probably the probe function of platform driver %s can"
> > + " be moved to .init.text\n", drv->driver.name);
>
> It really depends on the user's (or rather builder's) local
> configuration so how can we make this suggestion?
Can you point out a situation that makes the suggestion wrong? AFAIK
there only the possibility that the driver is loaded after .init is
discarded (as written in the comment).

Thanks
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2010-01-23 20:35:57

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 05/29] move cobalt-lcd's probe function to .devinit.text

A pointer to cobalt_lcdfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Yoichi Yuasa <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Antonino Daplas <[email protected]>
Acked-by: Ralf Baechle <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/cobalt_lcdfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/cobalt_lcdfb.c b/drivers/video/cobalt_lcdfb.c
index 108b89e..5eb61b5 100644
--- a/drivers/video/cobalt_lcdfb.c
+++ b/drivers/video/cobalt_lcdfb.c
@@ -287,7 +287,7 @@ static struct fb_ops cobalt_lcd_fbops = {
.fb_cursor = cobalt_lcdfb_cursor,
};

-static int __init cobalt_lcdfb_probe(struct platform_device *dev)
+static int __devinit cobalt_lcdfb_probe(struct platform_device *dev)
{
struct fb_info *info;
struct resource *res;
--
1.6.6

2010-01-23 20:35:59

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 25/29] move snirm_53c710's probe function to .devinit.text

A pointer to snirm710_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Kay Sievers <[email protected]>
Cc: David Brownell <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
---
drivers/scsi/sni_53c710.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/sni_53c710.c b/drivers/scsi/sni_53c710.c
index 37b3359..56cf0bb 100644
--- a/drivers/scsi/sni_53c710.c
+++ b/drivers/scsi/sni_53c710.c
@@ -64,7 +64,7 @@ static struct scsi_host_template snirm710_template = {
.module = THIS_MODULE,
};

-static int __init snirm710_probe(struct platform_device *dev)
+static int __devinit snirm710_probe(struct platform_device *dev)
{
unsigned long base;
struct NCR_700_Host_Parameters *hostdata;
--
1.6.6

2010-01-23 20:36:08

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 16/29] move omap_hdq's probe function to .devinit.text

A pointer to omap_hdq_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Stanley.Miao <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Madhusudhan Chikkature <[email protected]>
Cc: Felipe Balbi <[email protected]>
---
drivers/w1/masters/omap_hdq.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
index 0d92969..22977d3 100644
--- a/drivers/w1/masters/omap_hdq.c
+++ b/drivers/w1/masters/omap_hdq.c
@@ -72,7 +72,7 @@ struct hdq_data {
int init_trans;
};

-static int __init omap_hdq_probe(struct platform_device *pdev);
+static int __devinit omap_hdq_probe(struct platform_device *pdev);
static int omap_hdq_remove(struct platform_device *pdev);

static struct platform_driver omap_hdq_driver = {
@@ -558,7 +558,7 @@ static void omap_w1_write_byte(void *_hdq, u8 byte)
return;
}

-static int __init omap_hdq_probe(struct platform_device *pdev)
+static int __devinit omap_hdq_probe(struct platform_device *pdev)
{
struct hdq_data *hdq_data;
struct resource *res;
--
1.6.6

2010-01-23 20:36:22

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 23/29] move sharpsl-pm's probe function to .devinit.text

A pointer to sharpsl_pm_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Dmitry Baryshkov <[email protected]>
Cc: Russell King <[email protected]>
Acked-by: Eric Miao <[email protected]>
Cc: Andrew Morton <[email protected]>
---
arch/arm/mach-pxa/sharpsl_pm.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c
index 67229a1..463d874 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.c
+++ b/arch/arm/mach-pxa/sharpsl_pm.c
@@ -900,7 +900,7 @@ static struct platform_suspend_ops sharpsl_pm_ops = {
};
#endif

-static int __init sharpsl_pm_probe(struct platform_device *pdev)
+static int __devinit sharpsl_pm_probe(struct platform_device *pdev)
{
int ret;

--
1.6.6

2010-01-23 20:36:33

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 04/29] move cfag12864bfb's probe function to .devinit.text

A pointer to cfag12864bfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Miguel Ojeda <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Avuton Olrich <[email protected]>
Cc: Antonino Daplas <[email protected]>
---
drivers/auxdisplay/cfag12864bfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/auxdisplay/cfag12864bfb.c b/drivers/auxdisplay/cfag12864bfb.c
index fe3a865..b0ca5a4 100644
--- a/drivers/auxdisplay/cfag12864bfb.c
+++ b/drivers/auxdisplay/cfag12864bfb.c
@@ -81,7 +81,7 @@ static struct fb_ops cfag12864bfb_ops = {
.fb_mmap = cfag12864bfb_mmap,
};

-static int __init cfag12864bfb_probe(struct platform_device *device)
+static int __devinit cfag12864bfb_probe(struct platform_device *device)
{
int ret = -EINVAL;
struct fb_info *info = framebuffer_alloc(0, &device->dev);
--
1.6.6

2010-01-23 20:36:38

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 15/29] move omap24xxcam's probe function to .devinit.text

A pointer to omap24xxcam_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Sakari Ailus <[email protected]>
Acked-by: Trilok Soni <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/media/video/omap24xxcam.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/omap24xxcam.c b/drivers/media/video/omap24xxcam.c
index 7400eac..142c327 100644
--- a/drivers/media/video/omap24xxcam.c
+++ b/drivers/media/video/omap24xxcam.c
@@ -1735,7 +1735,7 @@ static struct v4l2_int_device omap24xxcam = {
*
*/

-static int __init omap24xxcam_probe(struct platform_device *pdev)
+static int __devinit omap24xxcam_probe(struct platform_device *pdev)
{
struct omap24xxcam_device *cam;
struct resource *mem;
--
1.6.6

2010-01-23 20:37:08

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 06/29] move corgi-ssp's probe function to .devinit.text

A pointer to corgi_ssp_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (when having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Eric Miao <[email protected]>
Cc: Russell King <[email protected]>
Cc: Paul Sokolovsky <[email protected]>
Cc: Richard Purdie <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Andrew Morton <[email protected]>
---
arch/arm/mach-pxa/corgi_ssp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-pxa/corgi_ssp.c b/arch/arm/mach-pxa/corgi_ssp.c
index a5ee707..1d9bc11 100644
--- a/arch/arm/mach-pxa/corgi_ssp.c
+++ b/arch/arm/mach-pxa/corgi_ssp.c
@@ -204,7 +204,7 @@ void __init corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo)
ssp_machinfo = machinfo;
}

-static int __init corgi_ssp_probe(struct platform_device *dev)
+static int __devinit corgi_ssp_probe(struct platform_device *dev)
{
int ret;

--
1.6.6

2010-01-23 20:38:07

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 02/29] move am79c961's probe function to .devinit.text

A pointer to am79c961_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Roel Kluin <[email protected]>
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: Andrew Morton <[email protected]>
---
drivers/net/arm/am79c961a.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index 164b37e..1c3c1f9 100644
--- a/drivers/net/arm/am79c961a.c
+++ b/drivers/net/arm/am79c961a.c
@@ -680,7 +680,7 @@ static const struct net_device_ops am79c961_netdev_ops = {
#endif
};

-static int __init am79c961_probe(struct platform_device *pdev)
+static int __devinit am79c961_probe(struct platform_device *pdev)
{
struct resource *res;
struct net_device *dev;
--
1.6.6

2010-01-23 20:37:47

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 18/29] move q40fb's probe function to .devinit.text

A pointer to q40fb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/q40fb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/q40fb.c b/drivers/video/q40fb.c
index 4beac1d..de40a62 100644
--- a/drivers/video/q40fb.c
+++ b/drivers/video/q40fb.c
@@ -85,7 +85,7 @@ static struct fb_ops q40fb_ops = {
.fb_imageblit = cfb_imageblit,
};

-static int __init q40fb_probe(struct platform_device *dev)
+static int __devinit q40fb_probe(struct platform_device *dev)
{
struct fb_info *info;

--
1.6.6

2010-01-23 20:36:17

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 01/29] move acornfb's probe function to .devinit.text

A pointer to acornfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: [email protected]
Cc: Andrew Morton <[email protected]>
---
drivers/video/acornfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c
index 0bcc59e..43d7d50 100644
--- a/drivers/video/acornfb.c
+++ b/drivers/video/acornfb.c
@@ -1221,7 +1221,7 @@ free_unused_pages(unsigned int virtual_start, unsigned int virtual_end)
printk("acornfb: freed %dK memory\n", mb_freed);
}

-static int __init acornfb_probe(struct platform_device *dev)
+static int __devinit acornfb_probe(struct platform_device *dev)
{
unsigned long size;
u_int h_sync, v_sync;
--
1.6.6

2010-01-23 20:37:30

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 26/29] move vesafb's probe function to .devinit.text

A pointer to vesafb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: James Simmons <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Antonino Daplas <[email protected]>
---
drivers/video/vesafb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
index bd37ee1..ef4128c 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -226,7 +226,7 @@ static int __init vesafb_setup(char *options)
return 0;
}

-static int __init vesafb_probe(struct platform_device *dev)
+static int __devinit vesafb_probe(struct platform_device *dev)
{
struct fb_info *info;
int i, err;
--
1.6.6

2010-01-23 20:38:00

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 09/29] move gbefb's probe function to .devinit.text

A pointer to gbefb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Roel Kluin <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Kaj-Michael Lang <[email protected]>
Cc: Martin Michlmayr <[email protected]>
Cc: Joshua Kinard <[email protected]>
---
drivers/video/gbefb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/gbefb.c b/drivers/video/gbefb.c
index 695fa01..5643a35 100644
--- a/drivers/video/gbefb.c
+++ b/drivers/video/gbefb.c
@@ -1128,7 +1128,7 @@ static int __init gbefb_setup(char *options)
return 0;
}

-static int __init gbefb_probe(struct platform_device *p_dev)
+static int __devinit gbefb_probe(struct platform_device *p_dev)
{
int i, ret = 0;
struct fb_info *info;
--
1.6.6

2010-01-23 20:39:30

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 21/29] move sgivwfb's probe function to .devinit.text

A pointer to sgivwfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Adrian Bunk <[email protected]>
Cc: Christoph Hellwig <[email protected]>
---
drivers/video/sgivwfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/sgivwfb.c b/drivers/video/sgivwfb.c
index f860122..7a3a5e2 100644
--- a/drivers/video/sgivwfb.c
+++ b/drivers/video/sgivwfb.c
@@ -745,7 +745,7 @@ int __init sgivwfb_setup(char *options)
/*
* Initialisation
*/
-static int __init sgivwfb_probe(struct platform_device *dev)
+static int __devinit sgivwfb_probe(struct platform_device *dev)
{
struct sgivw_par *par;
struct fb_info *info;
--
1.6.6

2010-01-23 20:39:01

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 11/29] move hgafb's probe function to .devinit.text

A pointer to hgafb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Anton Vorontsov <[email protected]>
Cc: Antonino Daplas <[email protected]>
---
drivers/video/hgafb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/hgafb.c b/drivers/video/hgafb.c
index 0129c04..db9b785 100644
--- a/drivers/video/hgafb.c
+++ b/drivers/video/hgafb.c
@@ -551,7 +551,7 @@ static struct fb_ops hgafb_ops = {
* Initialization
*/

-static int __init hgafb_probe(struct platform_device *pdev)
+static int __devinit hgafb_probe(struct platform_device *pdev)
{
struct fb_info *info;

--
1.6.6

2010-01-23 20:39:37

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 13/29] move hp-wmi's probe function to .devinit.text

A pointer to hp_wmi_bios_setup is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Frans Pop <[email protected]>
Cc: Larry Finger <[email protected]>
Cc: Len Brown <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: Matthew Garrett <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/platform/x86/hp-wmi.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index ad4c414..5c7259a 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -57,7 +57,7 @@ enum hp_wmi_radio {
HPWMI_WWAN = 2,
};

-static int __init hp_wmi_bios_setup(struct platform_device *device);
+static int __devinit hp_wmi_bios_setup(struct platform_device *device);
static int __exit hp_wmi_bios_remove(struct platform_device *device);
static int hp_wmi_resume_handler(struct device *device);

@@ -446,7 +446,7 @@ static void cleanup_sysfs(struct platform_device *device)
device_remove_file(&device->dev, &dev_attr_tablet);
}

-static int __init hp_wmi_bios_setup(struct platform_device *device)
+static int __devinit hp_wmi_bios_setup(struct platform_device *device)
{
int err;
int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
--
1.6.6

2010-01-23 20:38:30

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 29/29] move w100fb's probe function to .devinit.text

A pointer to w100fb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Philipp Zabel <[email protected]>
Cc: Ian Molton <[email protected]>
Cc: Richard Purdie <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Alberto Mardegan <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/w100fb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
index 2376f68..5d22395 100644
--- a/drivers/video/w100fb.c
+++ b/drivers/video/w100fb.c
@@ -628,7 +628,7 @@ static int w100fb_resume(struct platform_device *dev)
#endif


-int __init w100fb_probe(struct platform_device *pdev)
+int __devinit w100fb_probe(struct platform_device *pdev)
{
int err = -EIO;
struct w100fb_mach_info *inf;
--
1.6.6

2010-01-23 20:38:47

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 08/29] move epson1355fb's probe function to .devinit.text

A pointer to epson1355fb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Russell King <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Roland Stigge <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
---
drivers/video/epson1355fb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/epson1355fb.c b/drivers/video/epson1355fb.c
index 2735b79..6d755bb 100644
--- a/drivers/video/epson1355fb.c
+++ b/drivers/video/epson1355fb.c
@@ -602,7 +602,7 @@ static int epson1355fb_remove(struct platform_device *dev)
return 0;
}

-int __init epson1355fb_probe(struct platform_device *dev)
+int __devinit epson1355fb_probe(struct platform_device *dev)
{
struct epson1355_par *default_par;
struct fb_info *info;
--
1.6.6

2010-01-23 20:39:47

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 03/29] move arcfb's probe function to .devinit.text

A pointer to arcfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/arcfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
index c343169..01554d6 100644
--- a/drivers/video/arcfb.c
+++ b/drivers/video/arcfb.c
@@ -504,7 +504,7 @@ static struct fb_ops arcfb_ops = {
.fb_ioctl = arcfb_ioctl,
};

-static int __init arcfb_probe(struct platform_device *dev)
+static int __devinit arcfb_probe(struct platform_device *dev)
{
struct fb_info *info;
int retval = -ENOMEM;
--
1.6.6

2010-01-23 20:40:00

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 10/29] move h1940-bt's probe function to .devinit.text

A pointer to h1940bt_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Russell King <[email protected]>
Cc: Arnaud Patard <[email protected]>
Cc: Ben Dooks <[email protected]>
Cc: Andrew Morton <[email protected]>
---
arch/arm/mach-s3c2410/h1940-bluetooth.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-s3c2410/h1940-bluetooth.c b/arch/arm/mach-s3c2410/h1940-bluetooth.c
index b7d1f8d..a3f3c7b 100644
--- a/arch/arm/mach-s3c2410/h1940-bluetooth.c
+++ b/arch/arm/mach-s3c2410/h1940-bluetooth.c
@@ -56,7 +56,7 @@ static const struct rfkill_ops h1940bt_rfkill_ops = {
.set_block = h1940bt_set_block,
};

-static int __init h1940bt_probe(struct platform_device *pdev)
+static int __devinit h1940bt_probe(struct platform_device *pdev)
{
struct rfkill *rfk;
int ret = 0;
--
1.6.6

2010-01-23 20:40:33

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 22/29] move sgiwd93's probe function to .devinit.text

A pointer to sgiwd93_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Dmitri Vorobiev <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Acked-by: Ralf Baechle <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: peter fuerst <[email protected]>
Cc: Henrik Kretzschmar <[email protected]>
---
drivers/scsi/sgiwd93.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c
index 0807b26..fef0e3c 100644
--- a/drivers/scsi/sgiwd93.c
+++ b/drivers/scsi/sgiwd93.c
@@ -226,7 +226,7 @@ static struct scsi_host_template sgiwd93_template = {
.use_clustering = DISABLE_CLUSTERING,
};

-static int __init sgiwd93_probe(struct platform_device *pdev)
+static int __devinit sgiwd93_probe(struct platform_device *pdev)
{
struct sgiwd93_platform_data *pd = pdev->dev.platform_data;
unsigned char *wdregs = pd->wdregs;
--
1.6.6

2010-01-23 20:35:55

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 12/29] move hitfb's probe function to .devinit.text

A pointer to hitfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Andriy Skulysh <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/hitfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c
index 73c83a8..bf78779 100644
--- a/drivers/video/hitfb.c
+++ b/drivers/video/hitfb.c
@@ -325,7 +325,7 @@ static struct fb_ops hitfb_ops = {
.fb_imageblit = cfb_imageblit,
};

-static int __init hitfb_probe(struct platform_device *dev)
+static int __devinit hitfb_probe(struct platform_device *dev)
{
unsigned short lcdclor, ldr3, ldvndr;
struct fb_info *info;
--
1.6.6

2010-01-23 20:40:50

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 24/29] move sh_mobile_lcdc_fb's probe function to .devinit.text

A pointer to sh_mobile_lcdc_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Magnus Damm <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/sh_mobile_lcdcfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index a69830d..8f3c786 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -907,7 +907,7 @@ static const struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = {

static int sh_mobile_lcdc_remove(struct platform_device *pdev);

-static int __init sh_mobile_lcdc_probe(struct platform_device *pdev)
+static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
{
struct fb_info *info;
struct sh_mobile_lcdc_priv *priv;
--
1.6.6

2010-01-23 20:41:19

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 20/29] move sa11x0-fb's probe function to .devinit.text

A pointer to sa1100fb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Russell King <[email protected]>
Cc: Matthias Kaehlcke <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Pavel Machek <[email protected]>
Cc: Christoph Hellwig <[email protected]>
---
drivers/video/sa1100fb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c
index cdaa873..e8b76d6 100644
--- a/drivers/video/sa1100fb.c
+++ b/drivers/video/sa1100fb.c
@@ -1435,7 +1435,7 @@ static struct sa1100fb_info * __init sa1100fb_init_fbinfo(struct device *dev)
return fbi;
}

-static int __init sa1100fb_probe(struct platform_device *pdev)
+static int __devinit sa1100fb_probe(struct platform_device *pdev)
{
struct sa1100fb_info *fbi;
int ret, irq;
--
1.6.6

2010-01-23 20:41:29

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 17/29] move i2c_omap's probe function to .devinit.text

A pointer to omap_i2c_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Kalle Jokiniemi <[email protected]>
Cc: Tony Lindgren <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Richard Woodruff <[email protected]>
Cc: chandra shekhar <[email protected]>
Cc: Jason P Marini <[email protected]>
Cc: Syed Mohammed Khasim <[email protected]>
Cc: Jarkko Nikula <[email protected]>
Cc: Juha Yrjola <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/i2c/busses/i2c-omap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 0037e31..bd86a85 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -849,7 +849,7 @@ static const struct i2c_algorithm omap_i2c_algo = {
.functionality = omap_i2c_func,
};

-static int __init
+static int __devinit
omap_i2c_probe(struct platform_device *pdev)
{
struct omap_i2c_dev *dev;
--
1.6.6

2010-01-23 20:41:37

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 19/29] move s3c241xfb's probe function to .devinit.text

Pointers to s3c2410fb_probe and s3c2412fb_probe are passed to the core
via platform_driver_register and so the functions must not disappear
when the .init sections are discarded. Otherwise (if also having
HOTPLUG=y) unbinding and binding a device to one of the drivers via
sysfs will result in an oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Russell King <[email protected]>
Cc: Ben Dooks <[email protected]>
Cc: Arnaud Patard <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Vincent Sanders <[email protected]>
---
drivers/video/s3c2410fb.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c
index aac6612..2b094de 100644
--- a/drivers/video/s3c2410fb.c
+++ b/drivers/video/s3c2410fb.c
@@ -1004,12 +1004,12 @@ dealloc_fb:
return ret;
}

-static int __init s3c2410fb_probe(struct platform_device *pdev)
+static int __devinit s3c2410fb_probe(struct platform_device *pdev)
{
return s3c24xxfb_probe(pdev, DRV_S3C2410);
}

-static int __init s3c2412fb_probe(struct platform_device *pdev)
+static int __devinit s3c2412fb_probe(struct platform_device *pdev)
{
return s3c24xxfb_probe(pdev, DRV_S3C2412);
}
--
1.6.6

2010-01-23 20:35:53

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 14/29] move jornada_ssp's probe function to .devinit.text

A pointer to jornada_ssp_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Kristoffer Ericson <[email protected]>
Cc: Russell King <[email protected]>
Cc: Andrew Morton <[email protected]>
---
arch/arm/mach-sa1100/jornada720_ssp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-sa1100/jornada720_ssp.c b/arch/arm/mach-sa1100/jornada720_ssp.c
index 506a5e5..9b6dee5 100644
--- a/arch/arm/mach-sa1100/jornada720_ssp.c
+++ b/arch/arm/mach-sa1100/jornada720_ssp.c
@@ -130,7 +130,7 @@ void jornada_ssp_end(void)
};
EXPORT_SYMBOL(jornada_ssp_end);

-static int __init jornada_ssp_probe(struct platform_device *dev)
+static int __devinit jornada_ssp_probe(struct platform_device *dev)
{
int ret;

--
1.6.6

2010-01-23 20:41:57

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 28/29] move vga16fb's probe function to .devinit.text

A pointer to vga16fb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Roel Kluin <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/vga16fb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c
index 5b29389..76d8dae 100644
--- a/drivers/video/vga16fb.c
+++ b/drivers/video/vga16fb.c
@@ -1293,7 +1293,7 @@ static int vga16fb_setup(char *options)
}
#endif

-static int __init vga16fb_probe(struct platform_device *dev)
+static int __devinit vga16fb_probe(struct platform_device *dev)
{
struct fb_info *info;
struct vga16fb_par *par;
--
1.6.6

2010-01-23 20:42:20

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 27/29] move vfb's probe function to .devinit.text

A pointer to vfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Frans Pop <[email protected]>
Cc: Antonino Daplas <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/video/vfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/vfb.c b/drivers/video/vfb.c
index 050d432..b8ab995 100644
--- a/drivers/video/vfb.c
+++ b/drivers/video/vfb.c
@@ -479,7 +479,7 @@ static int __init vfb_setup(char *options)
* Initialisation
*/

-static int __init vfb_probe(struct platform_device *dev)
+static int __devinit vfb_probe(struct platform_device *dev)
{
struct fb_info *info;
int retval = -ENOMEM;
--
1.6.6

2010-01-23 20:42:36

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 07/29] move efifb's probe function to .devinit.text

A pointer to efifb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Peter Jones <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Jaya Kumar <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Maciej W. Rozycki <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Chandramouli Narayanan <[email protected]>
Cc: Huang Ying <[email protected]>
---
drivers/video/efifb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
index eb12182..2161f21 100644
--- a/drivers/video/efifb.c
+++ b/drivers/video/efifb.c
@@ -201,7 +201,7 @@ static int __init efifb_setup(char *options)
return 0;
}

-static int __init efifb_probe(struct platform_device *dev)
+static int __devinit efifb_probe(struct platform_device *dev)
{
struct fb_info *info;
int err;
--
1.6.6

2010-01-23 23:26:00

by Alexey Dobriyan

[permalink] [raw]
Subject: Re: [PATCH 01/29] move acornfb's probe function to .devinit.text

On Sat, Jan 23, 2010 at 09:35:09PM +0100, Uwe Kleine-K?nig wrote:
> drivers/video/acornfb.c | 2 +-

gods, can you just send one patch for all framebuffer drivers?

2010-01-23 23:28:14

by Alexey Dobriyan

[permalink] [raw]
Subject: Re: [PATCH 01/29] move acornfb's probe function to .devinit.text

On Sat, Jan 23, 2010 at 09:35:09PM +0100, Uwe Kleine-K?nig wrote:
> -static int __init acornfb_probe(struct platform_device *dev)
> +static int __devinit acornfb_probe(struct platform_device *dev)

Even more, if this function is marked __devinit, some other functions
can very well be marked __devinit, can you do this?

2010-01-24 21:09:13

by OGAWA Hirofumi

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Uwe Kleine-K?nig <[email protected]> writes:

> +int platform_driver_register(struct platform_driver *drv)
> +{
> + int ret = __platform_driver_register(drv);
> +
> +#if defined(CONFIG_HOTPLUG)
> + /*
> + * drivers that are registered by platform_driver_register
> + * should not have their probe function in .init.text. The
> + * reason is that a probe can happen after .init.text is
> + * discarded which then results in an oops. The alternatives
> + * are using .devinit.text for the probe function or "register"
> + * with platform_driver_probe.
> + */
> + if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
> + pr_warning("oops-warning: probe function of platform driver %s"
> + " lives in .init.text\n", drv->driver.name);
> +#else
> + /*
> + * without HOTPLUG probe functions can be discarded after the driver is
> + * loaded.
> + * There is a little chance for false positives, namely if the driver is
> + * registered after the .init sections are discarded.
> + */
> + if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
> + pr_info("probably the probe function of platform driver %s can"
> + " be moved to .init.text\n", drv->driver.name);
> +#endif
> + return ret;
> +}

Um..., can't we extend modpost or such one for this? I think the static
analysis is better (assume the changing ->probe dynamically is really
rare).

Thanks.
--
OGAWA Hirofumi <[email protected]>

2010-01-25 17:15:01

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Sat, Jan 23, 2010 at 10:49:16AM +0100, Uwe Kleine-K?nig wrote:
> Helle Dmitry,
>
> On Fri, Jan 22, 2010 at 03:49:37PM -0800, Dmitry Torokhov wrote:
> > On Fri, Jan 22, 2010 at 08:49:18PM +0100, Uwe Kleine-K?nig wrote:
> > > +int platform_driver_register(struct platform_driver *drv)
> > > +{
> > > + int ret = __platform_driver_register(drv);
> > > +
> > > +#if defined(CONFIG_HOTPLUG)
> > > + /*
> > > + * drivers that are registered by platform_driver_register
> > > + * should not have their probe function in .init.text. The
> > > + * reason is that a probe can happen after .init.text is
> > > + * discarded which then results in an oops. The alternatives
> > > + * are using .devinit.text for the probe function or "register"
> > > + * with platform_driver_probe.
> > > + */
> >
> >
> > What about CONFIG_MODULE case (without hotplug)? The driver may be
> > compiled in (and thus probe will be discarded) but device might be
> > created by a loadable module which is loaded later.
> I don't see the problem here.

You are right, without hotplug we don't try to bind to devices that
come in later so we are safe to discard probe.

> If the driver is registered using
> platform_driver_register and the probe function lives in .init.text it
> doesn't matter where the device comes from. If there is one you can
> unbind and bind at a later time when .init is already discarded. No?
>

Yes.

> More general, using platform_driver_register the pointer to the probe
> function have to stay valid as it is saved for later use, so it must not
> be an .init pointer.


>
> > > + if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
> > > + pr_warning("oops-warning: probe function of platform driver %s"
> > > + " lives in .init.text\n", drv->driver.name);
> > > +#else
> > > + /*
> > > + * without HOTPLUG probe functions can be discarded after the driver is
> > > + * loaded.
> > > + * There is a little chance for false positives, namely if the driver is
> > > + * registered after the .init sections are discarded.
> > > + */
> > > + if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
> > > + pr_info("probably the probe function of platform driver %s can"
> > > + " be moved to .init.text\n", drv->driver.name);
> >
> > It really depends on the user's (or rather builder's) local
> > configuration so how can we make this suggestion?
> Can you point out a situation that makes the suggestion wrong? AFAIK
> there only the possibility that the driver is loaded after .init is
> discarded (as written in the comment).
>

The presence of CONFIG_HOTPLUG depends on particular .config, so, for
example, you may not have it set while I have. So you will boot, get the
suggestion, submit a patch, then I will boot and will get a warning that
the probe function is in wrong section.

So in general I wonder if it is possible to request that all probe
functions are marked as __devinit or not marked at all, regardless of
CONFIG_HOTPLUG and CONFIG_MODULE settings.

--
Dmitry

2010-01-25 19:25:44

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hello Dmitry,

> > > > + if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
> > > > + pr_warning("oops-warning: probe function of platform driver %s"
> > > > + " lives in .init.text\n", drv->driver.name);
> > > > +#else
> > > > + /*
> > > > + * without HOTPLUG probe functions can be discarded after the driver is
> > > > + * loaded.
> > > > + * There is a little chance for false positives, namely if the driver is
> > > > + * registered after the .init sections are discarded.
> > > > + */
> > > > + if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
> > > > + pr_info("probably the probe function of platform driver %s can"
> > > > + " be moved to .init.text\n", drv->driver.name);
> > >
> > > It really depends on the user's (or rather builder's) local
> > > configuration so how can we make this suggestion?
> > Can you point out a situation that makes the suggestion wrong? AFAIK
> > there only the possibility that the driver is loaded after .init is
> > discarded (as written in the comment).
> >
>
> The presence of CONFIG_HOTPLUG depends on particular .config, so, for
> example, you may not have it set while I have. So you will boot, get the
> suggestion, submit a patch, then I will boot and will get a warning that
> the probe function is in wrong section.
>
> So in general I wonder if it is possible to request that all probe
> functions are marked as __devinit or not marked at all, regardless of
> CONFIG_HOTPLUG and CONFIG_MODULE settings.
Would you agree if the message would change to

probably the probe function of platform driver %s can be moved
to .devinit.text

?

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2010-01-25 19:39:30

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Mon, Jan 25, 2010 at 08:25:40PM +0100, Uwe Kleine-K?nig wrote:
> Hello Dmitry,
>
> > > > > + if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
> > > > > + pr_warning("oops-warning: probe function of platform driver %s"
> > > > > + " lives in .init.text\n", drv->driver.name);
> > > > > +#else
> > > > > + /*
> > > > > + * without HOTPLUG probe functions can be discarded after the driver is
> > > > > + * loaded.
> > > > > + * There is a little chance for false positives, namely if the driver is
> > > > > + * registered after the .init sections are discarded.
> > > > > + */
> > > > > + if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
> > > > > + pr_info("probably the probe function of platform driver %s can"
> > > > > + " be moved to .init.text\n", drv->driver.name);
> > > >
> > > > It really depends on the user's (or rather builder's) local
> > > > configuration so how can we make this suggestion?
> > > Can you point out a situation that makes the suggestion wrong? AFAIK
> > > there only the possibility that the driver is loaded after .init is
> > > discarded (as written in the comment).
> > >
> >
> > The presence of CONFIG_HOTPLUG depends on particular .config, so, for
> > example, you may not have it set while I have. So you will boot, get the
> > suggestion, submit a patch, then I will boot and will get a warning that
> > the probe function is in wrong section.
> >
> > So in general I wonder if it is possible to request that all probe
> > functions are marked as __devinit or not marked at all, regardless of
> > CONFIG_HOTPLUG and CONFIG_MODULE settings.
> Would you agree if the message would change to
>
> probably the probe function of platform driver %s can be moved
> to .devinit.text
>
> ?

How about "Consider marking the probe function as '__devinit'"?

--
Dmitry

2010-01-26 08:46:52

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 01/29] move acornfb's probe function to .devinit.text

On Sun, Jan 24, 2010 at 01:25:58 +0200, Alexey Dobriyan wrote:
> gods, can you just send one patch for all framebuffer drivers?
Well, I thought one logical change per changeset is the favourite way to
go. And as the people Cc:d are different I think most people prefer it
this way.

On Sun, Jan 24, 2010 at 01:28:13AM +0200, Alexey Dobriyan wrote:
> On Sat, Jan 23, 2010 at 09:35:09PM +0100, Uwe Kleine-K?nig wrote:
> > -static int __init acornfb_probe(struct platform_device *dev)
> > +static int __devinit acornfb_probe(struct platform_device *dev)
>
> Even more, if this function is marked __devinit, some other functions
> can very well be marked __devinit, can you do this?
Probably, the big pro after my patch is that modpost can warn about
this. Actually this applies to all (initially) over 50 patches in this
series. If you take my patches, squash them together and fix all called
functions, I'm happy, too.

If you don't I might come back to this and do it myself.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2010-01-26 08:47:47

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hello,

On Mon, Jan 25, 2010 at 06:09:01AM +0900, OGAWA Hirofumi wrote:
> Uwe Kleine-K?nig <[email protected]> writes:
>
> > +int platform_driver_register(struct platform_driver *drv)
> > +{
> > + int ret = __platform_driver_register(drv);
> > +
> > +#if defined(CONFIG_HOTPLUG)
> > + /*
> > + * drivers that are registered by platform_driver_register
> > + * should not have their probe function in .init.text. The
> > + * reason is that a probe can happen after .init.text is
> > + * discarded which then results in an oops. The alternatives
> > + * are using .devinit.text for the probe function or "register"
> > + * with platform_driver_probe.
> > + */
> > + if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
> > + pr_warning("oops-warning: probe function of platform driver %s"
> > + " lives in .init.text\n", drv->driver.name);
> > +#else
> > + /*
> > + * without HOTPLUG probe functions can be discarded after the driver is
> > + * loaded.
> > + * There is a little chance for false positives, namely if the driver is
> > + * registered after the .init sections are discarded.
> > + */
> > + if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
> > + pr_info("probably the probe function of platform driver %s can"
> > + " be moved to .init.text\n", drv->driver.name);
> > +#endif
> > + return ret;
> > +}
>
> Um..., can't we extend modpost or such one for this? I think the static
> analysis is better (assume the changing ->probe dynamically is really
> rare).
I like the idea and will look later into modpost if this can be done
there.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2010-01-26 08:59:31

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hello Greg,

On Fri, Jan 22, 2010 at 09:38:46AM -0800, Greg KH wrote:
> On Fri, Jan 22, 2010 at 06:06:41PM +0100, Uwe Kleine-K?nig wrote:
> > Hello,
> >
> > On Mon, Sep 07, 2009 at 04:19:41PM +0200, Uwe Kleine-K?nig wrote:
> > > Hi Greg,
> > >
> > > On Sat, Jul 11, 2009 at 10:05:48AM -0700, Greg KH wrote:
> > > > On Sat, Jul 11, 2009 at 12:00:14PM +0200, Uwe Kleine-K?nig wrote:
> > > > > Hi Greg,
> > > > >
> > > > > > > Are you conviced and took the patch or did you give up to convince me?
> > > > > >
> > > > > > Heh, no, sorry, it got burried in my queue.
> > > > > >
> > > > > > > I still think the patch is correct and I'd like to have it applied.
> > > > > >
> > > > > > Ok, let's test it out in the linux-next tree for a while to make sure it
> > > > > > works properly. Care to send me an updated version?
> > > > > I updated to latest Linus' master. It applies to linux-next from
> > > > > Fri Jul 10 14:44:30 2009 +1000 as is.
> > > >
> > > > Thanks, I'll apply it later today to my trees.
> > > ping?!
> > >
> > > > > Back some time I sent a series that fixes many of these bugs. I will
> > > > > update it later today and resend.
> > > >
> > > > Thanks, that would be good to have, to keep the noise down for devices
> > > > we already know about.
> > ping? I assume you don't have the original mails anymore, so should I
> > resend?
>
> Yes, sorry.
I would really appreciate if you'd take the patches as it is quite some
work to update and verify the patches are still needed as changing
platform_driver_register to platform_driver_probe doesn't conflict with
this series.

So can you please look into that before they are swapped out of your
inbox the third(?) time?

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2010-01-26 14:43:40

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Tue, Jan 26, 2010 at 09:59:28AM +0100, Uwe Kleine-K?nig wrote:
> Hello Greg,
>
> On Fri, Jan 22, 2010 at 09:38:46AM -0800, Greg KH wrote:
> > On Fri, Jan 22, 2010 at 06:06:41PM +0100, Uwe Kleine-K?nig wrote:
> > > Hello,
> > >
> > > On Mon, Sep 07, 2009 at 04:19:41PM +0200, Uwe Kleine-K?nig wrote:
> > > > Hi Greg,
> > > >
> > > > On Sat, Jul 11, 2009 at 10:05:48AM -0700, Greg KH wrote:
> > > > > On Sat, Jul 11, 2009 at 12:00:14PM +0200, Uwe Kleine-K?nig wrote:
> > > > > > Hi Greg,
> > > > > >
> > > > > > > > Are you conviced and took the patch or did you give up to convince me?
> > > > > > >
> > > > > > > Heh, no, sorry, it got burried in my queue.
> > > > > > >
> > > > > > > > I still think the patch is correct and I'd like to have it applied.
> > > > > > >
> > > > > > > Ok, let's test it out in the linux-next tree for a while to make sure it
> > > > > > > works properly. Care to send me an updated version?
> > > > > > I updated to latest Linus' master. It applies to linux-next from
> > > > > > Fri Jul 10 14:44:30 2009 +1000 as is.
> > > > >
> > > > > Thanks, I'll apply it later today to my trees.
> > > > ping?!
> > > >
> > > > > > Back some time I sent a series that fixes many of these bugs. I will
> > > > > > update it later today and resend.
> > > > >
> > > > > Thanks, that would be good to have, to keep the noise down for devices
> > > > > we already know about.
> > > ping? I assume you don't have the original mails anymore, so should I
> > > resend?
> >
> > Yes, sorry.
> I would really appreciate if you'd take the patches as it is quite some
> work to update and verify the patches are still needed as changing
> platform_driver_register to platform_driver_probe doesn't conflict with
> this series.
>
> So can you please look into that before they are swapped out of your
> inbox the third(?) time?

Will do, give me a day or so.

thanks,

greg k-h

2010-01-26 16:21:10

by Peter Jones

[permalink] [raw]
Subject: Re: [PATCH 07/29] move efifb's probe function to .devinit.text

On 01/23/2010 03:35 PM, Uwe Kleine-König wrote:
> A pointer to efifb_probe is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.

__devinit looks reasonable enough to me.

Acked-By: Peter Jones <[email protected]>

>
> Signed-off-by: Uwe Kleine-König <[email protected]>
> Cc: Peter Jones <[email protected]>
> Cc: Krzysztof Helt <[email protected]>
> Cc: Geert Uytterhoeven <[email protected]>
> Cc: Jaya Kumar <[email protected]>
> Cc: Ralf Baechle <[email protected]>
> Cc: Maciej W. Rozycki <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Chandramouli Narayanan <[email protected]>
> Cc: Huang Ying <[email protected]>
> ---
> drivers/video/efifb.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
> index eb12182..2161f21 100644
> --- a/drivers/video/efifb.c
> +++ b/drivers/video/efifb.c
> @@ -201,7 +201,7 @@ static int __init efifb_setup(char *options)
> return 0;
> }
>
> -static int __init efifb_probe(struct platform_device *dev)
> +static int __devinit efifb_probe(struct platform_device *dev)
> {
> struct fb_info *info;
> int err;


--
Peter

The trouble with the global village are all the global village idiots.
-- Paul Ginsparg

2010-01-28 01:23:58

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Tue, Jan 26, 2010 at 09:47:41AM +0100, Uwe Kleine-K?nig wrote:
> Hello,
>
> On Mon, Jan 25, 2010 at 06:09:01AM +0900, OGAWA Hirofumi wrote:
> > Uwe Kleine-K?nig <[email protected]> writes:
> >
> > > +int platform_driver_register(struct platform_driver *drv)
> > > +{
> > > + int ret = __platform_driver_register(drv);
> > > +
> > > +#if defined(CONFIG_HOTPLUG)
> > > + /*
> > > + * drivers that are registered by platform_driver_register
> > > + * should not have their probe function in .init.text. The
> > > + * reason is that a probe can happen after .init.text is
> > > + * discarded which then results in an oops. The alternatives
> > > + * are using .devinit.text for the probe function or "register"
> > > + * with platform_driver_probe.
> > > + */
> > > + if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
> > > + pr_warning("oops-warning: probe function of platform driver %s"
> > > + " lives in .init.text\n", drv->driver.name);
> > > +#else
> > > + /*
> > > + * without HOTPLUG probe functions can be discarded after the driver is
> > > + * loaded.
> > > + * There is a little chance for false positives, namely if the driver is
> > > + * registered after the .init sections are discarded.
> > > + */
> > > + if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
> > > + pr_info("probably the probe function of platform driver %s can"
> > > + " be moved to .init.text\n", drv->driver.name);
> > > +#endif
> > > + return ret;
> > > +}
> >
> > Um..., can't we extend modpost or such one for this? I think the static
> > analysis is better (assume the changing ->probe dynamically is really
> > rare).
> I like the idea and will look later into modpost if this can be done
> there.

That would be nice to do instead, as we already do checks like this
today, and might make more sense.

And could you do it for all probe functions, and not just the platform
devices? Don't all busses have this same problem?

thanks,

greg k-h

2010-01-28 18:04:26

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Tue, Jan 26, 2010 at 09:59:28AM +0100, Uwe Kleine-K?nig wrote:
> Hello Greg,
>
> On Fri, Jan 22, 2010 at 09:38:46AM -0800, Greg KH wrote:
> > On Fri, Jan 22, 2010 at 06:06:41PM +0100, Uwe Kleine-K?nig wrote:
> > > Hello,
> > >
> > > On Mon, Sep 07, 2009 at 04:19:41PM +0200, Uwe Kleine-K?nig wrote:
> > > > Hi Greg,
> > > >
> > > > On Sat, Jul 11, 2009 at 10:05:48AM -0700, Greg KH wrote:
> > > > > On Sat, Jul 11, 2009 at 12:00:14PM +0200, Uwe Kleine-K?nig wrote:
> > > > > > Hi Greg,
> > > > > >
> > > > > > > > Are you conviced and took the patch or did you give up to convince me?
> > > > > > >
> > > > > > > Heh, no, sorry, it got burried in my queue.
> > > > > > >
> > > > > > > > I still think the patch is correct and I'd like to have it applied.
> > > > > > >
> > > > > > > Ok, let's test it out in the linux-next tree for a while to make sure it
> > > > > > > works properly. Care to send me an updated version?
> > > > > > I updated to latest Linus' master. It applies to linux-next from
> > > > > > Fri Jul 10 14:44:30 2009 +1000 as is.
> > > > >
> > > > > Thanks, I'll apply it later today to my trees.
> > > > ping?!
> > > >
> > > > > > Back some time I sent a series that fixes many of these bugs. I will
> > > > > > update it later today and resend.
> > > > >
> > > > > Thanks, that would be good to have, to keep the noise down for devices
> > > > > we already know about.
> > > ping? I assume you don't have the original mails anymore, so should I
> > > resend?
> >
> > Yes, sorry.
> I would really appreciate if you'd take the patches as it is quite some
> work to update and verify the patches are still needed as changing
> platform_driver_register to platform_driver_probe doesn't conflict with
> this series.
>
> So can you please look into that before they are swapped out of your
> inbox the third(?) time?

I think the video ones can be all in one patch, that makes it easier for
me to track and apply. Same goes for any others you can merge together.

thanks,

greg k-h

2010-01-30 20:44:38

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hello,

On Wed, Jan 27, 2010 at 05:14:03PM -0800, Greg KH wrote:
> On Tue, Jan 26, 2010 at 09:47:41AM +0100, Uwe Kleine-K?nig wrote:
> > On Mon, Jan 25, 2010 at 06:09:01AM +0900, OGAWA Hirofumi wrote:
> > > Uwe Kleine-K?nig <[email protected]> writes:
> > > > +int platform_driver_register(struct platform_driver *drv)
> > > > +{
> > > > + int ret = __platform_driver_register(drv);
> > > > +
> > > > +#if defined(CONFIG_HOTPLUG)
> > > > + /*
> > > > + * drivers that are registered by platform_driver_register
> > > > + * should not have their probe function in .init.text. The
> > > > + * reason is that a probe can happen after .init.text is
> > > > + * discarded which then results in an oops. The alternatives
> > > > + * are using .devinit.text for the probe function or "register"
> > > > + * with platform_driver_probe.
> > > > + */
> > > > + if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
> > > > + pr_warning("oops-warning: probe function of platform driver %s"
> > > > + " lives in .init.text\n", drv->driver.name);
> > > > +#else
> > > > + /*
> > > > + * without HOTPLUG probe functions can be discarded after the driver is
> > > > + * loaded.
> > > > + * There is a little chance for false positives, namely if the driver is
> > > > + * registered after the .init sections are discarded.
> > > > + */
> > > > + if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
> > > > + pr_info("probably the probe function of platform driver %s can"
> > > > + " be moved to .init.text\n", drv->driver.name);
> > > > +#endif
> > > > + return ret;
> > > > +}
> > >
> > > Um..., can't we extend modpost or such one for this? I think the static
> > > analysis is better (assume the changing ->probe dynamically is really
> > > rare).
> > I like the idea and will look later into modpost if this can be done
> > there.
>
> That would be nice to do instead, as we already do checks like this
> today, and might make more sense.
>
> And could you do it for all probe functions, and not just the platform
> devices? Don't all busses have this same problem?
I think so, yes. And I made some changes to modpost to detect those.
Tested on two defconfigs (ARCH=arm) it yields three hits, all valid.

I send the series as reply to this mail or you can get it via git, see
below.

The first six patches should not change behaviour, only do some cleanup
and preparation for the last patch.

The most interesting patch is "make symbol white list a per mismatch
type variable". It allows a white list per section mismatch type and
so allows to say:

*driver (in .data) might reference to .devinit.text but not
.init.text

That's what the last patch does.

Best regards
Uwe

The following changes since commit 499a2673713c85734a54c37dd90b4b729de399c4:
Linus Torvalds (1):
Merge branch 'for-linus' of git://git.kernel.org/.../dtor/input

are available in the git repository at:

git://git.pengutronix.de/git/ukl/linux-2.6.git modpost

Uwe Kleine-K?nig (7):
modpost: members of *driver structs should not point to __init functions
modpost: define ALL_XXX{IN,EX}IT_SECTIONS
modpost: give most mismatch constants a better name
modpost: pass around const struct sectioncheck * instead of enum mismatch
modpost: remove now unused NO_MISMATCH constant
modpost: make symbol white list a per mismatch type variable
modpost: don't allow *driver to reference .init.*

scripts/mod/modpost.c | 152 ++++++++++++++++++++++++++++---------------------
1 files changed, 88 insertions(+), 64 deletions(-)

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2010-01-30 20:47:06

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 3/7] modpost: give most mismatch constants a better name

Signed-off-by: Uwe Kleine-König <[email protected]>
---
scripts/mod/modpost.c | 56 ++++++++++++++++++++++++------------------------
1 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index dbab53a..598d54a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -836,14 +836,14 @@ static const char *linker_symbols[] =

enum mismatch {
NO_MISMATCH,
- TEXT_TO_INIT,
- DATA_TO_INIT,
- TEXT_TO_EXIT,
- DATA_TO_EXIT,
- XXXINIT_TO_INIT,
- XXXEXIT_TO_EXIT,
- INIT_TO_EXIT,
- EXIT_TO_INIT,
+ TEXT_TO_ANY_INIT,
+ DATA_TO_ANY_INIT,
+ TEXT_TO_ANY_EXIT,
+ DATA_TO_ANY_EXIT,
+ XXXINIT_TO_SOME_INIT,
+ XXXEXIT_TO_SOME_EXIT,
+ ANY_INIT_TO_ANY_EXIT,
+ ANY_EXIT_TO_ANY_INIT,
EXPORT_TO_INIT_EXIT,
};

@@ -860,70 +860,70 @@ const struct sectioncheck sectioncheck[] = {
{
.fromsec = { TEXT_SECTIONS, NULL },
.tosec = { ALL_INIT_SECTIONS, NULL },
- .mismatch = TEXT_TO_INIT,
+ .mismatch = TEXT_TO_ANY_INIT,
},
{
.fromsec = { DATA_SECTIONS, NULL },
.tosec = { ALL_INIT_SECTIONS, NULL },
- .mismatch = DATA_TO_INIT,
+ .mismatch = DATA_TO_ANY_INIT,
},
{
.fromsec = { TEXT_SECTIONS, NULL },
.tosec = { ALL_EXIT_SECTIONS, NULL },
- .mismatch = TEXT_TO_EXIT,
+ .mismatch = TEXT_TO_ANY_EXIT,
},
{
.fromsec = { DATA_SECTIONS, NULL },
.tosec = { ALL_EXIT_SECTIONS, NULL },
- .mismatch = DATA_TO_EXIT,
+ .mismatch = DATA_TO_ANY_EXIT,
},
/* Do not reference init code/data from devinit/cpuinit/meminit code/data */
{
.fromsec = { ALL_XXXINIT_SECTIONS, NULL },
.tosec = { INIT_SECTIONS, NULL },
- .mismatch = XXXINIT_TO_INIT,
+ .mismatch = XXXINIT_TO_SOME_INIT,
},
/* Do not reference cpuinit code/data from meminit code/data */
{
.fromsec = { MEM_INIT_SECTIONS, NULL },
.tosec = { CPU_INIT_SECTIONS, NULL },
- .mismatch = XXXINIT_TO_INIT,
+ .mismatch = XXXINIT_TO_SOME_INIT,
},
/* Do not reference meminit code/data from cpuinit code/data */
{
.fromsec = { CPU_INIT_SECTIONS, NULL },
.tosec = { MEM_INIT_SECTIONS, NULL },
- .mismatch = XXXINIT_TO_INIT,
+ .mismatch = XXXINIT_TO_SOME_INIT,
},
/* Do not reference exit code/data from devexit/cpuexit/memexit code/data */
{
.fromsec = { ALL_XXXEXIT_SECTIONS, NULL },
.tosec = { EXIT_SECTIONS, NULL },
- .mismatch = XXXEXIT_TO_EXIT,
+ .mismatch = XXXEXIT_TO_SOME_EXIT,
},
/* Do not reference cpuexit code/data from memexit code/data */
{
.fromsec = { MEM_EXIT_SECTIONS, NULL },
.tosec = { CPU_EXIT_SECTIONS, NULL },
- .mismatch = XXXEXIT_TO_EXIT,
+ .mismatch = XXXEXIT_TO_SOME_EXIT,
},
/* Do not reference memexit code/data from cpuexit code/data */
{
.fromsec = { CPU_EXIT_SECTIONS, NULL },
.tosec = { MEM_EXIT_SECTIONS, NULL },
- .mismatch = XXXEXIT_TO_EXIT,
+ .mismatch = XXXEXIT_TO_SOME_EXIT,
},
/* Do not use exit code/data from init code */
{
.fromsec = { ALL_INIT_SECTIONS, NULL },
.tosec = { ALL_EXIT_SECTIONS, NULL },
- .mismatch = INIT_TO_EXIT,
+ .mismatch = ANY_INIT_TO_ANY_EXIT,
},
/* Do not use init code/data from exit code */
{
.fromsec = { ALL_EXIT_SECTIONS, NULL },
.tosec = { ALL_INIT_SECTIONS, NULL },
- .mismatch = EXIT_TO_INIT,
+ .mismatch = ANY_EXIT_TO_ANY_INIT,
},
/* Do not export init/exit functions or data */
{
@@ -1190,7 +1190,7 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
tosym, to_p);

switch (mismatch) {
- case TEXT_TO_INIT:
+ case TEXT_TO_ANY_INIT:
fprintf(stderr,
"The function %s%s() references\n"
"the %s %s%s%s.\n"
@@ -1200,7 +1200,7 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
to, sec2annotation(tosec), tosym, to_p,
fromsym, sec2annotation(tosec), tosym);
break;
- case DATA_TO_INIT: {
+ case DATA_TO_ANY_INIT: {
const char **s = symbol_white_list;
fprintf(stderr,
"The variable %s references\n"
@@ -1214,14 +1214,14 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
fprintf(stderr, "\n");
break;
}
- case TEXT_TO_EXIT:
+ case TEXT_TO_ANY_EXIT:
fprintf(stderr,
"The function %s() references a %s in an exit section.\n"
"Often the %s %s%s has valid usage outside the exit section\n"
"and the fix is to remove the %sannotation of %s.\n",
fromsym, to, to, tosym, to_p, sec2annotation(tosec), tosym);
break;
- case DATA_TO_EXIT: {
+ case DATA_TO_ANY_EXIT: {
const char **s = symbol_white_list;
fprintf(stderr,
"The variable %s references\n"
@@ -1235,8 +1235,8 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
fprintf(stderr, "\n");
break;
}
- case XXXINIT_TO_INIT:
- case XXXEXIT_TO_EXIT:
+ case XXXINIT_TO_SOME_INIT:
+ case XXXEXIT_TO_SOME_EXIT:
fprintf(stderr,
"The %s %s%s%s references\n"
"a %s %s%s%s.\n"
@@ -1246,7 +1246,7 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
to, sec2annotation(tosec), tosym, to_p,
tosym, fromsym, tosym);
break;
- case INIT_TO_EXIT:
+ case ANY_INIT_TO_ANY_EXIT:
fprintf(stderr,
"The %s %s%s%s references\n"
"a %s %s%s%s.\n"
@@ -1259,7 +1259,7 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
to, sec2annotation(tosec), tosym, to_p,
sec2annotation(tosec), tosym, to_p);
break;
- case EXIT_TO_INIT:
+ case ANY_EXIT_TO_ANY_INIT:
fprintf(stderr,
"The %s %s%s%s references\n"
"a %s %s%s%s.\n"
--
1.6.6

2010-01-30 20:47:15

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 5/7] modpost: remove now unused NO_MISMATCH constant

Signed-off-by: Uwe Kleine-König <[email protected]>
---
scripts/mod/modpost.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 3f0380b..a94bd10 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -835,7 +835,6 @@ static const char *linker_symbols[] =
{ "__init_begin", "_sinittext", "_einittext", NULL };

enum mismatch {
- NO_MISMATCH,
TEXT_TO_ANY_INIT,
DATA_TO_ANY_INIT,
TEXT_TO_ANY_EXIT,
@@ -1280,8 +1279,6 @@ static void report_sec_mismatch(const char *modname,
"Fix this by removing the %sannotation of %s "
"or drop the export.\n",
tosym, sec2annotation(tosec), sec2annotation(tosec), tosym);
- case NO_MISMATCH:
- /* To get warnings on missing members */
break;
}
fprintf(stderr, "\n");
--
1.6.6

2010-01-30 20:47:24

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 4/7] modpost: pass around const struct sectioncheck * instead of enum mismatch

This prepares having a per-check whitelist of symbol names.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
scripts/mod/modpost.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 598d54a..3f0380b 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -933,7 +933,8 @@ const struct sectioncheck sectioncheck[] = {
}
};

-static int section_mismatch(const char *fromsec, const char *tosec)
+static const struct sectioncheck *section_mismatch(
+ const char *fromsec, const char *tosec)
{
int i;
int elems = sizeof(sectioncheck) / sizeof(struct sectioncheck);
@@ -942,10 +943,10 @@ static int section_mismatch(const char *fromsec, const char *tosec)
for (i = 0; i < elems; i++) {
if (match(fromsec, check->fromsec) &&
match(tosec, check->tosec))
- return check->mismatch;
+ return check;
check++;
}
- return NO_MISMATCH;
+ return NULL;
}

/**
@@ -1158,7 +1159,8 @@ static int is_function(Elf_Sym *sym)
* Try to find symbols near it so user can find it.
* Check whitelist before warning - it may be a false positive.
*/
-static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
+static void report_sec_mismatch(const char *modname,
+ const struct sectioncheck *mismatch,
const char *fromsec,
unsigned long long fromaddr,
const char *fromsym,
@@ -1189,7 +1191,7 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
modname, fromsec, fromaddr, from, fromsym, from_p, to, tosec,
tosym, to_p);

- switch (mismatch) {
+ switch (mismatch->mismatch) {
case TEXT_TO_ANY_INIT:
fprintf(stderr,
"The function %s%s() references\n"
@@ -1289,11 +1291,11 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
Elf_Rela *r, Elf_Sym *sym, const char *fromsec)
{
const char *tosec;
- enum mismatch mismatch;
+ const struct sectioncheck *mismatch;

tosec = sec_name(elf, sym->st_shndx);
mismatch = section_mismatch(fromsec, tosec);
- if (mismatch != NO_MISMATCH) {
+ if (mismatch) {
Elf_Sym *to;
Elf_Sym *from;
const char *tosym;
--
1.6.6

2010-01-30 20:47:30

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 1/7] modpost: members of *driver structs should not point to __init functions

Either the functions referred to in a driver struct should live in
.devinit or the driver should be registered using platform_driver_probe
(or equivalent for different driver types) with ->probe being NULL.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
scripts/mod/modpost.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 2092361..713b62e 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -961,7 +961,7 @@ static int section_mismatch(const char *fromsec, const char *tosec)
* Pattern 2:
* Many drivers utilise a *driver container with references to
* add, remove, probe functions etc.
- * These functions may often be marked __init and we do not want to
+ * These functions may often be marked __devinit and we do not want to
* warn here.
* the pattern is identified by:
* tosec = init or exit section
--
1.6.6

2010-01-30 20:47:38

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 6/7] modpost: make symbol white list a per mismatch type variable

Signed-off-by: Uwe Kleine-König <[email protected]>
---
scripts/mod/modpost.c | 49 +++++++++++++++++++++++++++++++------------------
1 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index a94bd10..5dbe4db 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -817,18 +817,15 @@ static const char *data_sections[] = { DATA_SECTIONS, NULL };


/* symbols in .data that may refer to init/exit sections */
-static const char *symbol_white_list[] =
-{
- "*driver",
- "*_template", /* scsi uses *_template a lot */
- "*_timer", /* arm uses ops structures named _timer a lot */
- "*_sht", /* scsi also used *_sht to some extent */
- "*_ops",
- "*_probe",
- "*_probe_one",
- "*_console",
- NULL
-};
+#define DEFAULT_SYMBOL_WHITE_LIST \
+ "*driver", \
+ "*_template", /* scsi uses *_template a lot */ \
+ "*_timer", /* arm uses ops structures named _timer a lot */ \
+ "*_sht", /* scsi also used *_sht to some extent */ \
+ "*_ops", \
+ "*_probe", \
+ "*_probe_one", \
+ "*_console"

static const char *head_sections[] = { ".head.text*", NULL };
static const char *linker_symbols[] =
@@ -850,6 +847,7 @@ struct sectioncheck {
const char *fromsec[20];
const char *tosec[20];
enum mismatch mismatch;
+ const char *symbol_white_list[20];
};

const struct sectioncheck sectioncheck[] = {
@@ -860,75 +858,88 @@ const struct sectioncheck sectioncheck[] = {
.fromsec = { TEXT_SECTIONS, NULL },
.tosec = { ALL_INIT_SECTIONS, NULL },
.mismatch = TEXT_TO_ANY_INIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
{
.fromsec = { DATA_SECTIONS, NULL },
.tosec = { ALL_INIT_SECTIONS, NULL },
.mismatch = DATA_TO_ANY_INIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
{
.fromsec = { TEXT_SECTIONS, NULL },
.tosec = { ALL_EXIT_SECTIONS, NULL },
.mismatch = TEXT_TO_ANY_EXIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
{
.fromsec = { DATA_SECTIONS, NULL },
.tosec = { ALL_EXIT_SECTIONS, NULL },
.mismatch = DATA_TO_ANY_EXIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
/* Do not reference init code/data from devinit/cpuinit/meminit code/data */
{
.fromsec = { ALL_XXXINIT_SECTIONS, NULL },
.tosec = { INIT_SECTIONS, NULL },
.mismatch = XXXINIT_TO_SOME_INIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
/* Do not reference cpuinit code/data from meminit code/data */
{
.fromsec = { MEM_INIT_SECTIONS, NULL },
.tosec = { CPU_INIT_SECTIONS, NULL },
.mismatch = XXXINIT_TO_SOME_INIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
/* Do not reference meminit code/data from cpuinit code/data */
{
.fromsec = { CPU_INIT_SECTIONS, NULL },
.tosec = { MEM_INIT_SECTIONS, NULL },
.mismatch = XXXINIT_TO_SOME_INIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
/* Do not reference exit code/data from devexit/cpuexit/memexit code/data */
{
.fromsec = { ALL_XXXEXIT_SECTIONS, NULL },
.tosec = { EXIT_SECTIONS, NULL },
.mismatch = XXXEXIT_TO_SOME_EXIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
/* Do not reference cpuexit code/data from memexit code/data */
{
.fromsec = { MEM_EXIT_SECTIONS, NULL },
.tosec = { CPU_EXIT_SECTIONS, NULL },
.mismatch = XXXEXIT_TO_SOME_EXIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
/* Do not reference memexit code/data from cpuexit code/data */
{
.fromsec = { CPU_EXIT_SECTIONS, NULL },
.tosec = { MEM_EXIT_SECTIONS, NULL },
.mismatch = XXXEXIT_TO_SOME_EXIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
/* Do not use exit code/data from init code */
{
.fromsec = { ALL_INIT_SECTIONS, NULL },
.tosec = { ALL_EXIT_SECTIONS, NULL },
.mismatch = ANY_INIT_TO_ANY_EXIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
/* Do not use init code/data from exit code */
{
.fromsec = { ALL_EXIT_SECTIONS, NULL },
.tosec = { ALL_INIT_SECTIONS, NULL },
.mismatch = ANY_EXIT_TO_ANY_INIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
/* Do not export init/exit functions or data */
{
.fromsec = { "__ksymtab*", NULL },
.tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
- .mismatch = EXPORT_TO_INIT_EXIT
+ .mismatch = EXPORT_TO_INIT_EXIT,
+ .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
}
};

@@ -985,7 +996,8 @@ static const struct sectioncheck *section_mismatch(
* refsymname = __init_begin, _sinittext, _einittext
*
**/
-static int secref_whitelist(const char *fromsec, const char *fromsym,
+static int secref_whitelist(const struct sectioncheck *mismatch,
+ const char *fromsec, const char *fromsym,
const char *tosec, const char *tosym)
{
/* Check for pattern 1 */
@@ -997,7 +1009,7 @@ static int secref_whitelist(const char *fromsec, const char *fromsym,
/* Check for pattern 2 */
if (match(tosec, init_exit_sections) &&
match(fromsec, data_sections) &&
- match(fromsym, symbol_white_list))
+ match(fromsym, mismatch->symbol_white_list))
return 0;

/* Check for pattern 3 */
@@ -1202,7 +1214,7 @@ static void report_sec_mismatch(const char *modname,
fromsym, sec2annotation(tosec), tosym);
break;
case DATA_TO_ANY_INIT: {
- const char **s = symbol_white_list;
+ const char *const *s = mismatch->symbol_white_list;
fprintf(stderr,
"The variable %s references\n"
"the %s %s%s%s\n"
@@ -1223,7 +1235,7 @@ static void report_sec_mismatch(const char *modname,
fromsym, to, to, tosym, to_p, sec2annotation(tosec), tosym);
break;
case DATA_TO_ANY_EXIT: {
- const char **s = symbol_white_list;
+ const char *const *s = mismatch->symbol_white_list;
fprintf(stderr,
"The variable %s references\n"
"the %s %s%s%s\n"
@@ -1304,7 +1316,8 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
tosym = sym_name(elf, to);

/* check whitelist - we may ignore it */
- if (secref_whitelist(fromsec, fromsym, tosec, tosym)) {
+ if (secref_whitelist(mismatch,
+ fromsec, fromsym, tosec, tosym)) {
report_sec_mismatch(modname, mismatch,
fromsec, r->r_offset, fromsym,
is_function(from), tosec, tosym,
--
1.6.6

2010-01-30 20:47:55

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 7/7] modpost: don't allow *driver to reference .init.*

Signed-off-by: Uwe Kleine-König <[email protected]>
---
scripts/mod/modpost.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 5dbe4db..3318692 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -862,11 +862,20 @@ const struct sectioncheck sectioncheck[] = {
},
{
.fromsec = { DATA_SECTIONS, NULL },
- .tosec = { ALL_INIT_SECTIONS, NULL },
+ .tosec = { ALL_XXXINIT_SECTIONS, NULL },
.mismatch = DATA_TO_ANY_INIT,
.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
},
{
+ .fromsec = { DATA_SECTIONS, NULL },
+ .tosec = { INIT_SECTIONS, NULL },
+ .mismatch = DATA_TO_ANY_INIT,
+ .symbol_white_list = {
+ "*_template", "*_timer", "*_sht", "*_ops",
+ "*_probe", "*_probe_one", "*_console", NULL
+ },
+},
+{
.fromsec = { TEXT_SECTIONS, NULL },
.tosec = { ALL_EXIT_SECTIONS, NULL },
.mismatch = TEXT_TO_ANY_EXIT,
--
1.6.6

2010-01-30 20:49:53

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 2/7] modpost: define ALL_XYX{IN,EX}IT_SECTIONS

Signed-off-by: Uwe Kleine-König <[email protected]>
---
[resend to lkml as it blocked the original mail because of a triple-X in
the subject, fixed to read 'XYX']

scripts/mod/modpost.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 713b62e..dbab53a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -781,10 +781,13 @@ static void check_section(const char *modname, struct elf_info *elf,
#define ALL_EXIT_TEXT_SECTIONS \
".exit.text$", ".devexit.text$", ".cpuexit.text$", ".memexit.text$"

-#define ALL_INIT_SECTIONS INIT_SECTIONS, DEV_INIT_SECTIONS, \
- CPU_INIT_SECTIONS, MEM_INIT_SECTIONS
-#define ALL_EXIT_SECTIONS EXIT_SECTIONS, DEV_EXIT_SECTIONS, \
- CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS
+#define ALL_XXXINIT_SECTIONS DEV_INIT_SECTIONS, CPU_INIT_SECTIONS, \
+ MEM_INIT_SECTIONS
+#define ALL_XXXEXIT_SECTIONS DEV_EXIT_SECTIONS, CPU_EXIT_SECTIONS, \
+ MEM_EXIT_SECTIONS
+
+#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS
+#define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS

#define DATA_SECTIONS ".data$", ".data.rel$"
#define TEXT_SECTIONS ".text$"
@@ -876,7 +879,7 @@ const struct sectioncheck sectioncheck[] = {
},
/* Do not reference init code/data from devinit/cpuinit/meminit code/data */
{
- .fromsec = { DEV_INIT_SECTIONS, CPU_INIT_SECTIONS, MEM_INIT_SECTIONS, NULL },
+ .fromsec = { ALL_XXXINIT_SECTIONS, NULL },
.tosec = { INIT_SECTIONS, NULL },
.mismatch = XXXINIT_TO_INIT,
},
@@ -894,7 +897,7 @@ const struct sectioncheck sectioncheck[] = {
},
/* Do not reference exit code/data from devexit/cpuexit/memexit code/data */
{
- .fromsec = { DEV_EXIT_SECTIONS, CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS, NULL },
+ .fromsec = { ALL_XXXEXIT_SECTIONS, NULL },
.tosec = { EXIT_SECTIONS, NULL },
.mismatch = XXXEXIT_TO_EXIT,
},
--
1.6.6

2010-01-31 16:02:20

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Sat, Jan 30, 2010 at 09:44:25PM +0100, Uwe Kleine-K?nig wrote:
> Hello,
>
> On Wed, Jan 27, 2010 at 05:14:03PM -0800, Greg KH wrote:
> > On Tue, Jan 26, 2010 at 09:47:41AM +0100, Uwe Kleine-K?nig wrote:
> > > On Mon, Jan 25, 2010 at 06:09:01AM +0900, OGAWA Hirofumi wrote:
> > > > Uwe Kleine-K?nig <[email protected]> writes:
> > > > > +int platform_driver_register(struct platform_driver *drv)
> > > > > +{
> > > > > + int ret = __platform_driver_register(drv);
> > > > > +
> > > > > +#if defined(CONFIG_HOTPLUG)
> > > > > + /*
> > > > > + * drivers that are registered by platform_driver_register
> > > > > + * should not have their probe function in .init.text. The
> > > > > + * reason is that a probe can happen after .init.text is
> > > > > + * discarded which then results in an oops. The alternatives
> > > > > + * are using .devinit.text for the probe function or "register"
> > > > > + * with platform_driver_probe.
> > > > > + */
> > > > > + if (drv->probe && kernel_init_text_address((unsigned long)drv->probe))
> > > > > + pr_warning("oops-warning: probe function of platform driver %s"
> > > > > + " lives in .init.text\n", drv->driver.name);
> > > > > +#else
> > > > > + /*
> > > > > + * without HOTPLUG probe functions can be discarded after the driver is
> > > > > + * loaded.
> > > > > + * There is a little chance for false positives, namely if the driver is
> > > > > + * registered after the .init sections are discarded.
> > > > > + */
> > > > > + if (drv->probe && !kernel_init_text_address((unsigned long)drv->probe))
> > > > > + pr_info("probably the probe function of platform driver %s can"
> > > > > + " be moved to .init.text\n", drv->driver.name);
> > > > > +#endif
> > > > > + return ret;
> > > > > +}
> > > >
> > > > Um..., can't we extend modpost or such one for this? I think the static
> > > > analysis is better (assume the changing ->probe dynamically is really
> > > > rare).
> > > I like the idea and will look later into modpost if this can be done
> > > there.
> >
> > That would be nice to do instead, as we already do checks like this
> > today, and might make more sense.
> >
> > And could you do it for all probe functions, and not just the platform
> > devices? Don't all busses have this same problem?
> I think so, yes. And I made some changes to modpost to detect those.
> Tested on two defconfigs (ARCH=arm) it yields three hits, all valid.
>
> I send the series as reply to this mail or you can get it via git, see
> below.
>
> The first six patches should not change behaviour, only do some cleanup
> and preparation for the last patch.
>
> The most interesting patch is "make symbol white list a per mismatch
> type variable". It allows a white list per section mismatch type and
> so allows to say:
>
> *driver (in .data) might reference to .devinit.text but not
> .init.text
>
> That's what the last patch does.

Michael is handling kbuild stuff now and that may include modpost stuff.
So added Michael - then you guys can decide way forward.

The modpost patches looks OK at a quick view.
You can consider adding:

Acked-by: Sam Ravnborg <[email protected]>

Sam

2010-01-31 20:13:14

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hello,

> Michael is handling kbuild stuff now and that may include modpost stuff.
> So added Michael - then you guys can decide way forward.
Then the F: patterns for kbuild in MAINTAINERS should be extended.

> The modpost patches looks OK at a quick view.
> You can consider adding:
>
> Acked-by: Sam Ravnborg <[email protected]>
Thanks,
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2010-02-01 14:57:53

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH] i2c/imx: don't add probe function to the driver struct

Having a pointer to the probe function is unnecessary when using
platform_driver_probe and yields a section mismatch warning after
removing the white list entry "*driver" for
{ .data$, .data.rel$ } -> { .init.* } mismatches in modpost.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
Hello,

this is a new section mismatch found by modpost after my patches.

Best regards
Uwe

drivers/i2c/busses/i2c-imx.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 75bf820..32375bd 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -627,7 +627,6 @@ static int __exit i2c_imx_remove(struct platform_device *pdev)
}

static struct platform_driver i2c_imx_driver = {
- .probe = i2c_imx_probe,
.remove = __exit_p(i2c_imx_remove),
.driver = {
.name = DRIVER_NAME,
--
1.6.6

2010-02-02 15:25:18

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On 31.1.2010 21:13, Uwe Kleine-K?nig wrote:
> Hello,
>
>> Michael is handling kbuild stuff now and that may include modpost stuff.
>> So added Michael - then you guys can decide way forward.
> Then the F: patterns for kbuild in MAINTAINERS should be extended.

Well, modpost is kind of grey zone between module support (Rusty, whom
you already included) and kbuild (me, who added a subject filter for
"modpost" and is happy). This series is more kbuild related (it does not
affect the module loader) and it looks ok to me, so I'll pull it.

>
>> The modpost patches looks OK at a quick view.
>> You can consider adding:
>>
>> Acked-by: Sam Ravnborg <[email protected]>

Thanks, I added your ack to the merge commit.

Michal

2010-02-03 09:42:31

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

Hello,

> > So can you please look into that before they are swapped out of your
> > inbox the third(?) time?
>
> I think the video ones can be all in one patch, that makes it easier for
> me to track and apply. Same goes for any others you can merge together.
So I group by drivers/* and arch/*?

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2010-02-03 15:09:37

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] platform_driver_register: warn if probe is in .init.text

On Wed, Feb 03, 2010 at 10:42:26AM +0100, Uwe Kleine-K?nig wrote:
> Hello,
>
> > > So can you please look into that before they are swapped out of your
> > > inbox the third(?) time?
> >
> > I think the video ones can be all in one patch, that makes it easier for
> > me to track and apply. Same goes for any others you can merge together.
> So I group by drivers/* and arch/*?

Sure, that would make it easier, right?

thanks,

greg k-h

2010-02-04 19:57:16

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 6/9] w1: move omap_hdq's probe function to .devinit.text

A pointer to omap_hdq_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Stanley.Miao <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Madhusudhan Chikkature <[email protected]>
Cc: Felipe Balbi <[email protected]>
---
drivers/w1/masters/omap_hdq.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
index 0d92969..22977d3 100644
--- a/drivers/w1/masters/omap_hdq.c
+++ b/drivers/w1/masters/omap_hdq.c
@@ -72,7 +72,7 @@ struct hdq_data {
int init_trans;
};

-static int __init omap_hdq_probe(struct platform_device *pdev);
+static int __devinit omap_hdq_probe(struct platform_device *pdev);
static int omap_hdq_remove(struct platform_device *pdev);

static struct platform_driver omap_hdq_driver = {
@@ -558,7 +558,7 @@ static void omap_w1_write_byte(void *_hdq, u8 byte)
return;
}

-static int __init omap_hdq_probe(struct platform_device *pdev)
+static int __devinit omap_hdq_probe(struct platform_device *pdev)
{
struct hdq_data *hdq_data;
struct resource *res;
--
1.6.6

2010-02-04 19:57:23

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 7/9] media: move omap24xxcam's probe function to .devinit.text

A pointer to omap24xxcam_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Sakari Ailus <[email protected]>
Acked-by: Trilok Soni <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/media/video/omap24xxcam.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/omap24xxcam.c b/drivers/media/video/omap24xxcam.c
index 7400eac..142c327 100644
--- a/drivers/media/video/omap24xxcam.c
+++ b/drivers/media/video/omap24xxcam.c
@@ -1735,7 +1735,7 @@ static struct v4l2_int_device omap24xxcam = {
*
*/

-static int __init omap24xxcam_probe(struct platform_device *pdev)
+static int __devinit omap24xxcam_probe(struct platform_device *pdev)
{
struct omap24xxcam_device *cam;
struct resource *mem;
--
1.6.6

2010-02-04 19:57:20

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 4/9] x86: move hp-wmi's probe function to .devinit.text

A pointer to hp_wmi_bios_setup is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Frans Pop <[email protected]>
Cc: Larry Finger <[email protected]>
Cc: Len Brown <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: Matthew Garrett <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/platform/x86/hp-wmi.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index ad4c414..5c7259a 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -57,7 +57,7 @@ enum hp_wmi_radio {
HPWMI_WWAN = 2,
};

-static int __init hp_wmi_bios_setup(struct platform_device *device);
+static int __devinit hp_wmi_bios_setup(struct platform_device *device);
static int __exit hp_wmi_bios_remove(struct platform_device *device);
static int hp_wmi_resume_handler(struct device *device);

@@ -446,7 +446,7 @@ static void cleanup_sysfs(struct platform_device *device)
device_remove_file(&device->dev, &dev_attr_tablet);
}

-static int __init hp_wmi_bios_setup(struct platform_device *device)
+static int __devinit hp_wmi_bios_setup(struct platform_device *device)
{
int err;
int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
--
1.6.6

2010-02-04 19:57:18

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 5/9] i2c: move i2c_omap's probe function to .devinit.text

A pointer to omap_i2c_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Kalle Jokiniemi <[email protected]>
Cc: Tony Lindgren <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Richard Woodruff <[email protected]>
Cc: chandra shekhar <[email protected]>
Cc: Jason P Marini <[email protected]>
Cc: Syed Mohammed Khasim <[email protected]>
Cc: Jarkko Nikula <[email protected]>
Cc: Juha Yrjola <[email protected]>
Cc: Andrew Morton <[email protected]>
---
drivers/i2c/busses/i2c-omap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 0037e31..bd86a85 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -849,7 +849,7 @@ static const struct i2c_algorithm omap_i2c_algo = {
.functionality = omap_i2c_func,
};

-static int __init
+static int __devinit
omap_i2c_probe(struct platform_device *pdev)
{
struct omap_i2c_dev *dev;
--
1.6.6

2010-02-04 19:57:10

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 8/9] auxdisplay: move cfag12864bfb's probe function to .devinit.text

A pointer to cfag12864bfb_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Acked-by: Miguel Ojeda <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Avuton Olrich <[email protected]>
Cc: Antonino Daplas <[email protected]>
---
drivers/auxdisplay/cfag12864bfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/auxdisplay/cfag12864bfb.c b/drivers/auxdisplay/cfag12864bfb.c
index fe3a865..b0ca5a4 100644
--- a/drivers/auxdisplay/cfag12864bfb.c
+++ b/drivers/auxdisplay/cfag12864bfb.c
@@ -81,7 +81,7 @@ static struct fb_ops cfag12864bfb_ops = {
.fb_mmap = cfag12864bfb_mmap,
};

-static int __init cfag12864bfb_probe(struct platform_device *device)
+static int __devinit cfag12864bfb_probe(struct platform_device *device)
{
int ret = -EINVAL;
struct fb_info *info = framebuffer_alloc(0, &device->dev);
--
1.6.6

2010-02-04 19:57:09

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 2/9] platform-drivers: move probe to .devinit.text in drivers/scsi

A pointer to a probe callback is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: David Brownell <[email protected]>
Cc: Dmitri Vorobiev <[email protected]>
Cc: Henrik Kretzschmar <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Kay Sievers <[email protected]>
Cc: peter fuerst <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
---
drivers/scsi/sgiwd93.c | 2 +-
drivers/scsi/sni_53c710.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c
index 0807b26..fef0e3c 100644
--- a/drivers/scsi/sgiwd93.c
+++ b/drivers/scsi/sgiwd93.c
@@ -226,7 +226,7 @@ static struct scsi_host_template sgiwd93_template = {
.use_clustering = DISABLE_CLUSTERING,
};

-static int __init sgiwd93_probe(struct platform_device *pdev)
+static int __devinit sgiwd93_probe(struct platform_device *pdev)
{
struct sgiwd93_platform_data *pd = pdev->dev.platform_data;
unsigned char *wdregs = pd->wdregs;
diff --git a/drivers/scsi/sni_53c710.c b/drivers/scsi/sni_53c710.c
index 37b3359..56cf0bb 100644
--- a/drivers/scsi/sni_53c710.c
+++ b/drivers/scsi/sni_53c710.c
@@ -64,7 +64,7 @@ static struct scsi_host_template snirm710_template = {
.module = THIS_MODULE,
};

-static int __init snirm710_probe(struct platform_device *dev)
+static int __devinit snirm710_probe(struct platform_device *dev)
{
unsigned long base;
struct NCR_700_Host_Parameters *hostdata;
--
1.6.6

2010-02-04 19:58:45

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 9/9] net: move am79c961's probe function to .devinit.text

A pointer to am79c961_probe is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Roel Kluin <[email protected]>
Cc: Russell King <[email protected]>
Cc: [email protected]
Cc: Andrew Morton <[email protected]>
---
Hello,

@David Miller: this patch is in patchwork with State: Not Applicable.
Does that mean that netdev isn't the right tree for this patch?

Best regards
Uwe

drivers/net/arm/am79c961a.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index 164b37e..1c3c1f9 100644
--- a/drivers/net/arm/am79c961a.c
+++ b/drivers/net/arm/am79c961a.c
@@ -680,7 +680,7 @@ static const struct net_device_ops am79c961_netdev_ops = {
#endif
};

-static int __init am79c961_probe(struct platform_device *pdev)
+static int __devinit am79c961_probe(struct platform_device *pdev)
{
struct resource *res;
struct net_device *dev;
--
1.6.6

2010-02-04 19:57:13

by Uwe Kleine-König

[permalink] [raw]
Subject: [PATCH 1/9] platform-drivers: move probe to .devinit.text in arch/arm

A pointer to a probe callback is passed to the core via
platform_driver_register and so the function must not disappear when the
.init sections are discarded. Otherwise (if also having HOTPLUG=y)
unbinding and binding a device to the driver via sysfs will result in an
oops as does a device being registered late.

An alternative to this patch is using platform_driver_probe instead of
platform_driver_register plus removing the pointer to the probe function
from the struct platform_driver.

Signed-off-by: Uwe Kleine-König <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Arnaud Patard <[email protected]>
Cc: Ben Dooks <[email protected]>
Cc: Dmitry Baryshkov <[email protected]>
Cc: Eric Miao <[email protected]>
Cc: Kristoffer Ericson <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Paul Sokolovsky <[email protected]>
Cc: Richard Purdie <[email protected]>
Cc: Russell King <[email protected]>
---
arch/arm/mach-pxa/corgi_ssp.c | 2 +-
arch/arm/mach-pxa/sharpsl_pm.c | 2 +-
arch/arm/mach-s3c2410/h1940-bluetooth.c | 2 +-
arch/arm/mach-sa1100/jornada720_ssp.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-pxa/corgi_ssp.c b/arch/arm/mach-pxa/corgi_ssp.c
index a5ee707..1d9bc11 100644
--- a/arch/arm/mach-pxa/corgi_ssp.c
+++ b/arch/arm/mach-pxa/corgi_ssp.c
@@ -204,7 +204,7 @@ void __init corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo)
ssp_machinfo = machinfo;
}

-static int __init corgi_ssp_probe(struct platform_device *dev)
+static int __devinit corgi_ssp_probe(struct platform_device *dev)
{
int ret;

diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c
index 67229a1..463d874 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.c
+++ b/arch/arm/mach-pxa/sharpsl_pm.c
@@ -900,7 +900,7 @@ static struct platform_suspend_ops sharpsl_pm_ops = {
};
#endif

-static int __init sharpsl_pm_probe(struct platform_device *pdev)
+static int __devinit sharpsl_pm_probe(struct platform_device *pdev)
{
int ret;

diff --git a/arch/arm/mach-s3c2410/h1940-bluetooth.c b/arch/arm/mach-s3c2410/h1940-bluetooth.c
index b7d1f8d..a3f3c7b 100644
--- a/arch/arm/mach-s3c2410/h1940-bluetooth.c
+++ b/arch/arm/mach-s3c2410/h1940-bluetooth.c
@@ -56,7 +56,7 @@ static const struct rfkill_ops h1940bt_rfkill_ops = {
.set_block = h1940bt_set_block,
};

-static int __init h1940bt_probe(struct platform_device *pdev)
+static int __devinit h1940bt_probe(struct platform_device *pdev)
{
struct rfkill *rfk;
int ret = 0;
diff --git a/arch/arm/mach-sa1100/jornada720_ssp.c b/arch/arm/mach-sa1100/jornada720_ssp.c
index 506a5e5..9b6dee5 100644
--- a/arch/arm/mach-sa1100/jornada720_ssp.c
+++ b/arch/arm/mach-sa1100/jornada720_ssp.c
@@ -130,7 +130,7 @@ void jornada_ssp_end(void)
};
EXPORT_SYMBOL(jornada_ssp_end);

-static int __init jornada_ssp_probe(struct platform_device *dev)
+static int __devinit jornada_ssp_probe(struct platform_device *dev)
{
int ret;

--
1.6.6

2010-02-04 20:04:49

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 9/9] net: move am79c961's probe function to .devinit.text

From: Uwe Kleine-K?nig <[email protected]>
Date: Thu, 4 Feb 2010 20:56:57 +0100

> @David Miller: this patch is in patchwork with State: Not Applicable.
> Does that mean that netdev isn't the right tree for this patch?

I was under the impression that someone would pick up the
whole set as a unit.

If you want me to take it into net-next-2.6 I can.

2010-02-04 20:05:34

by Matthew Garrett

[permalink] [raw]
Subject: Re: [PATCH 4/9] x86: move hp-wmi's probe function to .devinit.text

On Thu, Feb 04, 2010 at 08:56:52PM +0100, Uwe Kleine-K?nig wrote:
> A pointer to hp_wmi_bios_setup is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.
>
> Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> Cc: Frans Pop <[email protected]>
> Cc: Larry Finger <[email protected]>
> Cc: Len Brown <[email protected]>
> Cc: Helge Deller <[email protected]>
> Cc: Matthew Garrett <[email protected]>
> Cc: Andrew Morton <[email protected]>

Acked-by: Matthew Garrett <[email protected]>

--
Matthew Garrett | [email protected]

2010-02-04 20:06:46

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 9/9] net: move am79c961's probe function to .devinit.text

On Thu, Feb 04, 2010 at 12:05:01PM -0800, David Miller wrote:
> From: Uwe Kleine-K?nig <[email protected]>
> Date: Thu, 4 Feb 2010 20:56:57 +0100
>
> > @David Miller: this patch is in patchwork with State: Not Applicable.
> > Does that mean that netdev isn't the right tree for this patch?
>
> I was under the impression that someone would pick up the
> whole set as a unit.
Ah, OK. I hope Greg does exactly that now.

Thanks
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2010-02-04 20:29:12

by Ralf Baechle

[permalink] [raw]
Subject: Re: [PATCH 2/9] platform-drivers: move probe to .devinit.text in drivers/scsi

On Thu, Feb 04, 2010 at 08:56:50PM +0100, Uwe Kleine-K?nig wrote:

> A pointer to a probe callback is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.

sgiwd93 bits looks good, so

Acked-by: Ralf Baechle <[email protected]>

The IP22 hardware doesn't support hotplugging so this bug isn't dangerous.

Ralf

2010-02-04 20:56:16

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH 1/9] platform-drivers: move probe to .devinit.text in arch/arm

On Thu, Feb 04, 2010 at 08:56:49PM +0100, Uwe Kleine-K?nig wrote:
> A pointer to a probe callback is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.
>
> Signed-off-by: Uwe Kleine-K?nig <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Arnaud Patard <[email protected]>
> Cc: Ben Dooks <[email protected]>
> Cc: Dmitry Baryshkov <[email protected]>
> Cc: Eric Miao <[email protected]>
> Cc: Kristoffer Ericson <[email protected]>
> Cc: Liam Girdwood <[email protected]>
> Cc: Paul Sokolovsky <[email protected]>
> Cc: Richard Purdie <[email protected]>
> Cc: Russell King <[email protected]>

sharpsl_pm part:
Acked-by: Dmitry Eremin-Solenikov <[email protected]>

--
With best wishes
Dmitry

2010-02-04 21:08:48

by Kristoffer Ericson

[permalink] [raw]
Subject: Re: [PATCH 1/9] platform-drivers: move probe to .devinit.text in arch/arm

On Thu, 4 Feb 2010 23:56:06 +0300
Dmitry Eremin-Solenikov <[email protected]> wrote:

> On Thu, Feb 04, 2010 at 08:56:49PM +0100, Uwe Kleine-König wrote:
> > A pointer to a probe callback is passed to the core via
> > platform_driver_register and so the function must not disappear when the
> > .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> > unbinding and binding a device to the driver via sysfs will result in an
> > oops as does a device being registered late.
> >
> > An alternative to this patch is using platform_driver_probe instead of
> > platform_driver_register plus removing the pointer to the probe function
> > from the struct platform_driver.
> >
> > Signed-off-by: Uwe Kleine-König <[email protected]>
> > Cc: Andrew Morton <[email protected]>
> > Cc: Arnaud Patard <[email protected]>
> > Cc: Ben Dooks <[email protected]>
> > Cc: Dmitry Baryshkov <[email protected]>
> > Cc: Eric Miao <[email protected]>
> > Cc: Kristoffer Ericson <[email protected]>
> > Cc: Liam Girdwood <[email protected]>
> > Cc: Paul Sokolovsky <[email protected]>
> > Cc: Richard Purdie <[email protected]>
> > Cc: Russell King <[email protected]>
>
> sharpsl_pm part:
> Acked-by: Dmitry Eremin-Solenikov <[email protected]>

jornada part:
Acked-by: Kristoffer Ericson <[email protected]>

>
> --
> With best wishes
> Dmitry
>


--
Kristoffer Ericson <[email protected]>

2010-02-04 21:24:39

by Arnaud Patard

[permalink] [raw]
Subject: Re: [PATCH 1/9] platform-drivers: move probe to .devinit.text in arch/arm

Uwe Kleine-König <[email protected]> writes:

> A pointer to a probe callback is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.
>
> Signed-off-by: Uwe Kleine-König <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Arnaud Patard <[email protected]>
> Cc: Ben Dooks <[email protected]>
> Cc: Dmitry Baryshkov <[email protected]>
> Cc: Eric Miao <[email protected]>
> Cc: Kristoffer Ericson <[email protected]>
> Cc: Liam Girdwood <[email protected]>
> Cc: Paul Sokolovsky <[email protected]>
> Cc: Richard Purdie <[email protected]>
> Cc: Russell King <[email protected]>
> ---
> arch/arm/mach-pxa/corgi_ssp.c | 2 +-
> arch/arm/mach-pxa/sharpsl_pm.c | 2 +-
> arch/arm/mach-s3c2410/h1940-bluetooth.c | 2 +-
> arch/arm/mach-sa1100/jornada720_ssp.c | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)

For the h1940-bluetooth change :
Acked-by: Arnaud Patard <[email protected]>

2010-02-04 21:32:07

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 2/9] platform-drivers: move probe to .devinit.text in drivers/scsi

Hello,

On Thu, Feb 04, 2010 at 09:25:07PM +0100, Ralf Baechle wrote:
> On Thu, Feb 04, 2010 at 08:56:50PM +0100, Uwe Kleine-K?nig wrote:
>
> > A pointer to a probe callback is passed to the core via
> > platform_driver_register and so the function must not disappear when the
> > .init sections are discarded. Otherwise (if also having HOTPLUG=y)
> > unbinding and binding a device to the driver via sysfs will result in an
> > oops as does a device being registered late.
> >
> > An alternative to this patch is using platform_driver_probe instead of
> > platform_driver_register plus removing the pointer to the probe function
> > from the struct platform_driver.
>
> sgiwd93 bits looks good, so
>
> Acked-by: Ralf Baechle <[email protected]>
>
> The IP22 hardware doesn't support hotplugging so this bug isn't dangerous.
You can still trigger it via sysfs. You need to be root though.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |

2010-02-12 20:10:57

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 9/9] net: move am79c961's probe function to .devinit.text

From: Uwe Kleine-K?nig <[email protected]>
Date: Thu, 4 Feb 2010 21:06:38 +0100

> On Thu, Feb 04, 2010 at 12:05:01PM -0800, David Miller wrote:
>> From: Uwe Kleine-K?nig <[email protected]>
>> Date: Thu, 4 Feb 2010 20:56:57 +0100
>>
>> > @David Miller: this patch is in patchwork with State: Not Applicable.
>> > Does that mean that netdev isn't the right tree for this patch?
>>
>> I was under the impression that someone would pick up the
>> whole set as a unit.
> Ah, OK. I hope Greg does exactly that now.

I've tossed this into my net-next-2.6 tree anyways to make sure it
doesn't get lost.

Thanks.

2010-02-17 21:10:40

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 9/9] net: move am79c961's probe function to .devinit.text

On Thu, Feb 04, 2010 at 09:06:38PM +0100, Uwe Kleine-K?nig wrote:
> On Thu, Feb 04, 2010 at 12:05:01PM -0800, David Miller wrote:
> > From: Uwe Kleine-K?nig <[email protected]>
> > Date: Thu, 4 Feb 2010 20:56:57 +0100
> >
> > > @David Miller: this patch is in patchwork with State: Not Applicable.
> > > Does that mean that netdev isn't the right tree for this patch?
> >
> > I was under the impression that someone would pick up the
> > whole set as a unit.
> Ah, OK. I hope Greg does exactly that now.

I have now done this.

thanks,

greg k-h