}
  
  #define BSG_DEFAULT_CMDS      64
- #define BSG_MAX_DEVS          32768
+ #define BSG_MAX_DEVS          (1 << MINORBITS)
  
  static DEFINE_IDA(bsg_minor_ida);
 -static struct class *bsg_class;
 +static const struct class bsg_class;
  static int bsg_major;
  
  static unsigned int bsg_timeout(struct bsg_device *bd, struct sg_io_v4 *hdr)
 
                         * generate sense data in this function,
                         * considering both err_mask and tf.
                         */
 -                      if (qc->flags & ATA_QCFLAG_RETRY)
 +                      if (qc->flags & ATA_QCFLAG_RETRY) {
 +                              /*
 +                               * Since qc->err_mask is set, ata_eh_qc_retry()
 +                               * will not increment scmd->allowed, so upper
 +                               * layer will only retry the command if it has
 +                               * not already been retried too many times.
 +                               */
                                ata_eh_qc_retry(qc);
 -                      else
 +                      } else {
                                ata_eh_qc_complete(qc);
 +                      }
                } else {
-                       if (qc->flags & ATA_QCFLAG_SENSE_VALID) {
+                       if (qc->flags & ATA_QCFLAG_SENSE_VALID ||
+                           qc->flags & ATA_QCFLAG_EH_SUCCESS_CMD) {
                                ata_eh_qc_complete(qc);
                        } else {
                                /* feed zero TF to sense generation */
 
  obj-$(CONFIG_NVME_TCP)                        += nvme-tcp.o
  obj-$(CONFIG_NVME_APPLE)              += nvme-apple.o
  
- nvme-core-y                           += core.o ioctl.o sysfs.o
 -nvme-core-y                           += core.o ioctl.o pr.o
++nvme-core-y                           += core.o ioctl.o sysfs.o pr.o
  nvme-core-$(CONFIG_NVME_VERBOSE_ERRORS)       += constants.o
  nvme-core-$(CONFIG_TRACING)           += trace.o
  nvme-core-$(CONFIG_NVME_MULTIPATH)    += multipath.o
 
        u32 hba_maxq, rem, tot_queues;
        struct Scsi_Host *host = hba->host;
  
 -      hba_maxq = FIELD_GET(MAX_QUEUE_SUP, hba->mcq_capabilities);
 +      /* maxq is 0 based value */
 +      hba_maxq = FIELD_GET(MAX_QUEUE_SUP, hba->mcq_capabilities) + 1;
  
-       tot_queues = UFS_MCQ_NUM_DEV_CMD_QUEUES + read_queues + poll_queues +
-                       rw_queues;
+       tot_queues = read_queues + poll_queues + rw_queues;
  
        if (hba_maxq < tot_queues) {
                dev_err(hba->dev, "Total queues (%d) exceeds HC capacity (%d)\n",