]> git.karo-electronics.de Git - linux-beck.git/blobdiff - drivers/scsi/sd.c
Merge branch 'drm-intel-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/ickle...
[linux-beck.git] / drivers / scsi / sd.c
index 57d1e3e1bd4478548f89ef9f3a472ee4418c71b3..956496182c805d8dd7f0aa58cc3ddb7c12c91b8b 100644 (file)
@@ -46,7 +46,6 @@
 #include <linux/blkdev.h>
 #include <linux/blkpg.h>
 #include <linux/delay.h>
-#include <linux/smp_lock.h>
 #include <linux/mutex.h>
 #include <linux/string_helpers.h>
 #include <linux/async.h>
@@ -258,6 +257,28 @@ sd_show_protection_type(struct device *dev, struct device_attribute *attr,
        return snprintf(buf, 20, "%u\n", sdkp->protection_type);
 }
 
+static ssize_t
+sd_show_protection_mode(struct device *dev, struct device_attribute *attr,
+                       char *buf)
+{
+       struct scsi_disk *sdkp = to_scsi_disk(dev);
+       struct scsi_device *sdp = sdkp->device;
+       unsigned int dif, dix;
+
+       dif = scsi_host_dif_capable(sdp->host, sdkp->protection_type);
+       dix = scsi_host_dix_capable(sdp->host, sdkp->protection_type);
+
+       if (!dix && scsi_host_dix_capable(sdp->host, SD_DIF_TYPE0_PROTECTION)) {
+               dif = 0;
+               dix = 1;
+       }
+
+       if (!dif && !dix)
+               return snprintf(buf, 20, "none\n");
+
+       return snprintf(buf, 20, "%s%u\n", dix ? "dix" : "dif", dif);
+}
+
 static ssize_t
 sd_show_app_tag_own(struct device *dev, struct device_attribute *attr,
                    char *buf)
@@ -285,6 +306,7 @@ static struct device_attribute sd_disk_attrs[] = {
        __ATTR(manage_start_stop, S_IRUGO|S_IWUSR, sd_show_manage_start_stop,
               sd_store_manage_start_stop),
        __ATTR(protection_type, S_IRUGO, sd_show_protection_type, NULL),
+       __ATTR(protection_mode, S_IRUGO, sd_show_protection_mode, NULL),
        __ATTR(app_tag_own, S_IRUGO, sd_show_app_tag_own, NULL),
        __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL),
        __ATTR_NULL,