| 765 | | } elsif (m@#\s*include\s*"compat.h"@) { |
| 766 | | print OUTPUT << 'EOF'; |
| 767 | | |
| 768 | | /* --> COMPATIBILITY SECTION FOR OLD (2.0, 2.1) KERNELS */ |
| 769 | | |
| 770 | | #ifdef MODULE |
| 771 | | #include <linux/module.h> |
| 772 | | #endif /* def MODULE */ |
| 773 | | #ifndef MODULE_AUTHOR |
| 774 | | #define MODULE_AUTHOR(noone) |
| 775 | | #endif |
| 776 | | #ifndef MODULE_DESCRIPTION |
| 777 | | #define MODULE_DESCRIPTION(none) |
| 778 | | #endif |
| 779 | | #ifndef MODULE_PARM |
| 780 | | #define MODULE_PARM(no,param) |
| 781 | | #endif |
| 782 | | #ifndef MODULE_PARM_DESC |
| 783 | | #define MODULE_PARM_DESC(no,description) |
| 784 | | #endif /* def MODULE */ |
| 785 | | |
| 786 | | EOF |
| 787 | | |
| 788 | | if (`grep THIS_MODULE "$package_root/$package_file"`) { |
| 789 | | print OUTPUT << 'EOF'; |
| 790 | | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,13) |
| 791 | | /* This is safe, because we won't use it for any kernels below 2.3.27 */ |
| 792 | | #define THIS_MODULE NULL |
| 793 | | #endif |
| 794 | | |
| 795 | | EOF |
| 796 | | } |
| 797 | | if (`grep KERNEL_VERSION "$package_root/$package_file"`) { |
| 798 | | print OUTPUT << 'EOF'; |
| 799 | | #include <linux/version.h> |
| 800 | | #ifndef KERNEL_VERSION |
| 801 | | #define KERNEL_VERSION(a,b,c) (((a) << 16) | ((b) << 8) | (c)) |
| 802 | | #endif |
| 803 | | |
| 804 | | EOF |
| 805 | | } |
| 806 | | if (`grep EXPORT_NO_SYMBOLS "$package_root/$package_file"`) { |
| 807 | | print OUTPUT << 'EOF'; |
| 808 | | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) |
| 809 | | #define EXPORT_NO_SYMBOLS |
| 810 | | #endif |
| 811 | | |
| 812 | | EOF |
| 813 | | } |
| 814 | | if (`grep EXPORT_SYMBOL "$package_root/$package_file"`) { |
| 815 | | print OUTPUT << 'EOF'; |
| 816 | | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0) |
| 817 | | #define EXPORT_SYMBOL(noexport) |
| 818 | | #endif |
| 819 | | |
| 820 | | EOF |
| 821 | | } |
| 822 | | if (`grep 'copy_from_user\\|copy_to_user\\|get_user_data' "$package_root/$package_file"`) { |
| 823 | | print OUTPUT << 'EOF'; |
| 824 | | /* copy_from/to_usr is called memcpy_from/to_fs in 2.0 kernels |
| 825 | | get_user was redefined in 2.1 kernels to use two arguments, and returns |
| 826 | | an error code */ |
| 827 | | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,4)) |
| 828 | | #define copy_from_user memcpy_fromfs |
| 829 | | #define copy_to_user memcpy_tofs |
| 830 | | #define get_user_data(to,from) ((to) = get_user(from),0) |
| 831 | | #else |
| 832 | | #include <asm/uaccess.h> |
| 833 | | #define get_user_data(to,from) get_user(to,from) |
| 834 | | #endif |
| 835 | | |
| 836 | | EOF |
| 837 | | } |
| 838 | | if (`grep 'schedule_timeout' "$package_root/$package_file"`) { |
| 839 | | print OUTPUT << 'EOF'; |
| 840 | | /* Add a scheduling fix for the new code in kernel 2.1.127 */ |
| 841 | | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,127)) |
| 842 | | #define schedule_timeout(x) ( current->timeout = jiffies + (x), schedule() ) |
| 843 | | #endif |
| 844 | | |
| 845 | | EOF |
| 846 | | } |
| 847 | | if (`grep 'pci_' "$package_root/$package_file"`) { |
| 848 | | print OUTPUT << 'EOF'; |
| 849 | | /* If the new PCI interface is not present, fall back on the old PCI BIOS |
| 850 | | interface. We also define some things to unite both interfaces. Not |
| 851 | | very nice, but it works like a charm. |
| 852 | | device is the 2.1 struct pci_dev, bus is the 2.0 bus number, dev is the |
| 853 | | 2.0 device/function code, com is the PCI command, and res is the result. */ |
| 854 | | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,54)) |
| 855 | | #define pci_present pcibios_present |
| 856 | | #define pci_read_config_byte_united(device,bus,dev,com,res) \ |
| 857 | | pcibios_read_config_byte(bus,dev,com,res) |
| 858 | | #define pci_read_config_word_united(device,bus,dev,com,res) \ |
| 859 | | pcibios_read_config_word(bus,dev,com,res) |
| 860 | | #define pci_write_config_byte_united(device,bus,dev,com,res) \ |
| 861 | | pcibios_write_config_byte(bus,dev,com,res) |
| 862 | | #define pci_write_config_word_united(device,bus,dev,com,res) \ |
| 863 | | pcibios_write_config_word(bus,dev,com,res) |
| 864 | | #else |
| 865 | | #define pci_read_config_byte_united(device,bus,dev,com,res) \ |
| 866 | | pci_read_config_byte(device,com,res) |
| 867 | | #define pci_read_config_word_united(device,bus,dev,com,res) \ |
| 868 | | pci_read_config_word(device,com,res) |
| 869 | | #define pci_write_config_byte_united(device,bus,dev,com,res) \ |
| 870 | | pci_write_config_byte(device,com,res) |
| 871 | | #define pci_write_config_word_united(device,bus,dev,com,res) \ |
| 872 | | pci_write_config_word(device,com,res) |
| 873 | | #endif |
| 874 | | |
| 875 | | EOF |
| 876 | | } |
| 877 | | if (`grep 'ioremap\\|iounmap' "$package_root/$package_file"`) { |
| 878 | | print OUTPUT << 'EOF'; |
| 879 | | /* I hope this is always correct, even for the PPC, but I really think so. |
| 880 | | And yes, the kernel version is exactly correct */ |
| 881 | | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)) |
| 882 | | #include <linux/mm.h> |
| 883 | | #define ioremap vremap |
| 884 | | #define iounmap vfree |
| 885 | | #endif |
| 886 | | |
| 887 | | EOF |
| 888 | | } |
| 889 | | if (`grep 'init_MUTEX' "$package_root/$package_file"`) { |
| 890 | | print OUTPUT << 'EOF'; |
| 891 | | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)) |
| 892 | | #define init_MUTEX(s) do { *(s) = MUTEX; } while(0) |
| 893 | | #endif |
| 894 | | EOF |
| 895 | | } |
| 896 | | if (`grep '__init' "$package_root/$package_file"`) { |
| 897 | | print OUTPUT << 'EOF'; |
| 898 | | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,53) |
| 899 | | #include <linux/init.h> |
| 900 | | #else |
| 901 | | #define __init |
| 902 | | #define __initdata |
| 903 | | #endif |
| 904 | | EOF |
| 905 | | } |
| 906 | | if (`grep 'PCI_DEVICE_ID_VIA_82C586_3' "$package_root/$package_file"`) { |
| 907 | | print OUTPUT << 'EOF'; |
| 908 | | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,34)) |
| 909 | | #define PCI_DEVICE_ID_VIA_82C586_3 0x3040 |
| 910 | | #endif |
| 911 | | EOF |
| 912 | | |
| 913 | | } |
| 914 | | if (`grep 'PCI_DEVICE_ID_AL_M7101' "$package_root/$package_file"`) { |
| 915 | | print OUTPUT << 'EOF'; |
| 916 | | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,34)) |
| 917 | | #define PCI_DEVICE_ID_AL_M7101 0x7101 |
| 918 | | #endif |
| 919 | | EOF |
| 920 | | } |
| 921 | | if (`grep 'PCI_DEVICE_ID_INTEL_82371AB_3' "$package_root/$package_file"`) { |
| 922 | | print OUTPUT << 'EOF'; |
| 923 | | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,31)) |
| 924 | | #define PCI_DEVICE_ID_INTEL_82371AB_3 0x7113 |
| 925 | | #endif |
| 926 | | EOF |
| 927 | | } |
| 928 | | if (`grep 'PCI_VENDOR_ID_APPLE' "$package_root/$package_file"`) { |
| 929 | | print OUTPUT << 'EOF'; |
| 930 | | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,31)) |
| 931 | | #define PCI_VENDOR_ID_APPLE 0x106b |
| 932 | | #endif |
| 933 | | EOF |
| 934 | | } |
| 935 | | if (`grep 'PCI_DEVICE_ID_APPLE_HYDRA' "$package_root/$package_file"`) { |
| 936 | | print OUTPUT << 'EOF'; |
| 937 | | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,31)) |
| 938 | | #define PCI_DEVICE_ID_APPLE_HYDRA 0x000e |
| 939 | | #endif |
| 940 | | EOF |
| 941 | | } |
| 942 | | if (`grep 'PCI_DEVICE_ID_INTEL_82801AA_3\\|PCI_DEVICE_ID_INTEL_82801AB_3' "$package_root/$package_file"`) { |
| 943 | | print OUTPUT << 'EOF'; |
| 944 | | #ifndef PCI_DEVICE_ID_INTEL_82801AA_3 |
| 945 | | #define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413 |
| 946 | | #endif |
| 947 | | #ifndef PCI_DEVICE_ID_INTEL_82801AB_3 |
| 948 | | #define PCI_DEVICE_ID_INTEL_82801AB_3 0x2423 |
| 949 | | #endif |
| 950 | | EOF |
| 951 | | } |
| 952 | | print OUTPUT << 'EOF'; |
| 953 | | |
| 954 | | /* --> END OF COMPATIBILITY SECTION */ |
| 955 | | |
| 956 | | EOF |