.. | .. |
---|
2742 | 2742 | return 0; |
---|
2743 | 2743 | } |
---|
2744 | 2744 | |
---|
2745 | | -static struct ata_device *ata_find_dev(struct ata_port *ap, int devno) |
---|
| 2745 | +static struct ata_device *ata_find_dev(struct ata_port *ap, unsigned int devno) |
---|
2746 | 2746 | { |
---|
2747 | | - if (!sata_pmp_attached(ap)) { |
---|
2748 | | - if (likely(devno >= 0 && |
---|
2749 | | - devno < ata_link_max_devices(&ap->link))) |
---|
| 2747 | + /* |
---|
| 2748 | + * For the non-PMP case, ata_link_max_devices() returns 1 (SATA case), |
---|
| 2749 | + * or 2 (IDE master + slave case). However, the former case includes |
---|
| 2750 | + * libsas hosted devices which are numbered per scsi host, leading |
---|
| 2751 | + * to devno potentially being larger than 0 but with each struct |
---|
| 2752 | + * ata_device having its own struct ata_port and struct ata_link. |
---|
| 2753 | + * To accommodate these, ignore devno and always use device number 0. |
---|
| 2754 | + */ |
---|
| 2755 | + if (likely(!sata_pmp_attached(ap))) { |
---|
| 2756 | + int link_max_devices = ata_link_max_devices(&ap->link); |
---|
| 2757 | + |
---|
| 2758 | + if (link_max_devices == 1) |
---|
| 2759 | + return &ap->link.device[0]; |
---|
| 2760 | + |
---|
| 2761 | + if (devno < link_max_devices) |
---|
2750 | 2762 | return &ap->link.device[devno]; |
---|
2751 | | - } else { |
---|
2752 | | - if (likely(devno >= 0 && |
---|
2753 | | - devno < ap->nr_pmp_links)) |
---|
2754 | | - return &ap->pmp_link[devno].device[0]; |
---|
| 2763 | + |
---|
| 2764 | + return NULL; |
---|
2755 | 2765 | } |
---|
| 2766 | + |
---|
| 2767 | + /* |
---|
| 2768 | + * For PMP-attached devices, the device number corresponds to C |
---|
| 2769 | + * (channel) of SCSI [H:C:I:L], indicating the port pmp link |
---|
| 2770 | + * for the device. |
---|
| 2771 | + */ |
---|
| 2772 | + if (devno < ap->nr_pmp_links) |
---|
| 2773 | + return &ap->pmp_link[devno].device[0]; |
---|
2756 | 2774 | |
---|
2757 | 2775 | return NULL; |
---|
2758 | 2776 | } |
---|
.. | .. |
---|
4241 | 4259 | break; |
---|
4242 | 4260 | |
---|
4243 | 4261 | case MAINTENANCE_IN: |
---|
4244 | | - if (scsicmd[1] == MI_REPORT_SUPPORTED_OPERATION_CODES) |
---|
| 4262 | + if ((scsicmd[1] & 0x1f) == MI_REPORT_SUPPORTED_OPERATION_CODES) |
---|
4245 | 4263 | ata_scsi_rbuf_fill(&args, ata_scsiop_maint_in); |
---|
4246 | 4264 | else |
---|
4247 | 4265 | ata_scsi_set_invalid_field(dev, cmd, 1, 0xff); |
---|