From: Rusty Russell <rusty@rustcorp.com.au>

Previously, default aliases were hardwired into modutils.  Now they should
be inside the modules, using MODULE_ALIAS() (they will be overridden by any
user alias).



 25-akpm/arch/i386/kernel/apm.c            |    2 +-
 25-akpm/drivers/char/agp/backend.c        |    1 +
 25-akpm/drivers/char/agp/frontend.c       |    1 -
 25-akpm/drivers/char/busmouse.c           |    1 +
 25-akpm/drivers/char/lp.c                 |    1 +
 25-akpm/drivers/char/nvram.c              |    1 +
 25-akpm/drivers/char/rtc.c                |    1 +
 25-akpm/drivers/char/watchdog/wdt.c       |    2 ++
 25-akpm/drivers/media/video/bttv-driver.c |    1 +
 25-akpm/drivers/net/ppp_generic.c         |    1 +
 25-akpm/drivers/net/tun.c                 |    1 +
 25-akpm/include/linux/device.h            |    5 +++++
 25-akpm/include/linux/miscdevice.h        |    5 +++++
 13 files changed, 21 insertions(+), 2 deletions(-)

diff -puN arch/i386/kernel/apm.c~MODULE_ALIAS-in-char-devices arch/i386/kernel/apm.c
--- 25/arch/i386/kernel/apm.c~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/arch/i386/kernel/apm.c	Tue Sep  2 08:28:38 2003
@@ -2080,4 +2080,4 @@ MODULE_PARM_DESC(idle_period,
 MODULE_PARM(smp, "i");
 MODULE_PARM_DESC(smp,
 	"Set this to enable APM use on an SMP platform. Use with caution on older systems");
-
+MODULE_ALIAS_MISCDEV(APM_MINOR_DEV);
diff -puN drivers/char/agp/backend.c~MODULE_ALIAS-in-char-devices drivers/char/agp/backend.c
--- 25/drivers/char/agp/backend.c~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/drivers/char/agp/backend.c	Tue Sep  2 08:28:38 2003
@@ -331,6 +331,7 @@ __setup("agp=", agp_setup);
 MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>");
 MODULE_DESCRIPTION("AGP GART driver");
 MODULE_LICENSE("GPL and additional rights");
+MODULE_ALIAS_MISCDEV(AGPGART_MINOR);
 
 module_init(agp_init);
 module_exit(agp_exit);
diff -puN drivers/char/agp/frontend.c~MODULE_ALIAS-in-char-devices drivers/char/agp/frontend.c
--- 25/drivers/char/agp/frontend.c~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/drivers/char/agp/frontend.c	Tue Sep  2 08:28:38 2003
@@ -1097,4 +1097,3 @@ void agp_frontend_cleanup(void)
 {
 	misc_deregister(&agp_miscdev);
 }
-
diff -puN drivers/char/busmouse.c~MODULE_ALIAS-in-char-devices drivers/char/busmouse.c
--- 25/drivers/char/busmouse.c~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/drivers/char/busmouse.c	Tue Sep  2 08:28:38 2003
@@ -452,4 +452,5 @@ EXPORT_SYMBOL(busmouse_add_buttons);
 EXPORT_SYMBOL(register_busmouse);
 EXPORT_SYMBOL(unregister_busmouse);
 
+MODULE_ALIAS_MISCDEV(BUSMOUSE_MINOR);
 MODULE_LICENSE("GPL");
diff -puN drivers/char/lp.c~MODULE_ALIAS-in-char-devices drivers/char/lp.c
--- 25/drivers/char/lp.c~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/drivers/char/lp.c	Tue Sep  2 08:28:38 2003
@@ -965,4 +965,5 @@ __setup("lp=", lp_setup);
 module_init(lp_init_module);
 module_exit(lp_cleanup_module);
 
+MODULE_ALIAS("char-major-" __stringify(LP_MAJOR));
 MODULE_LICENSE("GPL");
diff -puN drivers/char/nvram.c~MODULE_ALIAS-in-char-devices drivers/char/nvram.c
--- 25/drivers/char/nvram.c~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/drivers/char/nvram.c	Tue Sep  2 08:28:38 2003
@@ -923,3 +923,4 @@ EXPORT_SYMBOL(__nvram_check_checksum);
 EXPORT_SYMBOL(nvram_check_checksum);
 EXPORT_SYMBOL(__nvram_set_checksum);
 EXPORT_SYMBOL(nvram_set_checksum);
+MODULE_ALIAS_MISCDEV(NVRAM_MINOR);
diff -puN drivers/char/rtc.c~MODULE_ALIAS-in-char-devices drivers/char/rtc.c
--- 25/drivers/char/rtc.c~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/drivers/char/rtc.c	Tue Sep  2 08:28:38 2003
@@ -1345,3 +1345,4 @@ static void set_rtc_irq_bit(unsigned cha
 
 MODULE_AUTHOR("Paul Gortmaker");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_MISCDEV(RTC_MINOR);
diff -puN drivers/char/watchdog/wdt.c~MODULE_ALIAS-in-char-devices drivers/char/watchdog/wdt.c
--- 25/drivers/char/watchdog/wdt.c~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/drivers/char/watchdog/wdt.c	Tue Sep  2 08:28:38 2003
@@ -579,4 +579,6 @@ module_exit(wdt_exit);
 
 MODULE_AUTHOR("Alan Cox");
 MODULE_DESCRIPTION("Driver for ISA ICS watchdog cards (WDT500/501)");
+MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
+MODULE_ALIAS_MISCDEV(TEMP_MINOR);
 MODULE_LICENSE("GPL");
diff -puN drivers/media/video/bttv-driver.c~MODULE_ALIAS-in-char-devices drivers/media/video/bttv-driver.c
--- 25/drivers/media/video/bttv-driver.c~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/drivers/media/video/bttv-driver.c	Tue Sep  2 08:28:38 2003
@@ -115,6 +115,7 @@ MODULE_PARM(v4l2,"i");
 MODULE_DESCRIPTION("bttv - v4l/v4l2 driver module for bt848/878 based cards");
 MODULE_AUTHOR("Ralph Metzler & Marcus Metzler & Gerd Knorr");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_CHARDEV_MAJOR(VIDEO_MAJOR);
 
 /* kernel args */
 #ifndef MODULE
diff -puN drivers/net/ppp_generic.c~MODULE_ALIAS-in-char-devices drivers/net/ppp_generic.c
--- 25/drivers/net/ppp_generic.c~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/drivers/net/ppp_generic.c	Tue Sep  2 08:28:38 2003
@@ -2670,3 +2670,4 @@ EXPORT_SYMBOL(ppp_unregister_compressor)
 EXPORT_SYMBOL(all_ppp_units); /* for debugging */
 EXPORT_SYMBOL(all_channels); /* for debugging */
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_CHARDEV_MAJOR(PPP_MAJOR);
diff -puN drivers/net/tun.c~MODULE_ALIAS-in-char-devices drivers/net/tun.c
--- 25/drivers/net/tun.c~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/drivers/net/tun.c	Tue Sep  2 08:28:38 2003
@@ -640,3 +640,4 @@ void tun_cleanup(void)
 module_init(tun_init);
 module_exit(tun_cleanup);
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_MISCDEV(TUN_MINOR);
diff -puN include/linux/device.h~MODULE_ALIAS-in-char-devices include/linux/device.h
--- 25/include/linux/device.h~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/include/linux/device.h	Tue Sep  2 08:28:39 2003
@@ -398,4 +398,9 @@ extern void firmware_unregister(struct s
 #define dev_warn(dev, format, arg...)		\
 	dev_printk(KERN_WARNING , dev , format , ## arg)
 
+/* Create alias, so I can be autoloaded. */
+#define MODULE_ALIAS_CHARDEV(major,minor) \
+	MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
+#define MODULE_ALIAS_CHARDEV_MAJOR(major) \
+	MODULE_ALIAS("char-major-" __stringify(major) "-*")
 #endif /* _DEVICE_H_ */
diff -puN include/linux/miscdevice.h~MODULE_ALIAS-in-char-devices include/linux/miscdevice.h
--- 25/include/linux/miscdevice.h~MODULE_ALIAS-in-char-devices	Tue Sep  2 08:28:38 2003
+++ 25-akpm/include/linux/miscdevice.h	Tue Sep  2 08:28:39 2003
@@ -1,5 +1,7 @@
 #ifndef _LINUX_MISCDEVICE_H
 #define _LINUX_MISCDEVICE_H
+#include <linux/module.h>
+#include <linux/major.h>
 
 #define BUSMOUSE_MINOR 0
 #define PSMOUSE_MINOR  1
@@ -48,4 +50,7 @@ struct miscdevice 
 extern int misc_register(struct miscdevice * misc);
 extern int misc_deregister(struct miscdevice * misc);
 
+#define MODULE_ALIAS_MISCDEV(minor)				\
+	MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR)	\
+	"-" __stringify(minor))
 #endif

_