mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Kconfig, Makefile and ifdef: mod as yes vs. no?
@ 2009-07-11 21:06 Pekka Paalanen
  2009-07-11 21:53 ` Kyle McMartin
  0 siblings, 1 reply; 3+ messages in thread
From: Pekka Paalanen @ 2009-07-11 21:06 UTC (permalink / raw)
  To: linux-kernel

Hi,

I'm having hard time making a patch that would compile nouveau_backlight.o
only if CONFIG_BACKLIGHT_CLASS_DEVICE is y or m, and define just stubs
when it is n.

I'm trying this in the nouveau/linux-2.6 kernel tree, which is basically
2.6.31-rc2.

I attempted the following:

--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -8,7 +8,7 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_fifo.o nouveau_mem.o \
              nouveau_sgdma.o nouveau_dma.o \
              nouveau_bo.o nouveau_fence.o nouveau_gem.o nouveau_ttm.o \
              nouveau_hw.o nouveau_calc.o nouveau_bios.o nouveau_i2c.o \
-            nouveau_display.o nouveau_fbcon.o nouveau_backlight.o \
+             nouveau_display.o nouveau_fbcon.o \
              nv04_timer.o \
              nv04_mc.o nv40_mc.o nv50_mc.o \
              nv04_fb.o nv10_fb.o nv40_fb.o \
@@ -19,8 +19,9 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_fifo.o nouveau_mem.o \
              nv50_crtc.o nv50_dac.o nv50_sor.o nv50_connector.o \
              nv50_cursor.o nv50_display.o nv50_fbcon.o \
              nv04_display.o nv04_output.o nv04_crtc.o nv04_cursor.o \
-            nv04_fbcon.o
+             nv04_fbcon.o
 
 nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
+nouveau-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += nouveau_backlight.o
 
 obj-$(CONFIG_DRM_NOUVEAU)+= nouveau.o

--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -708,8 +708,21 @@ extern int  nouveau_dma_init(struct nouveau_channel *);
 extern int  nouveau_dma_wait(struct nouveau_channel *, int size);
 
 /* nouveau_backlight.c */
+#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
 extern int nouveau_backlight_init(struct drm_device *);
 extern void nouveau_backlight_exit(struct drm_device *);
+#else
+static inline int nouveau_backlight_init(struct drm_device *dev)
+{
+       (void)dev;
+       return 0;
+}
+
+static inline void nouveau_backlight_exit(struct drm_device *dev)
+{
+       (void)dev;
+}
+#endif
 
When CONFIG_BACKLIGHT_CLASS_DEVICE=m this behaves as if it was n, i.e.
I get the stubs and no nouveau_backlight.o.

For CONFIG_BACKLIGHT_CLASS_DEVICE=y and n I get what I want.

What is the proper way to get m behave like y in this situation?

Oh, and should I use the following instead of (void)dev;?
static inline void nouveau_backlight_exit(struct drm_device *dev __used) { }

Please, Cc me.


Thanks.

-- 
Pekka Paalanen
http://www.iki.fi/pq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Kconfig, Makefile and ifdef: mod as yes vs. no?
  2009-07-11 21:06 Kconfig, Makefile and ifdef: mod as yes vs. no? Pekka Paalanen
@ 2009-07-11 21:53 ` Kyle McMartin
  2009-07-12  9:07   ` Pekka Paalanen
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle McMartin @ 2009-07-11 21:53 UTC (permalink / raw)
  To: Pekka Paalanen; +Cc: linux-kernel

On Sun, Jul 12, 2009 at 12:06:25AM +0300, Pekka Paalanen wrote:
> +#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
>

You need to test _MODULE for the symbol too... since it's necessary to
be able to distinguish between symbols which exist in the vmlinux, and
symbols which require a module to be loaded.

#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) &&
	defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)

should work.

regards, Kyle

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Kconfig, Makefile and ifdef: mod as yes vs. no?
  2009-07-11 21:53 ` Kyle McMartin
@ 2009-07-12  9:07   ` Pekka Paalanen
  0 siblings, 0 replies; 3+ messages in thread
From: Pekka Paalanen @ 2009-07-12  9:07 UTC (permalink / raw)
  To: Kyle McMartin; +Cc: linux-kernel

On Sat, 11 Jul 2009 17:53:43 -0400
Kyle McMartin <kyle@mcmartin.ca> wrote:

> On Sun, Jul 12, 2009 at 12:06:25AM +0300, Pekka Paalanen wrote:
> > +#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
> >
> 
> You need to test _MODULE for the symbol too... since it's necessary to
> be able to distinguish between symbols which exist in the vmlinux, and
> symbols which require a module to be loaded.
> 
> #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) &&
> 	defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
> 
> should work.

Just || instead of &&, and yes, this is a solution for half of the problem,
thanks.

But what about the Makefile?

nouveau-y := nouveau_drv.o ...
nouveau-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += nouveau_backlight.o
obj-$(CONFIG_DRM_NOUVEAU)+= nouveau.o

With this, nouveau_backlight.o is not built if
CONFIG_BACKLIGHT_CLASS_DEVICE=m. Should I write:

nouveau-$(if $(findstring m,$(CONFIG_BACKLIGHT_CLASS_DEVICE)),y,n) += \
	nouveau_backlight.o

which to me looks ugly, or add a new Kconfig boolean option that is
selected 'if CONFIG_BACKLIGHT_CLASS_DEVICE' and use that in both Makefile
and code, or is there a canonical way to do this?

Other code seems to deal with a similar situation by #ifdef'ing the
whole c-file contents. That cannot be the preferred way, can it?


Thanks.

-- 
Pekka Paalanen
http://www.iki.fi/pq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-07-12  9:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-11 21:06 Kconfig, Makefile and ifdef: mod as yes vs. no? Pekka Paalanen
2009-07-11 21:53 ` Kyle McMartin
2009-07-12  9:07   ` Pekka Paalanen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®