}
 
 
-/**
- * scsi_ioctl - Dispatch ioctl to scsi device
- * @sdev: scsi device receiving ioctl
- * @cmd: which ioctl is it
- * @arg: data associated with ioctl
- *
- * Description: The scsi_ioctl() function differs from most ioctls in that it
- * does not take a major/minor number as the dev field.  Rather, it takes
- * a pointer to a &struct scsi_device.
- */
-int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
+static int scsi_ioctl_common(struct scsi_device *sdev, int cmd, void __user *arg)
 {
        char scsi_cmd[MAX_COMMAND_SIZE];
        struct scsi_sense_hdr sense_hdr;
                 return scsi_ioctl_get_pci(sdev, arg);
        case SG_SCSI_RESET:
                return scsi_ioctl_reset(sdev, arg);
-       default:
-               if (sdev->host->hostt->ioctl)
-                       return sdev->host->hostt->ioctl(sdev, cmd, arg);
        }
+       return -ENOIOCTLCMD;
+}
+
+/**
+ * scsi_ioctl - Dispatch ioctl to scsi device
+ * @sdev: scsi device receiving ioctl
+ * @cmd: which ioctl is it
+ * @arg: data associated with ioctl
+ *
+ * Description: The scsi_ioctl() function differs from most ioctls in that it
+ * does not take a major/minor number as the dev field.  Rather, it takes
+ * a pointer to a &struct scsi_device.
+ */
+int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
+{
+       int ret = scsi_ioctl_common(sdev, cmd, arg);
+
+       if (ret != -ENOIOCTLCMD)
+               return ret;
+
+       if (sdev->host->hostt->ioctl)
+               return sdev->host->hostt->ioctl(sdev, cmd, arg);
+
        return -EINVAL;
 }
 EXPORT_SYMBOL(scsi_ioctl);
 
+#ifdef CONFIG_COMPAT
+int scsi_compat_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
+{
+       int ret = scsi_ioctl_common(sdev, cmd, arg);
+
+       if (ret != -ENOIOCTLCMD)
+               return ret;
+
+       if (sdev->host->hostt->compat_ioctl)
+               return sdev->host->hostt->compat_ioctl(sdev, cmd, arg);
+
+       return ret;
+}
+EXPORT_SYMBOL(scsi_compat_ioctl);
+#endif
+
 /*
  * We can process a reset even when a device isn't fully operable.
  */