Re: [PATCH] vt_ioctl.c: fix compile error with pm_set_vt_switch()

From: Arnd Bergmann
Date: Mon Sep 05 2011 - 10:55:10 EST


On Saturday 03 September 2011, Alan Cox wrote:
> On Fri, 2 Sep 2011 14:02:42 -0700
> H Hartley Sweeten <hartleys@xxxxxxxxxxxxxxxxxxx> wrote:
>
> > When CONFIG_PM_SLEEP, CONFIG_VT, and CONFIG_VT_CONSOLE are not enabled
> > the function pm_set_vt_switch() is defined as an inline in linux/suspend.h. This causes
> > a compile error if CONFIG_VT is enabled.
> >
> > drivers/tty/vt/vt_ioctl.c:1794: error: redefinition of 'pm_set_vt_switch'
> > include/linux/suspend.h:17: error: previous definition of 'pm_set_vt_switch' was here
> >
> > Fix this with an #if defined guard around the function in vt_ioctl.c.
>
> Can you put the #if uglies into the buggy suspend.h header instead so the
> code proper is kept clean of ifdefs.

I had discovered the same problem earlier but did not get to submit a
fix yet. I think the patch below should do it. Hartley, can you confirm that?

Arnd
---
vt/suspend: pm_set_vt_switch does not depend on CONFIG_PM_SLEEP

This avoid having multiple conflicting definitions of pm_set_vt_switch
when CONFIG_VT is set but CONFIG_PM_SLEEP or CONFIG_VT_CONSOLE are not.

drivers/tty/vt/vt_ioctl.c:1794: error: redefinition of 'pm_set_vt_switch'
include/linux/suspend.h:17: error: previous definition of 'pm_set_vt_switch' was here

Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 6bbcef2..69f3b39 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -8,15 +8,18 @@
#include <linux/mm.h>
#include <asm/errno.h>

-#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
+#if defined(CONFIG_VT)
extern void pm_set_vt_switch(int);
-extern int pm_prepare_console(void);
-extern void pm_restore_console(void);
#else
static inline void pm_set_vt_switch(int do_switch)
{
}
+#endif

+#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
+extern int pm_prepare_console(void);
+extern void pm_restore_console(void);
+#else
static inline int pm_prepare_console(void)
{
return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/