Commit 8d8c37c7 authored by James Bottomley's avatar James Bottomley

remove old ifdefs aic7xxx

From: janitor@sternwelten.at

 Patches to remove some old ifdefs.
 remove most of the #include <linux/version.h>
 kill compat cruft like #define ahd_pci_set_dma_mask pci_set_dma_mask
Signed-off-by: default avatarMaximilian Attems <janitor@sternwelten.at>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 5708e7bd
...@@ -521,7 +521,7 @@ struct ahc_dma_seg { ...@@ -521,7 +521,7 @@ struct ahc_dma_seg {
struct sg_map_node { struct sg_map_node {
bus_dmamap_t sg_dmamap; bus_dmamap_t sg_dmamap;
bus_addr_t sg_physaddr; dma_addr_t sg_physaddr;
struct ahc_dma_seg* sg_vaddr; struct ahc_dma_seg* sg_vaddr;
SLIST_ENTRY(sg_map_node) links; SLIST_ENTRY(sg_map_node) links;
}; };
...@@ -584,7 +584,7 @@ struct scb { ...@@ -584,7 +584,7 @@ struct scb {
struct scb_platform_data *platform_data; struct scb_platform_data *platform_data;
struct sg_map_node *sg_map; struct sg_map_node *sg_map;
struct ahc_dma_seg *sg_list; struct ahc_dma_seg *sg_list;
bus_addr_t sg_list_phys; dma_addr_t sg_list_phys;
u_int sg_count;/* How full ahc_dma_seg is */ u_int sg_count;/* How full ahc_dma_seg is */
}; };
...@@ -611,10 +611,10 @@ struct scb_data { ...@@ -611,10 +611,10 @@ struct scb_data {
*/ */
bus_dma_tag_t hscb_dmat; /* dmat for our hardware SCB array */ bus_dma_tag_t hscb_dmat; /* dmat for our hardware SCB array */
bus_dmamap_t hscb_dmamap; bus_dmamap_t hscb_dmamap;
bus_addr_t hscb_busaddr; dma_addr_t hscb_busaddr;
bus_dma_tag_t sense_dmat; bus_dma_tag_t sense_dmat;
bus_dmamap_t sense_dmamap; bus_dmamap_t sense_dmamap;
bus_addr_t sense_busaddr; dma_addr_t sense_busaddr;
bus_dma_tag_t sg_dmat; /* dmat for our sg segments */ bus_dma_tag_t sg_dmat; /* dmat for our sg segments */
SLIST_HEAD(, sg_map_node) sg_maps; SLIST_HEAD(, sg_map_node) sg_maps;
uint8_t numscbs; uint8_t numscbs;
...@@ -1069,14 +1069,14 @@ struct ahc_softc { ...@@ -1069,14 +1069,14 @@ struct ahc_softc {
bus_dma_tag_t parent_dmat; bus_dma_tag_t parent_dmat;
bus_dma_tag_t shared_data_dmat; bus_dma_tag_t shared_data_dmat;
bus_dmamap_t shared_data_dmamap; bus_dmamap_t shared_data_dmamap;
bus_addr_t shared_data_busaddr; dma_addr_t shared_data_busaddr;
/* /*
* Bus address of the one byte buffer used to * Bus address of the one byte buffer used to
* work-around a DMA bug for chips <= aic7880 * work-around a DMA bug for chips <= aic7880
* in target mode. * in target mode.
*/ */
bus_addr_t dma_bug_buf; dma_addr_t dma_bug_buf;
/* Number of enabled target mode device on this card */ /* Number of enabled target mode device on this card */
u_int enabled_luns; u_int enabled_luns;
......
...@@ -4199,9 +4199,9 @@ ahc_probe_scbs(struct ahc_softc *ahc) { ...@@ -4199,9 +4199,9 @@ ahc_probe_scbs(struct ahc_softc *ahc) {
static void static void
ahc_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) ahc_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
{ {
bus_addr_t *baddr; dma_addr_t *baddr;
baddr = (bus_addr_t *)arg; baddr = (dma_addr_t *)arg;
*baddr = segs->ds_addr; *baddr = segs->ds_addr;
} }
...@@ -4456,7 +4456,7 @@ ahc_alloc_scbs(struct ahc_softc *ahc) ...@@ -4456,7 +4456,7 @@ ahc_alloc_scbs(struct ahc_softc *ahc)
struct scb_data *scb_data; struct scb_data *scb_data;
struct scb *next_scb; struct scb *next_scb;
struct sg_map_node *sg_map; struct sg_map_node *sg_map;
bus_addr_t physaddr; dma_addr_t physaddr;
struct ahc_dma_seg *segs; struct ahc_dma_seg *segs;
int newcount; int newcount;
int i; int i;
...@@ -4820,7 +4820,7 @@ ahc_init(struct ahc_softc *ahc) ...@@ -4820,7 +4820,7 @@ ahc_init(struct ahc_softc *ahc)
if (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1, if (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1,
/*boundary*/BUS_SPACE_MAXADDR_32BIT + 1, /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
/*lowaddr*/ahc->flags & AHC_39BIT_ADDRESSING /*lowaddr*/ahc->flags & AHC_39BIT_ADDRESSING
? (bus_addr_t)0x7FFFFFFFFFULL ? (dma_addr_t)0x7FFFFFFFFFULL
: BUS_SPACE_MAXADDR_32BIT, : BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR, /*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL, /*filter*/NULL, /*filterarg*/NULL,
......
...@@ -129,10 +129,7 @@ ...@@ -129,10 +129,7 @@
*/ */
#include "aiclib.c" #include "aiclib.c"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
#include <linux/init.h> /* __setup */ #include <linux/init.h> /* __setup */
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
#include "sd.h" /* For geometry detection */ #include "sd.h" /* For geometry detection */
...@@ -152,14 +149,6 @@ spinlock_t ahc_list_spinlock; ...@@ -152,14 +149,6 @@ spinlock_t ahc_list_spinlock;
u_int ahc_linux_nseg; u_int ahc_linux_nseg;
#endif #endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
struct proc_dir_entry proc_scsi_aic7xxx = {
PROC_SCSI_AIC7XXX, 7, "aic7xxx",
S_IFDIR | S_IRUGO | S_IXUGO, 2,
0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
#endif
/* /*
* Set this to the delay in seconds after SCSI bus reset. * Set this to the delay in seconds after SCSI bus reset.
* Note, we honor this only for the initial bus reset. * Note, we honor this only for the initial bus reset.
...@@ -572,7 +561,7 @@ static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*); ...@@ -572,7 +561,7 @@ static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*);
static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb, static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb,
struct ahc_dma_seg *sg, struct ahc_dma_seg *sg,
bus_addr_t addr, bus_size_t len); dma_addr_t addr, bus_size_t len);
static __inline void static __inline void
ahc_schedule_completeq(struct ahc_softc *ahc) ahc_schedule_completeq(struct ahc_softc *ahc)
...@@ -590,14 +579,7 @@ ahc_schedule_completeq(struct ahc_softc *ahc) ...@@ -590,14 +579,7 @@ ahc_schedule_completeq(struct ahc_softc *ahc)
static __inline void static __inline void
ahc_schedule_runq(struct ahc_softc *ahc) ahc_schedule_runq(struct ahc_softc *ahc)
{ {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
tasklet_schedule(&ahc->platform_data->runq_tasklet); tasklet_schedule(&ahc->platform_data->runq_tasklet);
#else
/*
* Tasklets are not available, so run inline.
*/
ahc_runq_tasklet((unsigned long)ahc);
#endif
} }
static __inline struct ahc_linux_device* static __inline struct ahc_linux_device*
...@@ -728,7 +710,7 @@ ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb) ...@@ -728,7 +710,7 @@ ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb)
static __inline int static __inline int
ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb, ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb,
struct ahc_dma_seg *sg, bus_addr_t addr, bus_size_t len) struct ahc_dma_seg *sg, dma_addr_t addr, bus_size_t len)
{ {
int consumed; int consumed;
...@@ -740,7 +722,7 @@ ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb, ...@@ -740,7 +722,7 @@ ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb,
sg->addr = ahc_htole32(addr & 0xFFFFFFFF); sg->addr = ahc_htole32(addr & 0xFFFFFFFF);
scb->platform_data->xfer_len += len; scb->platform_data->xfer_len += len;
if (sizeof(bus_addr_t) > 4 if (sizeof(dma_addr_t) > 4
&& (ahc->flags & AHC_39BIT_ADDRESSING) != 0) && (ahc->flags & AHC_39BIT_ADDRESSING) != 0)
len |= (addr >> 8) & AHC_SG_HIGH_ADDR_MASK; len |= (addr >> 8) & AHC_SG_HIGH_ADDR_MASK;
...@@ -877,11 +859,7 @@ ahc_linux_detect(Scsi_Host_Template *template) ...@@ -877,11 +859,7 @@ ahc_linux_detect(Scsi_Host_Template *template)
"aic7xxx: insmod or else it might trash certain memory areas.\n"); "aic7xxx: insmod or else it might trash certain memory areas.\n");
#endif #endif
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
template->proc_name = "aic7xxx"; template->proc_name = "aic7xxx";
#else
template->proc_dir = &proc_scsi_aic7xxx;
#endif
/* /*
* Initialize our softc list lock prior to * Initialize our softc list lock prior to
...@@ -1323,28 +1301,20 @@ ahc_runq_tasklet(unsigned long data) ...@@ -1323,28 +1301,20 @@ ahc_runq_tasklet(unsigned long data)
{ {
struct ahc_softc* ahc; struct ahc_softc* ahc;
struct ahc_linux_device *dev; struct ahc_linux_device *dev;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
u_long flags; u_long flags;
#endif
ahc = (struct ahc_softc *)data; ahc = (struct ahc_softc *)data;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
ahc_lock(ahc, &flags); ahc_lock(ahc, &flags);
#endif
while ((dev = ahc_linux_next_device_to_run(ahc)) != NULL) { while ((dev = ahc_linux_next_device_to_run(ahc)) != NULL) {
TAILQ_REMOVE(&ahc->platform_data->device_runq, dev, links); TAILQ_REMOVE(&ahc->platform_data->device_runq, dev, links);
dev->flags &= ~AHC_DEV_ON_RUN_LIST; dev->flags &= ~AHC_DEV_ON_RUN_LIST;
ahc_linux_check_device_queue(ahc, dev); ahc_linux_check_device_queue(ahc, dev);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
/* Yeild to our interrupt handler */ /* Yeild to our interrupt handler */
ahc_unlock(ahc, &flags); ahc_unlock(ahc, &flags);
ahc_lock(ahc, &flags); ahc_lock(ahc, &flags);
#endif
} }
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
ahc_unlock(ahc, &flags); ahc_unlock(ahc, &flags);
#endif
} }
/******************************** Macros **************************************/ /******************************** Macros **************************************/
...@@ -1357,7 +1327,7 @@ ahc_runq_tasklet(unsigned long data) ...@@ -1357,7 +1327,7 @@ ahc_runq_tasklet(unsigned long data)
int int
ahc_dma_tag_create(struct ahc_softc *ahc, bus_dma_tag_t parent, ahc_dma_tag_create(struct ahc_softc *ahc, bus_dma_tag_t parent,
bus_size_t alignment, bus_size_t boundary, bus_size_t alignment, bus_size_t boundary,
bus_addr_t lowaddr, bus_addr_t highaddr, dma_addr_t lowaddr, dma_addr_t highaddr,
bus_dma_filter_t *filter, void *filterarg, bus_dma_filter_t *filter, void *filterarg,
bus_size_t maxsize, int nsegments, bus_size_t maxsize, int nsegments,
bus_size_t maxsegsz, int flags, bus_dma_tag_t *ret_tag) bus_size_t maxsegsz, int flags, bus_dma_tag_t *ret_tag)
...@@ -1394,7 +1364,6 @@ ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr, ...@@ -1394,7 +1364,6 @@ ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr,
{ {
bus_dmamap_t map; bus_dmamap_t map;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT); map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT);
if (map == NULL) if (map == NULL)
return (ENOMEM); return (ENOMEM);
...@@ -1406,7 +1375,7 @@ ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr, ...@@ -1406,7 +1375,7 @@ ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr,
* our dma mask when doing allocations. * our dma mask when doing allocations.
*/ */
if (ahc->dev_softc != NULL) if (ahc->dev_softc != NULL)
if (ahc_pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF)) { if (pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF)) {
printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
kfree(map); kfree(map);
return (ENODEV); return (ENODEV);
...@@ -1414,22 +1383,12 @@ ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr, ...@@ -1414,22 +1383,12 @@ ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr,
*vaddr = pci_alloc_consistent(ahc->dev_softc, *vaddr = pci_alloc_consistent(ahc->dev_softc,
dmat->maxsize, &map->bus_addr); dmat->maxsize, &map->bus_addr);
if (ahc->dev_softc != NULL) if (ahc->dev_softc != NULL)
if (ahc_pci_set_dma_mask(ahc->dev_softc, if (pci_set_dma_mask(ahc->dev_softc,
ahc->platform_data->hw_dma_mask)) { ahc->platform_data->hw_dma_mask)) {
printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
kfree(map); kfree(map);
return (ENODEV); return (ENODEV);
} }
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
/*
* At least in 2.2.14, malloc is a slab allocator so all
* allocations are aligned. We assume for these kernel versions
* that all allocations will be bellow 4Gig, physically contiguous,
* and accessible via DMA by the controller.
*/
map = NULL; /* No additional information to store */
*vaddr = malloc(dmat->maxsize, M_DEVBUF, M_NOWAIT);
#endif
if (*vaddr == NULL) if (*vaddr == NULL)
return (ENOMEM); return (ENOMEM);
*mapp = map; *mapp = map;
...@@ -1440,12 +1399,8 @@ void ...@@ -1440,12 +1399,8 @@ void
ahc_dmamem_free(struct ahc_softc *ahc, bus_dma_tag_t dmat, ahc_dmamem_free(struct ahc_softc *ahc, bus_dma_tag_t dmat,
void* vaddr, bus_dmamap_t map) void* vaddr, bus_dmamap_t map)
{ {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
pci_free_consistent(ahc->dev_softc, dmat->maxsize, pci_free_consistent(ahc->dev_softc, dmat->maxsize,
vaddr, map->bus_addr); vaddr, map->bus_addr);
#else
free(vaddr, M_DEVBUF);
#endif
} }
int int
...@@ -1459,12 +1414,7 @@ ahc_dmamap_load(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map, ...@@ -1459,12 +1414,7 @@ ahc_dmamap_load(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map,
*/ */
bus_dma_segment_t stack_sg; bus_dma_segment_t stack_sg;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
stack_sg.ds_addr = map->bus_addr; stack_sg.ds_addr = map->bus_addr;
#else
#define VIRT_TO_BUS(a) (uint32_t)virt_to_bus((void *)(a))
stack_sg.ds_addr = VIRT_TO_BUS(buf);
#endif
stack_sg.ds_len = dmat->maxsize; stack_sg.ds_len = dmat->maxsize;
cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0); cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0);
return (0); return (0);
...@@ -1475,8 +1425,9 @@ ahc_dmamap_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map) ...@@ -1475,8 +1425,9 @@ ahc_dmamap_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map)
{ {
/* /*
* The map may is NULL in our < 2.3.X implementation. * The map may is NULL in our < 2.3.X implementation.
* Now it's 2.6.5, but just in case...
*/ */
if (map != NULL) BUG_ON(map == NULL);
free(map, M_DEVBUF); free(map, M_DEVBUF);
} }
...@@ -1693,9 +1644,7 @@ aic7xxx_setup(char *s) ...@@ -1693,9 +1644,7 @@ aic7xxx_setup(char *s)
return 1; return 1;
} }
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0)
__setup("aic7xxx=", aic7xxx_setup); __setup("aic7xxx=", aic7xxx_setup);
#endif
uint32_t aic7xxx_verbose; uint32_t aic7xxx_verbose;
...@@ -1738,8 +1687,7 @@ ahc_linux_register_host(struct ahc_softc *ahc, Scsi_Host_Template *template) ...@@ -1738,8 +1687,7 @@ ahc_linux_register_host(struct ahc_softc *ahc, Scsi_Host_Template *template)
ahc_set_name(ahc, new_name); ahc_set_name(ahc, new_name);
} }
host->unique_id = ahc->unit; host->unique_id = ahc->unit;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4) && \ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
scsi_set_pci_device(host, ahc->dev_softc); scsi_set_pci_device(host, ahc->dev_softc);
#endif #endif
ahc_linux_initialize_scsi_bus(ahc); ahc_linux_initialize_scsi_bus(ahc);
...@@ -1925,19 +1873,11 @@ ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg) ...@@ -1925,19 +1873,11 @@ ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg)
ahc->platform_data->completeq_timer.data = (u_long)ahc; ahc->platform_data->completeq_timer.data = (u_long)ahc;
ahc->platform_data->completeq_timer.function = ahc->platform_data->completeq_timer.function =
(ahc_linux_callback_t *)ahc_linux_thread_run_complete_queue; (ahc_linux_callback_t *)ahc_linux_thread_run_complete_queue;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
init_MUTEX_LOCKED(&ahc->platform_data->eh_sem); init_MUTEX_LOCKED(&ahc->platform_data->eh_sem);
init_MUTEX_LOCKED(&ahc->platform_data->dv_sem); init_MUTEX_LOCKED(&ahc->platform_data->dv_sem);
init_MUTEX_LOCKED(&ahc->platform_data->dv_cmd_sem); init_MUTEX_LOCKED(&ahc->platform_data->dv_cmd_sem);
#else
ahc->platform_data->eh_sem = MUTEX_LOCKED;
ahc->platform_data->dv_sem = MUTEX_LOCKED;
ahc->platform_data->dv_cmd_sem = MUTEX_LOCKED;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
tasklet_init(&ahc->platform_data->runq_tasklet, ahc_runq_tasklet, tasklet_init(&ahc->platform_data->runq_tasklet, ahc_runq_tasklet,
(unsigned long)ahc); (unsigned long)ahc);
#endif
ahc->seltime = (aic7xxx_seltime & 0x3) << 4; ahc->seltime = (aic7xxx_seltime & 0x3) << 4;
ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4; ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4;
if (aic7xxx_pci_parity == 0) if (aic7xxx_pci_parity == 0)
...@@ -1956,9 +1896,7 @@ ahc_platform_free(struct ahc_softc *ahc) ...@@ -1956,9 +1896,7 @@ ahc_platform_free(struct ahc_softc *ahc)
if (ahc->platform_data != NULL) { if (ahc->platform_data != NULL) {
del_timer_sync(&ahc->platform_data->completeq_timer); del_timer_sync(&ahc->platform_data->completeq_timer);
ahc_linux_kill_dv_thread(ahc); ahc_linux_kill_dv_thread(ahc);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
tasklet_kill(&ahc->platform_data->runq_tasklet); tasklet_kill(&ahc->platform_data->runq_tasklet);
#endif
if (ahc->platform_data->host != NULL) { if (ahc->platform_data->host != NULL) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
scsi_remove_host(ahc->platform_data->host); scsi_remove_host(ahc->platform_data->host);
...@@ -1999,13 +1937,10 @@ ahc_platform_free(struct ahc_softc *ahc) ...@@ -1999,13 +1937,10 @@ ahc_platform_free(struct ahc_softc *ahc)
base_addr = (u_long)ahc->bsh.maddr; base_addr = (u_long)ahc->bsh.maddr;
base_addr &= PAGE_MASK; base_addr &= PAGE_MASK;
iounmap((void *)base_addr); iounmap((void *)base_addr);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
release_mem_region(ahc->platform_data->mem_busaddr, release_mem_region(ahc->platform_data->mem_busaddr,
0x1000); 0x1000);
#endif
} }
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) && \ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
/* /*
* In 2.4 we detach from the scsi midlayer before the PCI * In 2.4 we detach from the scsi midlayer before the PCI
* layer invokes our remove callback. No per-instance * layer invokes our remove callback. No per-instance
...@@ -3751,7 +3686,7 @@ ahc_linux_run_device_queue(struct ahc_softc *ahc, struct ahc_linux_device *dev) ...@@ -3751,7 +3686,7 @@ ahc_linux_run_device_queue(struct ahc_softc *ahc, struct ahc_linux_device *dev)
* a transfer crosses a 32bit page. * a transfer crosses a 32bit page.
*/ */
while (cur_seg < end_seg) { while (cur_seg < end_seg) {
bus_addr_t addr; dma_addr_t addr;
bus_size_t len; bus_size_t len;
int consumed; int consumed;
...@@ -3780,7 +3715,7 @@ ahc_linux_run_device_queue(struct ahc_softc *ahc, struct ahc_linux_device *dev) ...@@ -3780,7 +3715,7 @@ ahc_linux_run_device_queue(struct ahc_softc *ahc, struct ahc_linux_device *dev)
scb->hscb->datacnt = scb->sg_list->len; scb->hscb->datacnt = scb->sg_list->len;
} else if (cmd->request_bufflen != 0) { } else if (cmd->request_bufflen != 0) {
struct ahc_dma_seg *sg; struct ahc_dma_seg *sg;
bus_addr_t addr; dma_addr_t addr;
sg = scb->sg_list; sg = scb->sg_list;
addr = pci_map_single(ahc->dev_softc, addr = pci_map_single(ahc->dev_softc,
...@@ -4064,7 +3999,7 @@ ahc_send_async(struct ahc_softc *ahc, char channel, ...@@ -4064,7 +3999,7 @@ ahc_send_async(struct ahc_softc *ahc, char channel,
WARN_ON(lun != CAM_LUN_WILDCARD); WARN_ON(lun != CAM_LUN_WILDCARD);
scsi_report_device_reset(ahc->platform_data->host, scsi_report_device_reset(ahc->platform_data->host,
channel - 'A', target); channel - 'A', target);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0) #else
Scsi_Device *scsi_dev; Scsi_Device *scsi_dev;
/* /*
...@@ -4085,12 +4020,10 @@ ahc_send_async(struct ahc_softc *ahc, char channel, ...@@ -4085,12 +4020,10 @@ ahc_send_async(struct ahc_softc *ahc, char channel,
break; break;
} }
case AC_BUS_RESET: case AC_BUS_RESET:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
if (ahc->platform_data->host != NULL) { if (ahc->platform_data->host != NULL) {
scsi_report_bus_reset(ahc->platform_data->host, scsi_report_bus_reset(ahc->platform_data->host,
channel - 'A'); channel - 'A');
} }
#endif
break; break;
default: default:
panic("ahc_send_async: Unexpected async event"); panic("ahc_send_async: Unexpected async event");
......
...@@ -70,17 +70,9 @@ ...@@ -70,17 +70,9 @@
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <asm/io.h> #include <asm/io.h>
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
#include <linux/interrupt.h> /* For tasklet support. */ #include <linux/interrupt.h> /* For tasklet support. */
#include <linux/config.h> #include <linux/config.h>
#include <linux/slab.h> #include <linux/slab.h>
#else
#include <linux/malloc.h>
#endif
/* Core SCSI definitions */ /* Core SCSI definitions */
#define AIC_LIB_PREFIX ahc #define AIC_LIB_PREFIX ahc
...@@ -156,11 +148,6 @@ extern Scsi_Host_Template aic7xxx_driver_template; ...@@ -156,11 +148,6 @@ extern Scsi_Host_Template aic7xxx_driver_template;
/***************************** Bus Space/DMA **********************************/ /***************************** Bus Space/DMA **********************************/
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,2,17)
typedef dma_addr_t bus_addr_t;
#else
typedef uint32_t bus_addr_t;
#endif
typedef uint32_t bus_size_t; typedef uint32_t bus_size_t;
typedef enum { typedef enum {
...@@ -175,7 +162,7 @@ typedef union { ...@@ -175,7 +162,7 @@ typedef union {
typedef struct bus_dma_segment typedef struct bus_dma_segment
{ {
bus_addr_t ds_addr; dma_addr_t ds_addr;
bus_size_t ds_len; bus_size_t ds_len;
} bus_dma_segment_t; } bus_dma_segment_t;
...@@ -189,11 +176,11 @@ typedef struct ahc_linux_dma_tag* bus_dma_tag_t; ...@@ -189,11 +176,11 @@ typedef struct ahc_linux_dma_tag* bus_dma_tag_t;
struct ahc_linux_dmamap struct ahc_linux_dmamap
{ {
bus_addr_t bus_addr; dma_addr_t bus_addr;
}; };
typedef struct ahc_linux_dmamap* bus_dmamap_t; typedef struct ahc_linux_dmamap* bus_dmamap_t;
typedef int bus_dma_filter_t(void*, bus_addr_t); typedef int bus_dma_filter_t(void*, dma_addr_t);
typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
#define BUS_DMA_WAITOK 0x0 #define BUS_DMA_WAITOK 0x0
...@@ -210,7 +197,7 @@ typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); ...@@ -210,7 +197,7 @@ typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
int ahc_dma_tag_create(struct ahc_softc *, bus_dma_tag_t /*parent*/, int ahc_dma_tag_create(struct ahc_softc *, bus_dma_tag_t /*parent*/,
bus_size_t /*alignment*/, bus_size_t /*boundary*/, bus_size_t /*alignment*/, bus_size_t /*boundary*/,
bus_addr_t /*lowaddr*/, bus_addr_t /*highaddr*/, dma_addr_t /*lowaddr*/, dma_addr_t /*highaddr*/,
bus_dma_filter_t*/*filter*/, void */*filterarg*/, bus_dma_filter_t*/*filter*/, void */*filterarg*/,
bus_size_t /*maxsize*/, int /*nsegments*/, bus_size_t /*maxsize*/, int /*nsegments*/,
bus_size_t /*maxsegsz*/, int /*flags*/, bus_size_t /*maxsegsz*/, int /*flags*/,
...@@ -292,11 +279,7 @@ ahc_scb_timer_reset(struct scb *scb, u_int usec) ...@@ -292,11 +279,7 @@ ahc_scb_timer_reset(struct scb *scb, u_int usec)
} }
/***************************** SMP support ************************************/ /***************************** SMP support ************************************/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,17)
#include <linux/spinlock.h> #include <linux/spinlock.h>
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
#include <linux/smp.h>
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) || defined(SCSI_HAS_HOST_LOCK)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) || defined(SCSI_HAS_HOST_LOCK))
#define AHC_SCSI_HAS_HOST_LOCK 1 #define AHC_SCSI_HAS_HOST_LOCK 1
...@@ -515,11 +498,8 @@ typedef enum { ...@@ -515,11 +498,8 @@ typedef enum {
struct scb_platform_data { struct scb_platform_data {
struct ahc_linux_device *dev; struct ahc_linux_device *dev;
bus_addr_t buf_busaddr; dma_addr_t buf_busaddr;
uint32_t xfer_len; uint32_t xfer_len;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
uint32_t resid; /* Transfer residual */
#endif
uint32_t sense_resid; /* Auto-Sense residual */ uint32_t sense_resid; /* Auto-Sense residual */
ahc_linux_scb_flags flags; ahc_linux_scb_flags flags;
}; };
...@@ -549,9 +529,7 @@ struct ahc_platform_data { ...@@ -549,9 +529,7 @@ struct ahc_platform_data {
struct ahc_completeq completeq; struct ahc_completeq completeq;
spinlock_t spin_lock; spinlock_t spin_lock;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
struct tasklet_struct runq_tasklet; struct tasklet_struct runq_tasklet;
#endif
u_int qfrozen; u_int qfrozen;
pid_t dv_pid; pid_t dv_pid;
struct timer_list completeq_timer; struct timer_list completeq_timer;
...@@ -567,7 +545,7 @@ struct ahc_platform_data { ...@@ -567,7 +545,7 @@ struct ahc_platform_data {
uint32_t irq; /* IRQ for this adapter */ uint32_t irq; /* IRQ for this adapter */
uint32_t bios_address; uint32_t bios_address;
uint32_t mem_busaddr; /* Mem Base Addr */ uint32_t mem_busaddr; /* Mem Base Addr */
bus_addr_t hw_dma_mask; dma_addr_t hw_dma_mask;
ahc_linux_softc_flags flags; ahc_linux_softc_flags flags;
}; };
...@@ -819,9 +797,7 @@ ahc_list_unlock(unsigned long *flags) ...@@ -819,9 +797,7 @@ ahc_list_unlock(unsigned long *flags)
#define PCIR_SUBVEND_0 0x2c #define PCIR_SUBVEND_0 0x2c
#define PCIR_SUBDEV_0 0x2e #define PCIR_SUBDEV_0 0x2e
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
extern struct pci_driver aic7xxx_pci_driver; extern struct pci_driver aic7xxx_pci_driver;
#endif
typedef enum typedef enum
{ {
...@@ -954,25 +930,6 @@ ahc_flush_device_writes(struct ahc_softc *ahc) ...@@ -954,25 +930,6 @@ ahc_flush_device_writes(struct ahc_softc *ahc)
ahc_inb(ahc, INTSTAT); ahc_inb(ahc, INTSTAT);
} }
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0)
#define pci_map_sg(pdev, sg_list, nseg, direction) (nseg)
#define pci_unmap_sg(pdev, sg_list, nseg, direction)
#define sg_dma_address(sg) (VIRT_TO_BUS((sg)->address))
#define sg_dma_len(sg) ((sg)->length)
#define pci_map_single(pdev, buffer, bufflen, direction) \
(VIRT_TO_BUS(buffer))
#define pci_unmap_single(pdev, buffer, buflen, direction)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,3)
#define ahc_pci_set_dma_mask pci_set_dma_mask
#else
/*
* Always "return" 0 for success.
*/
#define ahc_pci_set_dma_mask(dev_softc, mask) \
(((dev_softc)->dma_mask = mask) && 0)
#endif
/**************************** Proc FS Support *********************************/ /**************************** Proc FS Support *********************************/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
int ahc_linux_proc_info(char *, char **, off_t, int, int, int); int ahc_linux_proc_info(char *, char **, off_t, int, int, int);
...@@ -1080,35 +1037,13 @@ u_long ahc_get_transfer_length(struct scb *scb) ...@@ -1080,35 +1037,13 @@ u_long ahc_get_transfer_length(struct scb *scb)
static __inline static __inline
int ahc_get_transfer_dir(struct scb *scb) int ahc_get_transfer_dir(struct scb *scb)
{ {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,40)
return (scb->io_ctx->sc_data_direction); return (scb->io_ctx->sc_data_direction);
#else
if (scb->io_ctx->bufflen == 0)
return (CAM_DIR_NONE);
switch(scb->io_ctx->cmnd[0]) {
case 0x08: /* READ(6) */
case 0x28: /* READ(10) */
case 0xA8: /* READ(12) */
return (CAM_DIR_IN);
case 0x0A: /* WRITE(6) */
case 0x2A: /* WRITE(10) */
case 0xAA: /* WRITE(12) */
return (CAM_DIR_OUT);
default:
return (CAM_DIR_NONE);
}
#endif
} }
static __inline static __inline
void ahc_set_residual(struct scb *scb, u_long resid) void ahc_set_residual(struct scb *scb, u_long resid)
{ {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
scb->io_ctx->resid = resid; scb->io_ctx->resid = resid;
#else
scb->platform_data->resid = resid;
#endif
} }
static __inline static __inline
...@@ -1120,11 +1055,7 @@ void ahc_set_sense_residual(struct scb *scb, u_long resid) ...@@ -1120,11 +1055,7 @@ void ahc_set_sense_residual(struct scb *scb, u_long resid)
static __inline static __inline
u_long ahc_get_residual(struct scb *scb) u_long ahc_get_residual(struct scb *scb)
{ {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
return (scb->io_ctx->resid); return (scb->io_ctx->resid);
#else
return (scb->platform_data->resid);
#endif
} }
static __inline static __inline
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment