2008-08-13 03:14:50

by Dave Jones

[permalink] [raw]
Subject: Re: [WATCHDOG] v2.6.27-rc patches

On Wed, Aug 06, 2008 at 10:29:18PM +0200, Wim Van Sebroeck wrote:
> Hi Linus,
>
> Please pull from 'master' branch of
> git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog.git
> or if master.kernel.org hasn't synced up yet:
> master.kernel.org:/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog.git
>
> This will update the following files:
>
> Author: Anton Vorontsov <[email protected]>
> Date: Thu Jul 3 23:51:36 2008 -0700
>
> [WATCHDOG] mpc8xxx_wdt: add support for MPC8xx watchdogs

This is broken when built modular because this...

> +}
> +module_init(mpc8xxx_wdt_init_late);

and this ..

> +arch_initcall(mpc8xxx_wdt_init);

Can't be mixed. You end up with two init_module invocations

drivers/watchdog/mpc8xxx_wdt.c:304: error: redefinition of '__inittest'
drivers/watchdog/mpc8xxx_wdt.c:298: error: previous definition of '__inittest' was here
drivers/watchdog/mpc8xxx_wdt.c:304: error: redefinition of 'init_module'
drivers/watchdog/mpc8xxx_wdt.c:298: error: previous definition of 'init_module' was here

Given they both call different routines though, I'm not sure the right fix here.

Dave


--
http://www.codemonkey.org.uk


2008-08-13 12:23:52

by Anton Vorontsov

[permalink] [raw]
Subject: [PATCH] [WATCHDOG] mpc8xxx_wdt: fix modular build

This patch fixes following build error when mpc8xxx_wdt is selected to
build as a module:

drivers/watchdog/mpc8xxx_wdt.c:304: error: redefinition of '__inittest'
drivers/watchdog/mpc8xxx_wdt.c:298: error: previous definition of '__inittest' was here
drivers/watchdog/mpc8xxx_wdt.c:304: error: redefinition of 'init_module'
drivers/watchdog/mpc8xxx_wdt.c:298: error: previous definition of 'init_module' was here

Reported-by: Dave Jones <[email protected]>
Signed-off-by: Anton Vorontsov <[email protected]>
---

On Tue, Aug 12, 2008 at 11:10:44PM -0400, Dave Jones wrote:
> On Wed, Aug 06, 2008 at 10:29:18PM +0200, Wim Van Sebroeck wrote:
> > Hi Linus,
> >
> > Please pull from 'master' branch of
> > git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog.git
> > or if master.kernel.org hasn't synced up yet:
> > master.kernel.org:/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog.git
> >
> > This will update the following files:
> >
> > Author: Anton Vorontsov <[email protected]>
> > Date: Thu Jul 3 23:51:36 2008 -0700
> >
> > [WATCHDOG] mpc8xxx_wdt: add support for MPC8xx watchdogs
>
> This is broken when built modular because this...
>
> > +}
> > +module_init(mpc8xxx_wdt_init_late);
>
> and this ..
>
> > +arch_initcall(mpc8xxx_wdt_init);
>
> Can't be mixed. You end up with two init_module invocations
>
> drivers/watchdog/mpc8xxx_wdt.c:304: error: redefinition of '__inittest'
> drivers/watchdog/mpc8xxx_wdt.c:298: error: previous definition of '__inittest' was here
> drivers/watchdog/mpc8xxx_wdt.c:304: error: redefinition of 'init_module'
> drivers/watchdog/mpc8xxx_wdt.c:298: error: previous definition of 'init_module' was here
>
> Given they both call different routines though, I'm not sure the right fix here.

Thanks for noticing!

Unfortunately I don't see any elegant way to fix this. In the long term,
it would be great if we could work with misc (thus watchdog) subsystem at
arch_initcall() time (yes, we need this early on 8xx). Until this happen,
I think this patch is the best fix we can do.

drivers/watchdog/mpc8xxx_wdt.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/drivers/watchdog/mpc8xxx_wdt.c b/drivers/watchdog/mpc8xxx_wdt.c
index f209496..8e50bc4 100644
--- a/drivers/watchdog/mpc8xxx_wdt.c
+++ b/drivers/watchdog/mpc8xxx_wdt.c
@@ -48,6 +48,7 @@ struct mpc8xxx_wdt_type {
};

static struct mpc8xxx_wdt __iomem *wd_base;
+static int mpc8xxx_wdt_init_late(void);

