[SCSI] drivers/scsi: Use ARRAY_SIZE macro
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / scsi / aic7xxx / aic79xx_osm.c
index bcced0a417e690967c0630b01b5c997e08e46106..e0ccdf362200613416dbe2e89a354edff4684f8b 100644 (file)
@@ -782,6 +782,7 @@ ahd_linux_bus_reset(struct scsi_cmnd *cmd)
 {
        struct ahd_softc *ahd;
        int    found;
+       unsigned long flags;
 
        ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
 #ifdef AHD_DEBUG
@@ -789,8 +790,11 @@ ahd_linux_bus_reset(struct scsi_cmnd *cmd)
                printf("%s: Bus reset called for cmd %p\n",
                       ahd_name(ahd), cmd);
 #endif
+       ahd_lock(ahd, &flags);
+
        found = ahd_reset_channel(ahd, scmd_channel(cmd) + 'A',
                                  /*initiate reset*/TRUE);
+       ahd_unlock(ahd, &flags);
 
        if (bootverbose)
                printf("%s: SCSI bus reset delivered. "
@@ -912,7 +916,7 @@ ahd_linux_setup_iocell_info(u_long index, int instance, int targ, int32_t value)
 {
 
        if ((instance >= 0)
-        && (instance < NUM_ELEMENTS(aic79xx_iocell_info))) {
+        && (instance < ARRAY_SIZE(aic79xx_iocell_info))) {
                uint8_t *iocell_info;
 
                iocell_info = (uint8_t*)&aic79xx_iocell_info[instance];
@@ -930,7 +934,7 @@ ahd_linux_setup_tag_info_global(char *p)
        tags = simple_strtoul(p + 1, NULL, 0) & 0xff;
        printf("Setting Global Tags= %d\n", tags);
 
-       for (i = 0; i < NUM_ELEMENTS(aic79xx_tag_info); i++) {
+       for (i = 0; i < ARRAY_SIZE(aic79xx_tag_info); i++) {
                for (j = 0; j < AHD_NUM_TARGETS; j++) {
                        aic79xx_tag_info[i].tag_commands[j] = tags;
                }
@@ -942,7 +946,7 @@ ahd_linux_setup_tag_info(u_long arg, int instance, int targ, int32_t value)
 {
 
        if ((instance >= 0) && (targ >= 0)
-        && (instance < NUM_ELEMENTS(aic79xx_tag_info))
+        && (instance < ARRAY_SIZE(aic79xx_tag_info))
         && (targ < AHD_NUM_TARGETS)) {
                aic79xx_tag_info[instance].tag_commands[targ] = value & 0x1FF;
                if (bootverbose)
@@ -1068,21 +1072,21 @@ aic79xx_setup(char *s)
        end = strchr(s, '\0');
 
        /*
-        * XXX ia64 gcc isn't smart enough to know that NUM_ELEMENTS
+        * XXX ia64 gcc isn't smart enough to know that ARRAY_SIZE
         * will never be 0 in this case.
-        */      
-       n = 0;  
+        */
+       n = 0;
 
        while ((p = strsep(&s, ",.")) != NULL) {
                if (*p == '\0')
                        continue;
-               for (i = 0; i < NUM_ELEMENTS(options); i++) {
+               for (i = 0; i < ARRAY_SIZE(options); i++) {
 
                        n = strlen(options[i].name);
                        if (strncmp(options[i].name, p, n) == 0)
                                break;
                }
-               if (i == NUM_ELEMENTS(options))
+               if (i == ARRAY_SIZE(options))
                        continue;
 
                if (strncmp(p, "global_tag_depth", n) == 0) {
@@ -1290,7 +1294,7 @@ ahd_platform_init(struct ahd_softc *ahd)
        /*
         * Lookup and commit any modified IO Cell options.
         */
-       if (ahd->unit < NUM_ELEMENTS(aic79xx_iocell_info)) {
+       if (ahd->unit < ARRAY_SIZE(aic79xx_iocell_info)) {
                struct ahd_linux_iocell_opts *iocell_opts;
 
                iocell_opts = &aic79xx_iocell_info[ahd->unit];
@@ -1422,7 +1426,7 @@ ahd_linux_user_tagdepth(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
 
        tags = 0;
        if ((ahd->user_discenable & devinfo->target_mask) != 0) {
-               if (ahd->unit >= NUM_ELEMENTS(aic79xx_tag_info)) {
+               if (ahd->unit >= ARRAY_SIZE(aic79xx_tag_info)) {
 
                        if (warned_user == 0) {
                                printf(KERN_WARNING