Skip to contentSkip to conversation

drivers/video/backlight/mbp_nvidia_bl.c:114: error: storage size of '__mod_dmi_device_table' isn't known

PATCH In review Alexey Dobriyan 3 participants 6 messages Nov 14, 2008 – Dec 3, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

How can this work, given that MODULE_DEVICE_TABLE line expands into

	extern const struct dmi_device_id __mod_dmi_device_table __attribute__ ((unused, alias("mbp_device_table")));
				^^^^^^

but there is no struct dmi_device_id, there is struct dmi_system_id?

commit 239cfbde1f5843c4a24199f117d5f67f637d72d5

Author: David Woodhouse <[email protected]>
Date:   Tue Sep 16 16:25:24 2008 -0700

Fix autoloading of MacBook Pro backlight driver.

Use new MODULE_DEVICE_TABLE(dmi, ...) facility. There's no need for every driver to screw it up for themselves, when the alias can be generated automatically.

drivers/video/backlight/mbp_nvidia_bl.c +1 -3
index 385cba4..06964af 100644
@@ -111,6 +111,4 @@ module_exit(mbp_exit);
 MODULE_AUTHOR("Matthew Garrett <[email protected]>");
 MODULE_DESCRIPTION("Nvidia-based Macbook Pro Backlight Driver");
 MODULE_LICENSE("GPL");
-MODULE_ALIAS("svnAppleInc.:pnMacBookPro3,1");
-MODULE_ALIAS("svnAppleInc.:pnMacBookPro3,2");
-MODULE_ALIAS("svnAppleInc.:pnMacBookPro4,1");
+MODULE_DEVICE_TABLE(dmi, mbp_device_table);
#1 lore raw
Quoted 6 lines · Alexey Dobriyan

How can this work, given that MODULE_DEVICE_TABLE line expands into

extern const struct dmi_device_id __mod_dmi_device_table

__attribute__ ((unused, alias("mbp_device_table")));
                                ^^^^^^

but there is no struct dmi_device_id, there is struct dmi_system_id?

Interesting question ;)

It actually looks like this...

static struct dmi_system_id __initdata mbp_device_table[] = {
	...
};
extern const struct dmi_device_id __mod_dmi_device_table \
		__attribute__ ((unused, alias("mbp_device_table")));

So 'struct dmi_device_id' isn't ever really used -- it's just like a forward declaration of a struct, and the compiler doesn't care because it never needs to know anything more about that struct.

Not ideal though -- we should probably see if we can fix it. I suspect it's not worth a global change of dmi_system_id to dmi_device_id though... got any better ideas?

Maybe we could change MODULE_GENERIC_TABLE to be more agnostic about the datatype -- just call it and 'extern char'. After all, it's only for the linker.

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
#2 lore raw

PATCH 1/1 Fixup MODULE_DEVICE_TABLE(dmi, ...)

Quoted 23 lines · David Woodhouse
Quoted 6 lines · Alexey Dobriyan

How can this work, given that MODULE_DEVICE_TABLE line expands into

extern const struct dmi_device_id __mod_dmi_device_table

__attribute__ ((unused, alias("mbp_device_table")));
                                ^^^^^^

but there is no struct dmi_device_id, there is struct dmi_system_id?

Interesting question ;)

It actually looks like this...

static struct dmi_system_id __initdata mbp_device_table[] = {
	...
};
extern const struct dmi_device_id __mod_dmi_device_table \
		__attribute__ ((unused, alias("mbp_device_table")));

So 'struct dmi_device_id' isn't ever really used -- it's just like a forward declaration of a struct, and the compiler doesn't care because it never needs to know anything more about that struct.

Quoted 7 lines

Not ideal though -- we should probably see if we can fix it. I suspect it's not worth a global change of dmi_system_id to dmi_device_id though... got any better ideas?

Maybe we could change MODULE_GENERIC_TABLE to be more agnostic about the datatype -- just call it and 'extern char'. After all, it's only for the linker.

Let's do it the most staightforward way :-)

[PATCH] Fixup MODULE_DEVICE_TABLE(dmi, ...)

drivers/video/backlight/mbp_nvidia_bl.c:114: error: storage size of '__mod_dmi_device_table' isn't known

---

 include/linux/mod_devicetable.h |    1 +
 1 file changed, 1 insertion(+)
include/linux/mod_devicetable.h +1 -0
@@ -443,6 +443,7 @@ struct dmi_system_id {
 	struct dmi_strmatch matches[4];
 	void *driver_data;
 };
