diff -urN hcfusbmodem-1.06powerpcfull/modules/GPL/oscompat.h hcfusbmodem-1.06powerpcfull-simple_class/modules/GPL/oscompat.h --- hcfusbmodem-1.06powerpcfull/modules/GPL/oscompat.h 2005-06-20 15:18:46.000000000 -0400 +++ hcfusbmodem-1.06powerpcfull-simple_class/modules/GPL/oscompat.h 2005-09-07 18:26:39.000000000 -0400 @@ -543,4 +543,16 @@ #define PCI_SLOT_NAME(x) (x)->dev.bus_id #endif +#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) +#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) +#endif + #endif /* __OSCOMPAT_H */ diff -urN hcfusbmodem-1.06powerpcfull/modules/Makefile hcfusbmodem-1.06powerpcfull-simple_class/modules/Makefile --- hcfusbmodem-1.06powerpcfull/modules/Makefile 2005-06-20 15:25:00.000000000 -0400 +++ hcfusbmodem-1.06powerpcfull-simple_class/modules/Makefile 2005-09-07 18:26:39.000000000 -0400 @@ -48,6 +48,16 @@ KMODS_DIR := /lib/modules/$(KERNELVER) CNXT_MODS_DIR := $(KMODS_DIR)/extra +# On SuSE 9.0 and up, CNXT_KERNELSRC points to an incomplete kernel source +# directory and some include files are not available in this tree +SUSE_OBJ_TREE := $(shell if grep -q '^KERNELSRC ' "${CNXT_KERNELSRC}/Makefile" && [ -d "${CNXT_KERNELSRC}" ]; then echo "yes"; else echo "no"; fi) + +ifeq ($(SUSE_OBJ_TREE),yes) +REAL_KERNELSRC := $(shell grep '^KERNELSRC ' "${CNXT_KERNELSRC}/Makefile" | awk '{print $3}') +else +REAL_KERNELSRC := $(CNXT_KERNELSRC) +endif + FOUND_PCI_DEV_SLOT_NAME := $(shell grep -q 'slot_name' ${CNXT_KERNELSRC}/include/linux/pci.h 2> /dev/null && echo -DFOUND_PCI_DEV_SLOT_NAME) CFLAGS+= $(FOUND_PCI_DEV_SLOT_NAME) @@ -57,6 +67,9 @@ KO= ko KBUILD_EXTMOD_SUPPORTED := $(shell egrep -q 'KBUILD_EXTMOD|KERNEL_SOURCE|KERNELSRC' ${CNXT_KERNELSRC}/Makefile 2>/dev/null && echo yes || echo no) +FOUND_CLASS_SIMPLE := $(shell grep -q 'class_simple_device_add' ${REAL_KERNELSRC}/include/linux/device.h 2> /dev/null && echo -DFOUND_CLASS_SIMPLE) +CFLAGS+= $(FOUND_CLASS_SIMPLE) + else KO= o # Configure compiler (on some systems, kgcc must be used to compile kernel code) diff -urN hcfusbmodem-1.06powerpcfull/modules/osdiag.c hcfusbmodem-1.06powerpcfull-simple_class/modules/osdiag.c --- hcfusbmodem-1.06powerpcfull/modules/osdiag.c 2004-12-14 02:50:07.000000000 -0500 +++ hcfusbmodem-1.06powerpcfull-simple_class/modules/osdiag.c 2005-09-07 18:26:44.000000000 -0400 @@ -30,7 +30,11 @@ static struct list_head diag_instance_list = LIST_HEAD_INIT(diag_instance_list); static spinlock_t diag_lock = SPIN_LOCK_UNLOCKED; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,2) +#ifdef FOUND_CLASS_SIMPLE static struct class_simple *diag_class; +#else +static struct class *diag_class; +#endif #endif #define common_instance_header \ @@ -659,7 +663,7 @@ #else #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,2) if (!IS_ERR(diag_class)) { - class_simple_device_add(diag_class, MKDEV(diagmajor, pDiag->hwInstNum), hwDevLink, CNXTTARGET"diag%d", pDiag->hwInstNum); + CLASS_DEVICE_CREATE(diag_class, MKDEV(diagmajor, pDiag->hwInstNum), hwDevLink, CNXTTARGET"diag%d", pDiag->hwInstNum); } #endif @@ -764,7 +768,7 @@ } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,2) if (!IS_ERR(diag_class)) - class_simple_device_remove(MKDEV(diagmajor, pDiag->hwInstNum)); + CLASS_DEVICE_DESTROY(diag_class, MKDEV(diagmajor, pDiag->hwInstNum)); #endif #endif @@ -834,14 +838,14 @@ devfs_remove(CNXTTARGET"diagdmp"); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,2) if (!IS_ERR(diag_class)) - class_simple_device_remove(MKDEV(diagmajor, CNXTDIAGDMPMINOR)); + CLASS_DEVICE_DESTROY(diag_class, MKDEV(diagmajor, CNXTDIAGDMPMINOR)); #endif #endif #endif /* DMP || DMP_RETAIL */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,2) if (!IS_ERR(diag_class)) - class_simple_destroy(diag_class); + CLASS_DESTROY(diag_class); #endif if(diagmajor > 0) unregister_chrdev(diagmajor, CNXTTARGET"diag"); @@ -865,7 +869,7 @@ } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,2) - diag_class = class_simple_create(THIS_MODULE, CNXTTARGET"diag"); + diag_class = CLASS_CREATE(THIS_MODULE, CNXTTARGET"diag"); if (IS_ERR(diag_class)) { printk(KERN_ERR "%s: cannot create simple class (%ld)\n", __FUNCTION__, PTR_ERR(diag_class)); if(diagmajor > 0) @@ -884,7 +888,7 @@ #else #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,2) if (!IS_ERR(diag_class)) { - class_simple_device_add(diag_class, MKDEV(diagmajor, CNXTDIAGDMPMINOR), NULL, CNXTTARGET"diagdmp"); + CLASS_DEVICE_CREATE(diag_class, MKDEV(diagmajor, CNXTDIAGDMPMINOR), NULL, CNXTTARGET"diagdmp"); } #endif devfs_mk_cdev(MKDEV(diagmajor, CNXTDIAGDMPMINOR), S_IFCHR | S_IRUSR | S_IWUSR, CNXTTARGET"diagdmp");