diff -urNp slmodem-2.9.9d.orig/drivers/Makefile slmodem-2.9.9d/drivers/Makefile --- slmodem-2.9.9d.orig/drivers/Makefile 2005-04-23 01:43:04.000000000 +0200 +++ slmodem-2.9.9d/drivers/Makefile 2005-06-08 19:31:20.000000000 +0200 @@ -18,7 +18,9 @@ KERNEL_DIR:=/lib/modules/$(shell uname -r)/build -EXTRA_CFLAGS = -I$(obj) -I$(obj)/../modem +FOUND_CLASS_SIMPLE := $(shell grep -q 'class_simple_device_add' ${KERNEL_DIR}/include/linux/device.h 2> /dev/null && echo -DFOUND_CLASS_SIMPLE) + +EXTRA_CFLAGS = -I$(obj) -I$(obj)/../modem $(FOUND_CLASS_SIMPLE) obj-m := slamr.o slusb.o @@ -61,7 +63,7 @@ slusb-objs:= old_st7554.o obj:=. module-dir:=${DESTDIR}/lib/modules/$(KERNEL_VER)/misc -CFLAGS:= -Wall -pipe -O3 -fomit-frame-pointer -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -DMODVERSIONS --include $(KERNEL_DIR)/include/linux/modversions.h -I$(KERNEL_DIR)/include +CFLAGS:= -Wall -pipe -O3 -fomit-frame-pointer -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -DMODVERSIONS --include $(KERNEL_DIR)/include/linux/modversions.h -I$(KERNEL_DIR)/include $(FOUND_CLASS_SIMPLE) all: $(obj-m) diff -urNp slmodem-2.9.9d.orig/drivers/amrmo_init.c slmodem-2.9.9d/drivers/amrmo_init.c --- slmodem-2.9.9d.orig/drivers/amrmo_init.c 2005-04-23 01:43:04.000000000 +0200 +++ slmodem-2.9.9d/drivers/amrmo_init.c 2005-06-08 19:37:56.000000000 +0200 @@ -283,7 +283,19 @@ MODULE_DEVICE_TABLE (pci, amrmo_pci_tbl) static struct amrmo_struct *amrmo_table[MAXNUM] = {}; #ifndef OLD_KERNEL +#ifdef FOUND_CLASS_SIMPLE +#define CLASS_DEVICE_CREATE(class, dev, device, fmt, rest) class_simple_device_add(class, dev, device, fmt, rest) +#define CLASS_DESTROY(class) class_simple_destroy(class) +#define CLASS_DEVICE_DESTROY(class, dev) class_simple_device_remove(dev) +#define CLASS_CREATE(owner, name) class_simple_create(owner, name) static struct class_simple *amrmo_class; +#else +#define CLASS_DEVICE_CREATE(class, dev, device, fmt, rest) class_device_create(class, dev, device, fmt, rest) +#define CLASS_DESTROY(class) class_destroy(class) +#define CLASS_DEVICE_DESTROY(class, dev) class_device_destroy(class, dev) +#define CLASS_CREATE(owner, name) class_create(owner, name) +static struct class *amrmo_class; +#endif #endif /* @@ -629,7 +641,7 @@ static int __init amrmo_pci_probe(struct } #endif #else - class_simple_device_add(amrmo_class, MKDEV(AMRMO_MAJOR, i), NULL, "slamr%d", i); + CLASS_DEVICE_CREATE(amrmo_class, MKDEV(AMRMO_MAJOR, i), NULL, "slamr%d", i); devfs_mk_cdev(MKDEV(AMRMO_MAJOR,i), S_IFCHR|S_IRUSR|S_IWUSR, "slamr%d", i); #endif return 0; @@ -661,7 +673,7 @@ static void __exit amrmo_pci_remove(stru } #endif #else - class_simple_device_remove(MKDEV(AMRMO_MAJOR, amrmo->num)); + CLASS_DEVICE_DESTROY(amrmo_class, MKDEV(AMRMO_MAJOR, amrmo->num)); devfs_remove("slamr%d", amrmo->num); #endif amrmo_table[amrmo->num] = NULL; @@ -745,7 +757,7 @@ static int __init amrmo_init(void) } #ifndef OLD_KERNEL - amrmo_class = class_simple_create(THIS_MODULE, "slamr"); + amrmo_class = CLASS_CREATE(THIS_MODULE, "slamr"); if (IS_ERR(amrmo_class)) { int err = PTR_ERR(amrmo_class); printk(KERN_ERR "slamr: failure creating simple class, error %d\n", err); @@ -755,7 +767,7 @@ static int __init amrmo_init(void) if ((err = pci_register_driver(&amrmo_pci_driver)) < 0) { pci_unregister_driver(&amrmo_pci_driver); #ifndef OLD_KERNEL - class_simple_destroy(amrmo_class); + CLASS_DESTROY(amrmo_class); #endif return err; } @@ -763,7 +775,7 @@ static int __init amrmo_init(void) if(register_chrdev(AMRMO_MAJOR, "slamr", &amrmo_fops) < 0) { pci_unregister_driver(&amrmo_pci_driver); #ifndef OLD_KERNEL - class_simple_destroy(amrmo_class); + CLASS_DESTROY(amrmo_class); #endif return -ENOMEM; } @@ -777,7 +789,7 @@ static void __exit amrmo_exit(void) unregister_chrdev(AMRMO_MAJOR,"slamr"); pci_unregister_driver(&amrmo_pci_driver); #ifndef OLD_KERNEL - class_simple_destroy(amrmo_class); + CLASS_DESTROY(amrmo_class); #endif } diff -urNp slmodem-2.9.9d.orig/drivers/st7554.c slmodem-2.9.9d/drivers/st7554.c --- slmodem-2.9.9d.orig/drivers/st7554.c 2005-04-23 01:43:04.000000000 +0200 +++ slmodem-2.9.9d/drivers/st7554.c 2005-06-08 19:41:07.000000000 +0200 @@ -206,7 +206,19 @@ struct st7554_state { static struct st7554_state *st7554_table[MAX_MODEMS] = {}; +#ifdef FOUND_CLASS_SIMPLE +#define CLASS_DEVICE_CREATE(class, dev, device, fmt, rest) class_simple_device_add(class, dev, device, fmt, rest) +#define CLASS_DESTROY(class) class_simple_destroy(class) +#define CLASS_DEVICE_DESTROY(class, dev) class_simple_device_remove(dev) +#define CLASS_CREATE(owner, name) class_simple_create(owner, name) static struct class_simple *st7554_class; +#else +#define CLASS_DEVICE_CREATE(class, dev, device, fmt, rest) class_device_create(class, dev, device, fmt, rest) +#define CLASS_DESTROY(class) class_destroy(class) +#define CLASS_DEVICE_DESTROY(class, dev) class_device_destroy(class, dev) +#define CLASS_CREATE(owner, name) class_create(owner, name) +static struct class *st7554_class; +#endif static DECLARE_MUTEX(open_sem); @@ -1271,7 +1283,7 @@ static int st7554_probe(struct usb_inter } usb_set_intfdata(interface, s ); - class_simple_device_add(st7554_class, MKDEV(243, i), NULL, "slusb%d", i); + CLASS_DEVICE_CREATE(st7554_class, MKDEV(243, i), NULL, "slusb%d", i); devfs_mk_cdev(MKDEV(243,i),S_IFCHR|S_IRUSR|S_IWUSR,"slusb%d",i); USB_INFO(KERN_INFO "slusb: slusb%d is found.\n", s->minor); @@ -1300,7 +1312,7 @@ static void st7554_disconnect(struct usb return; } - class_simple_device_remove(MKDEV(243, s->minor)); + CLASS_DEVICE_DESTROY(st7554_class, MKDEV(243, s->minor)); devfs_remove("slusb%d",s->minor); st7554_stop(s); @@ -1334,7 +1346,7 @@ static int __init st7554_modem_init(void int ret; USB_INFO ("ST7554 USB Modem.\n"); - st7554_class = class_simple_create(THIS_MODULE, "slusb"); + st7554_class = CLASS_CREATE(THIS_MODULE, "slusb"); if (IS_ERR(st7554_class)) { ret = PTR_ERR(st7554_class); USB_ERR("st7554_modem_init: failed to create sysfs class, error %d\n", ret); @@ -1344,13 +1356,13 @@ static int __init st7554_modem_init(void ret = usb_register(&st7554_usb_driver); if ( ret ) { USB_ERR ("st7554_modem_init: cannot register usb device.\n"); - class_simple_destroy(st7554_class); + CLASS_DESTROY(st7554_class); return ret; } if(register_chrdev(243, "slusb", &st7554_fops) < 0) { usb_deregister(&st7554_usb_driver); - class_simple_destroy(st7554_class); + CLASS_DESTROY(st7554_class); return -ENOMEM; } return 0; @@ -1362,7 +1374,7 @@ static void __exit st7554_modem_exit(voi USB_DBG ("st7554: exit...\n"); unregister_chrdev(243,"slusb"); usb_deregister(&st7554_usb_driver); - class_simple_destroy(st7554_class); + CLASS_DESTROY(st7554_class); }