+#define dmi_device_id dmi_system_id	/* fixup MODULE_DEVICE_TABLE(dmi,...); */
 #endif
 
 #define DMI_MATCH(a, b)	{ a, b }
#3 lore raw

Re: [PATCH] Fixup MODULE_DEVICE_TABLE(dmi, ...)

Quoted 28 lines · On Fri, 21 Nov 2008 04:55:59 +0300 Alexey Dobriyan <[email protected]> wrote:
Quoted 27 lines · David Woodhouse
Quoted 6 lines · Alexey Dobriyan

How can this work, given that MODULE_DEVICE_TABLE line expands into

extern const struct dmi_device_id __mod_dmi_device_table

__attribute__ ((unused, alias("mbp_device_table")));
                                ^^^^^^

but there is no struct dmi_device_id, there is struct dmi_system_id?

Interesting question ;)

It actually looks like this...

static struct dmi_system_id __initdata mbp_device_table[] = {
	...
};
extern const struct dmi_device_id __mod_dmi_device_table \
		__attribute__ ((unused, alias("mbp_device_table")));

So 'struct dmi_device_id' isn't ever really used -- it's just like a forward declaration of a struct, and the compiler doesn't care because it never needs to know anything more about that struct.

Not ideal though -- we should probably see if we can fix it. I suspect it's not worth a global change of dmi_system_id to dmi_device_id though... got any better ideas?

Quoted 6 lines
Quoted 3 lines

Maybe we could change MODULE_GENERIC_TABLE to be more agnostic about the datatype -- just call it and 'extern char'. After all, it's only for the linker.

Let's do it the most staightforward way :-)

What happened with all this?

Quoted 13 lines

[PATCH] Fixup MODULE_DEVICE_TABLE(dmi, ...)

drivers/video/backlight/mbp_nvidia_bl.c:114: error: storage size of '__mod_dmi_device_table' isn't known

---

 include/linux/mod_devicetable.h |    1 +
 1 file changed, 1 insertion(+)

include/linux/mod_devicetable.h struct dmi_system_id { · line 449

Quoted 7 lines
include/linux/mod_devicetable.h +1 -0
@@ -443,6 +443,7 @@ struct dmi_system_id {
 	struct dmi_strmatch matches[4];
 	void *driver_data;
 };
+#define dmi_device_id dmi_system_id	/* fixup MODULE_DEVICE_TABLE(dmi,...); */
 #endif
 
 #define DMI_MATCH(a, b)	{ a, b }

The changelog is too crappy for me. Why did that error occur, and how does the patch fix it?

#4 lore raw

Re: [PATCH] Fixup MODULE_DEVICE_TABLE(dmi, ...)

Quoted 2 lines · Andrew Morton

The changelog is too crappy for me. Why did that error occur, and how does the patch fix it?

Well, you repeated the explanation of what's wrong -- although I don't see how it actually causes an _error_; it works here.

The problem is that the MODULE_DEVICE_TABLE(dmi, foo) line expands to...

extern const struct dmi_device_id __mod_dmi_device_table

      __attribute__ ((unused, alias("foo")));

And 'struct dmi_device_id' doesn't exist -- what we have is 'struct dmi_system_id'.

In practice, this doesn't seem to matter because we never ask the compiler to look _inside_ that struct -- it's just like a forward declaration of 'struct foo' and then using pointers to it.

But it looks like Alexey's managed to find a way to actually make a compiler barf on it, so that increases the motivation to fix it promptly...

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
#5 lore raw

Re: [PATCH] Fixup MODULE_DEVICE_TABLE(dmi, ...)

Quoted 6 lines · David Woodhouse
Quoted 2 lines · Andrew Morton

The changelog is too crappy for me. Why did that error occur, and how does the patch fix it?

Well, you repeated the explanation of what's wrong -- although I don't see how it actually causes an _error_; it works here.

It's just gcc version,

	gcc version 3.4.6 (Gentoo 3.4.6-r2 p1.5)

which is 5-10% faster than 4.1.2, that's why I switched back to it.

Quoted 15 lines

The problem is that the MODULE_DEVICE_TABLE(dmi, foo) line expands to...

extern const struct dmi_device_id __mod_dmi_device_table

      __attribute__ ((unused, alias("foo")));

And 'struct dmi_device_id' doesn't exist -- what we have is 'struct dmi_system_id'.

In practice, this doesn't seem to matter because we never ask the compiler to look _inside_ that struct -- it's just like a forward declaration of 'struct foo' and then using pointers to it.

But it looks like Alexey's managed to find a way to actually make a compiler barf on it, so that increases the motivation to fix it promptly...