[SCSI] drivers/scsi: Use ARRAY_SIZE macro
[safe/jmp/linux-2.6] / drivers / scsi / g_NCR5380.c
index 45756fa..5f313c9 100644 (file)
@@ -127,7 +127,7 @@ static int ncr_53c400a = NCR_NOT_SET;
 static int dtc_3181e = NCR_NOT_SET;
 
 static struct override {
-       NCR5380_implementation_fields;
+       NCR5380_map_type NCR5380_map_name;
        int irq;
        int dma;
        int board;              /* Use NCR53c400, Ricoh, etc. extensions ? */
@@ -138,10 +138,9 @@ static struct override {
 [1] __initdata = { { 0,},};
 #endif
 
+#define NO_OVERRIDES ARRAY_SIZE(overrides)
 
-#define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override))
-
-#ifndef MODULE 
+#ifndef MODULE
 
 /**
  *     internal_setup          -       handle lilo command string override
@@ -210,7 +209,7 @@ static int __init do_NCR5380_setup(char *str)
 {
        int ints[10];
 
-       get_options(str, sizeof(ints) / sizeof(int), ints);
+       get_options(str, ARRAY_SIZE(ints), ints);
        internal_setup(BOARD_NCR5380, str, ints);
        return 1;
 }
@@ -218,7 +217,7 @@ static int __init do_NCR5380_setup(char *str)
 /**
  *     do_NCR53C400_setup              -       set up entry point
  *     @str: unused
- *     @ints: integer parameters from kernel setup code 
+ *     @ints: integer parameters from kernel setup code
  *
  *     Setup function invoked at boot to parse the ncr53c400= command
  *     line.
@@ -228,7 +227,7 @@ static int __init do_NCR53C400_setup(char *str)
 {
        int ints[10];
 
-       get_options(str, sizeof(ints) / sizeof(int), ints);
+       get_options(str, ARRAY_SIZE(ints), ints);
        internal_setup(BOARD_NCR53C400, str, ints);
        return 1;
 }
@@ -236,7 +235,7 @@ static int __init do_NCR53C400_setup(char *str)
 /**
  *     do_NCR53C400A_setup     -       set up entry point
  *     @str: unused
- *     @ints: integer parameters from kernel setup code 
+ *     @ints: integer parameters from kernel setup code
  *
  *     Setup function invoked at boot to parse the ncr53c400a= command
  *     line.
@@ -246,7 +245,7 @@ static int __init do_NCR53C400A_setup(char *str)
 {
        int ints[10];
 
-       get_options(str, sizeof(ints) / sizeof(int), ints);
+       get_options(str, ARRAY_SIZE(ints), ints);
        internal_setup(BOARD_NCR53C400A, str, ints);
        return 1;
 }
@@ -254,7 +253,7 @@ static int __init do_NCR53C400A_setup(char *str)
 /**
  *     do_DTC3181E_setup       -       set up entry point
  *     @str: unused
- *     @ints: integer parameters from kernel setup code 
+ *     @ints: integer parameters from kernel setup code
  *
  *     Setup function invoked at boot to parse the dtc3181e= command
  *     line.
@@ -264,7 +263,7 @@ static int __init do_DTC3181E_setup(char *str)
 {
        int ints[10];
 
-       get_options(str, sizeof(ints) / sizeof(int), ints);
+       get_options(str, ARRAY_SIZE(ints), ints);
        internal_setup(BOARD_DTC3181E, str, ints);
        return 1;
 }
@@ -299,6 +298,10 @@ int __init generic_NCR5380_detect(struct scsi_host_template * tpnt)
        };
        int flags = 0;
        struct Scsi_Host *instance;
+#ifdef CONFIG_SCSI_G_NCR5380_MEM
+       unsigned long base;
+       void __iomem *iomem;
+#endif
 
        if (ncr_irq != NCR_NOT_SET)
                overrides[0].irq = ncr_irq;
@@ -424,15 +427,22 @@ int __init generic_NCR5380_detect(struct scsi_host_template * tpnt)
                        region_size = NCR5380_region_size;
                }
 #else
-               if(!request_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size, "ncr5380"))
+               base = overrides[current_override].NCR5380_map_name;
+               if (!request_mem_region(base, NCR5380_region_size, "ncr5380"))
+                       continue;
+               iomem = ioremap(base, NCR5380_region_size);
+               if (!iomem) {
+                       release_mem_region(base, NCR5380_region_size);
                        continue;
+               }
 #endif
                instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata));
                if (instance == NULL) {
 #ifndef CONFIG_SCSI_G_NCR5380_MEM
                        release_region(overrides[current_override].NCR5380_map_name, region_size);
 #else
-                       release_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size);
+                       iounmap(iomem);
+                       release_mem_region(base, NCR5380_region_size);
 #endif
                        continue;
                }
@@ -440,6 +450,8 @@ int __init generic_NCR5380_detect(struct scsi_host_template * tpnt)
                instance->NCR5380_instance_name = overrides[current_override].NCR5380_map_name;
 #ifndef CONFIG_SCSI_G_NCR5380_MEM
                instance->n_io_port = region_size;
+#else
+               ((struct NCR5380_hostdata *)instance->hostdata).iomem = iomem;
 #endif
 
                NCR5380_init(instance, flags);
@@ -509,6 +521,7 @@ int generic_NCR5380_release_resources(struct Scsi_Host *instance)
 #ifndef CONFIG_SCSI_G_NCR5380_MEM
        release_region(instance->NCR5380_instance_name, instance->n_io_port);
 #else
+       iounmap(((struct NCR5380_hostdata *)instance->hostdata).iomem);
        release_mem_region(instance->NCR5380_instance_name, NCR5380_region_size);
 #endif
 
@@ -586,7 +599,7 @@ static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst,
                }
 #else
                /* implies CONFIG_SCSI_G_NCR5380_MEM */
-               isa_memcpy_fromio(dst + start, NCR53C400_host_buffer + NCR5380_map_name, 128);
+               memcpy_fromio(dst + start, iomem + NCR53C400_host_buffer, 128);
 #endif
                start += 128;
                blocks--;
@@ -606,7 +619,7 @@ static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst,
                }
 #else
                /* implies CONFIG_SCSI_G_NCR5380_MEM */
-               isa_memcpy_fromio(dst + start, NCR53C400_host_buffer + NCR5380_map_name, 128);
+               memcpy_fromio(dst + start, iomem + NCR53C400_host_buffer, 128);
 #endif
                start += 128;
                blocks--;
@@ -671,7 +684,7 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src,
                }
 #else
                /* implies CONFIG_SCSI_G_NCR5380_MEM */
-               isa_memcpy_toio(NCR53C400_host_buffer + NCR5380_map_name, src + start, 128);
+               memcpy_toio(iomem + NCR53C400_host_buffer, src + start, 128);
 #endif
                start += 128;
                blocks--;
@@ -687,7 +700,7 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src,
                }
 #else
                /* implies CONFIG_SCSI_G_NCR5380_MEM */
-               isa_memcpy_toio(NCR53C400_host_buffer + NCR5380_map_name, src + start, 128);
+               memcpy_toio(iomem + NCR53C400_host_buffer, src + start, 128);
 #endif
                start += 128;
                blocks--;