static u16 timeout = 0xffff;
module_param(timeout, ushort, 0);
@@ -213,6 +214,12 @@ static int __devinit mpc8xxx_wdt_probe(struct of_device *ofdev,
else
timeout_sec = timeout / freq;

+#ifdef CONFIG_8xxx_WDT_MODULE
+ ret = mpc8xxx_wdt_init_late();
+ if (ret)
+ goto err_unmap;
+#endif
+
pr_info("WDT driver for MPC8xxx initialized. mode:%s timeout=%d "
"(%d seconds)\n", reset ? "reset" : "interrupt", timeout,
timeout_sec);
@@ -280,7 +287,7 @@ static struct of_platform_driver mpc8xxx_wdt_driver = {
* very early to start pinging the watchdog (misc devices are not yet
* available), and later module_init() just registers the misc device.
*/
-static int __init mpc8xxx_wdt_init_late(void)
+static int mpc8xxx_wdt_init_late(void)
{
int ret;

@@ -295,7 +302,9 @@ static int __init mpc8xxx_wdt_init_late(void)
}
return 0;
}
+#ifndef CONFIG_8xxx_WDT_MODULE
module_init(mpc8xxx_wdt_init_late);
+#endif

static int __init mpc8xxx_wdt_init(void)
{
--
1.5.6.3

2008-08-13 14:34:00

by Adrian Bunk

[permalink] [raw]
Subject: Re: [PATCH] [WATCHDOG] mpc8xxx_wdt: fix modular build

On Wed, Aug 13, 2008 at 04:23:41PM +0400, Anton Vorontsov wrote:
>...
> --- a/drivers/watchdog/mpc8xxx_wdt.c
> +++ b/drivers/watchdog/mpc8xxx_wdt.c
> @@ -48,6 +48,7 @@ struct mpc8xxx_wdt_type {
> };
>
> static struct mpc8xxx_wdt __iomem *wd_base;
> +static int mpc8xxx_wdt_init_late(void);
>
> static u16 timeout = 0xffff;
> module_param(timeout, ushort, 0);
> @@ -213,6 +214,12 @@ static int __devinit mpc8xxx_wdt_probe(struct of_device *ofdev,
> else
> timeout_sec = timeout / freq;
>
> +#ifdef CONFIG_8xxx_WDT_MODULE
> + ret = mpc8xxx_wdt_init_late();
> + if (ret)
> + goto err_unmap;
> +#endif

In mpc8xxx_wdt_probe()?

Isn't mpc8xxx_wdt_init() the correct place?

> pr_info("WDT driver for MPC8xxx initialized. mode:%s timeout=%d "
> "(%d seconds)\n", reset ? "reset" : "interrupt", timeout,
> timeout_sec);
> @@ -280,7 +287,7 @@ static struct of_platform_driver mpc8xxx_wdt_driver = {
> * very early to start pinging the watchdog (misc devices are not yet
> * available), and later module_init() just registers the misc device.
> */
> -static int __init mpc8xxx_wdt_init_late(void)
> +static int mpc8xxx_wdt_init_late(void)
> {
> int ret;
>
> @@ -295,7 +302,9 @@ static int __init mpc8xxx_wdt_init_late(void)
> }
> return 0;
> }
> +#ifndef CONFIG_8xxx_WDT_MODULE

Your #ifdef is correct, but "#ifdef MODULE" would express this better.

> module_init(mpc8xxx_wdt_init_late);
> +#endif
>
> static int __init mpc8xxx_wdt_init(void)
> {

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2008-08-13 17:21:51

by Anton Vorontsov

[permalink] [raw]
Subject: Re: [PATCH] [WATCHDOG] mpc8xxx_wdt: fix modular build

On Wed, Aug 13, 2008 at 05:31:59PM +0300, Adrian Bunk wrote:
> On Wed, Aug 13, 2008 at 04:23:41PM +0400, Anton Vorontsov wrote:
> >...
> > --- a/drivers/watchdog/mpc8xxx_wdt.c
> > +++ b/drivers/watchdog/mpc8xxx_wdt.c
> > @@ -48,6 +48,7 @@ struct mpc8xxx_wdt_type {
> > };
> >
> > static struct mpc8xxx_wdt __iomem *wd_base;
> > +static int mpc8xxx_wdt_init_late(void);
> >
> > static u16 timeout = 0xffff;
> > module_param(timeout, ushort, 0);
> > @@ -213,6 +214,12 @@ static int __devinit mpc8xxx_wdt_probe(struct of_device *ofdev,
> > else
> > timeout_sec = timeout / freq;
> >
> > +#ifdef CONFIG_8xxx_WDT_MODULE
> > + ret = mpc8xxx_wdt_init_late();
> > + if (ret)
> > + goto err_unmap;
> > +#endif
>
> In mpc8xxx_wdt_probe()?

Yes.

> Isn't mpc8xxx_wdt_init() the correct place?

Not exactly. In case of non-modular build we rely on the fact
that OF devices are populated before module_init(), so _probe
is executed before _init_late.

But with modules, we can do the right thing: just register the driver
and await for the usual probe, then probe the wdt, and then register
userspace interface. Yes, kind of complicated, but we really need
this on 8xx.

> > pr_info("WDT driver for MPC8xxx initialized. mode:%s timeout=%d "
> > "(%d seconds)\n", reset ? "reset" : "interrupt", timeout,
> > timeout_sec);
> > @@ -280,7 +287,7 @@ static struct of_platform_driver mpc8xxx_wdt_driver = {
> > * very early to start pinging the watchdog (misc devices are not yet
> > * available), and later module_init() just registers the misc device.
> > */
> > -static int __init mpc8xxx_wdt_init_late(void)
> > +static int mpc8xxx_wdt_init_late(void)
> > {
> > int ret;
> >
> > @@ -295,7 +302,9 @@ static int __init mpc8xxx_wdt_init_late(void)
> > }
> > return 0;
> > }
> > +#ifndef CONFIG_8xxx_WDT_MODULE
>
> Your #ifdef is correct, but "#ifdef MODULE" would express this better.

Thanks, will repost soon.

--
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2

2008-08-13 18:35:00

by Anton Vorontsov

[permalink] [raw]
Subject: [PATCH v2] [WATCHDOG] mpc8xxx_wdt: fix modular build

This patch fixes following build error when mpc8xxx_wdt is selected to
build as a module:

drivers/watchdog/mpc8xxx_wdt.c:304: error: redefinition of '__inittest'
drivers/watchdog/mpc8xxx_wdt.c:298: error: previous definition of '__inittest' was here
drivers/watchdog/mpc8xxx_wdt.c:304: error: redefinition of 'init_module'
drivers/watchdog/mpc8xxx_wdt.c:298: error: previous definition of 'init_module' was here

Reported-by: Dave Jones <[email protected]>
Signed-off-by: Anton Vorontsov <[email protected]>
---

CONFIG_8xxx_WDT_MODULE -> MODULE, per Adrian Bunk's comment.

drivers/watchdog/mpc8xxx_wdt.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/drivers/watchdog/mpc8xxx_wdt.c b/drivers/watchdog/mpc8xxx_wdt.c
index f209496..8e50bc4 100644
--- a/drivers/watchdog/mpc8xxx_wdt.c
+++ b/drivers/watchdog/mpc8xxx_wdt.c
@@ -48,6 +48,7 @@ struct mpc8xxx_wdt_type {
};

static struct mpc8xxx_wdt __iomem *wd_base;
+static int mpc8xxx_wdt_init_late(void);

static u16 timeout = 0xffff;
module_param(timeout, ushort, 0);
@@ -213,6 +214,12 @@ static int __devinit mpc8xxx_wdt_probe(struct of_device *ofdev,
else
timeout_sec = timeout / freq;

+#ifdef MODULE
+ ret = mpc8xxx_wdt_init_late();
+ if (ret)
+ goto err_unmap;
+#endif
+
pr_info("WDT driver for MPC8xxx initialized. mode:%s timeout=%d "
"(%d seconds)\n", reset ? "reset" : "interrupt", timeout,
timeout_sec);
@@ -280,7 +287,7 @@ static struct of_platform_driver mpc8xxx_wdt_driver = {
* very early to start pinging the watchdog (misc devices are not yet
* available), and later module_init() just registers the misc device.
*/
-static int __init mpc8xxx_wdt_init_late(void)
+static int mpc8xxx_wdt_init_late(void)
{
int ret;

@@ -295,7 +302,9 @@ static int __init mpc8xxx_wdt_init_late(void)
}
return 0;
}
+#ifndef MODULE
module_init(mpc8xxx_wdt_init_late);
+#endif

static int __init mpc8xxx_wdt_init(void)
{
--
1.5.6.3