Re: [PATCH 22/82] remove linux/version.h from drivers/message/fus ion

Moore, Eric Moore
2005-07-20T05:09:10Z

[-- Attachment #1: Type: text/plain, Size: 875 bytes --]

On Tuesday, July 19, 2005 9:12 PM, Matt Domsch wrote:
>> What you illustrated above is not going to work.
>> If your doing #ifndef around a function, such as scsi_device_online, it's
>> not going to compile
>> when scsi_device_online is already implemented in the kernel tree.
>> The routine scsi_device_online is a function, not a define. For a define
>> this would work.
>
> Sure it does, function names are defined symbols.
>

No its not compiling for me.
I'm currently building drivers for the DELL DKMS kit.
Trying to add support for SLES9 SP2 support ( -191 kernel).
My driver compiles for SLES9 Base(-97) and SP2(-139) but fails for SP2.
Between SP1 and SP2, they added msleep.

Here is the make.log output that you will find in
/var/lib/dkms/mptlinux/3.02.52/build
when it fails to compile.

Also attached is linux_compat.h with the changes you have suggested.

[-- Attachment #2: linux_compat.h --]
[-- Type: application/octet-stream, Size: 3477 bytes --]

/* drivers/message/fusion/linux_compat.h */

#ifndef FUSION_LINUX_COMPAT_H
#define FUSION_LINUX_COMPAT_H

#include <linux/version.h>
#include <linux/sched.h>
#include <linux/jiffies.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_cmnd.h>

/* scsi_print_command() came in lk 2.6.8 kernel,
* prior kernels it was called print_Scsi_Cmnd()
*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8))
extern void print_Scsi_Cmnd(struct scsi_cmnd *cmd);
#else
extern void scsi_print_command(struct scsi_cmnd *cmd);
#endif
static void inline mptscsih_scsi_print_command(struct scsi_cmnd *cmd){
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8))
print_Scsi_Cmnd(cmd);
#else
scsi_print_command(cmd);
#endif
}

/* define scsi_device_online which came in lk 2.6.6,
* to be backward compatible to older variants of lk 2.6
*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6))
static int inline scsi_device_online(struct scsi_device *sdev)
{
return sdev->online;
}
#endif

/* define msleep, msleep_interruptible which came in lk 2.6.8
* to be backward compatible to older variants of lk 2.6
*/
#ifndef msecs_to_jiffies
static inline unsigned long msecs_to_jiffies(const unsigned int m)
{
#if HZ <= 1000 && !(1000 % HZ)
return (m + (1000 / HZ) - 1) / (1000 / HZ);
#elif HZ > 1000 && !(HZ % 1000)
return m * (HZ / 1000);
#else
return (m * HZ + 999) / 1000;
#endif
}
#endif

#ifndef msleep
static void inline msleep(unsigned long msecs)
{
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(msecs_to_jiffies(msecs) + 1);
}
#endif
#ifndef msleep_interruptible
static void inline msleep_interruptible(unsigned long msecs)
{
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(msecs_to_jiffies(msecs) + 1);
}
#endif

/* define __iomem which came in lk 2.6.9
* to be backward compatible to older variants of lk 2.6
*/
#ifndef __iomem
#define __iomem
#endif

/* define pm_message_t which came in lk 2.6.11
* to be backward compatible to older variants of lk 2.6
*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
typedef u32 pm_message_t;
#endif

/* exporting of pci_disable_msi which came in lk 2.6.8
* to be backward compatible to older variants of lk 2.6
*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8))
static inline void pci_disable_msi(struct pci_dev* dev) {}
#endif

/* defines for SAS controlers, to be eventually added to inlcude/linux/pci_ids.h
*/
#ifndef PCI_DEVICE_ID_LSI_SAS1064
#define PCI_DEVICE_ID_LSI_SAS1064 (0x0050)
#endif

#ifndef PCI_DEVICE_ID_LSI_SAS1066
#define PCI_DEVICE_ID_LSI_SAS1066 (0x005E)
#endif

#ifndef PCI_DEVICE_ID_LSI_SAS1068
#define PCI_DEVICE_ID_LSI_SAS1068 (0x0054)
#endif

#ifndef PCI_DEVICE_ID_LSI_SAS1064A
#define PCI_DEVICE_ID_LSI_SAS1064A (0x005C)
#endif

#ifndef PCI_DEVICE_ID_LSI_SAS1064E
#define PCI_DEVICE_ID_LSI_SAS1064E (0x0056)
#endif

#ifndef PCI_DEVICE_ID_LSI_SAS1066E
#define PCI_DEVICE_ID_LSI_SAS1066E (0x005A)
#endif

#ifndef PCI_DEVICE_ID_LSI_SAS1068E
#define PCI_DEVICE_ID_LSI_SAS1068E (0x0058)
#endif

#ifndef PCI_DEVICE_ID_LSI_FC939X
#define PCI_DEVICE_ID_LSI_FC939X (0x0642)
#endif

#ifndef PCI_DEVICE_ID_LSI_FC949X
#define PCI_DEVICE_ID_LSI_FC949X (0x0640)
#endif

/*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
#endif /* _LINUX_COMPAT_H */

[-- Attachment #3: make.log --]
[-- Type: application/octet-stream, Size: 1488 bytes --]

DKMS make.log for mptlinux-3.02.52 for kernel 2.6.5-7.191-smp (i586)
Tue Jul 19 22:42:47 MDT 2005
make: Entering directory `/usr/src/linux-2.6.5-7.191-obj/i386/smp'
make -C /usr/src/linux-2.6.5-7.191 O=/usr/src/linux-2.6.5-7.191-obj/i386/smp modules

WARNING: Symbol version dump /usr/src/linux-2.6.5-7.191-obj/i386/smp/Module.symvers is missing, modules will have CONFIG_MODVERSIONS disabled.

CC [M] /var/lib/dkms/mptlinux/3.02.52/build/mptbase.o
In file included from /var/lib/dkms/mptlinux/3.02.52/build/mptbase.h:58,
from /var/lib/dkms/mptlinux/3.02.52/build/mptbase.c:71:
/var/lib/dkms/mptlinux/3.02.52/build/linux_compat.h:45: error: redefinition of `msecs_to_jiffies'
/usr/src/linux-2.6.5-7.191/include/linux/jiffies.h:96: error: `msecs_to_jiffies' previously defined here
/var/lib/dkms/mptlinux/3.02.52/build/linux_compat.h:58: error: conflicting types for `msleep'
/usr/src/linux-2.6.5-7.191/include/linux/delay.h:41: error: previous declaration of `msleep'
/var/lib/dkms/mptlinux/3.02.52/build/linux_compat.h:65: error: conflicting types for `msleep_interruptible'
/usr/src/linux-2.6.5-7.191/include/linux/delay.h:42: error: previous declaration of `msleep_interruptible'
make[3]: *** [/var/lib/dkms/mptlinux/3.02.52/build/mptbase.o] Error 1
make[2]: *** [_module_/var/lib/dkms/mptlinux/3.02.52/build] Error 2
make[1]: *** [modules] Error 2
make: *** [modules] Error 2
make: Leaving directory `/usr/src/linux-2.6.5-7.191-obj/i386/smp'