mm: thp: set the accessed flag for old pages on access fault
[pandora-kernel.git] / drivers / scsi / scsi_sysfs.c
index bb7c482..72ca515 100644 (file)
@@ -246,11 +246,11 @@ show_shost_active_mode(struct device *dev,
 
 static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL);
 
-static int check_reset_type(char *str)
+static int check_reset_type(const char *str)
 {
-       if (strncmp(str, "adapter", 10) == 0)
+       if (sysfs_streq(str, "adapter"))
                return SCSI_ADAPTER_RESET;
-       else if (strncmp(str, "firmware", 10) == 0)
+       else if (sysfs_streq(str, "firmware"))
                return SCSI_FIRMWARE_RESET;
        else
                return 0;
@@ -263,12 +263,9 @@ store_host_reset(struct device *dev, struct device_attribute *attr,
        struct Scsi_Host *shost = class_to_shost(dev);
        struct scsi_host_template *sht = shost->hostt;
        int ret = -EINVAL;
-       char str[10];
        int type;
 
-       sscanf(buf, "%s", str);
-       type = check_reset_type(str);
-
+       type = check_reset_type(buf);
        if (!type)
                goto exit_store_host_reset;
 
@@ -1023,33 +1020,31 @@ static void __scsi_remove_target(struct scsi_target *starget)
 void scsi_remove_target(struct device *dev)
 {
        struct Scsi_Host *shost = dev_to_shost(dev->parent);
-       struct scsi_target *starget, *found;
+       struct scsi_target *starget, *last = NULL;
        unsigned long flags;
 
- restart:
-       found = NULL;
+       /* remove targets being careful to lookup next entry before
+        * deleting the last
+        */
        spin_lock_irqsave(shost->host_lock, flags);
        list_for_each_entry(starget, &shost->__targets, siblings) {
                if (starget->state == STARGET_DEL)
                        continue;
                if (starget->dev.parent == dev || &starget->dev == dev) {
-                       found = starget;
-                       found->reap_ref++;
-                       break;
+                       /* assuming new targets arrive at the end */
+                       starget->reap_ref++;
+                       spin_unlock_irqrestore(shost->host_lock, flags);
+                       if (last)
+                               scsi_target_reap(last);
+                       last = starget;
+                       __scsi_remove_target(starget);
+                       spin_lock_irqsave(shost->host_lock, flags);
                }
        }
        spin_unlock_irqrestore(shost->host_lock, flags);
 
-       if (found) {
-               __scsi_remove_target(found);
-               scsi_target_reap(found);
-               /* in the case where @dev has multiple starget children,
-                * continue removing.
-                *
-                * FIXME: does such a case exist?
-                */
-               goto restart;
-       }
+       if (last)
+               scsi_target_reap(last);
 }
 EXPORT_SYMBOL(scsi_remove_target);