Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ata: libata-scsi: use *switch* statements to check SCSI command codes

Replace strings of the *if* statements checking the SCSI command code
with the *switch* statements that fit better here...

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

authored by

Sergey Shtylyov and committed by
Damien Le Moal
59b00404 03c0e84f

+19 -7
+19 -7
drivers/ata/libata-scsi.c
··· 1362 1362 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 1363 1363 tf->protocol = ATA_PROT_NODATA; 1364 1364 1365 - if (cdb[0] == VERIFY) { 1365 + switch (cdb[0]) { 1366 + case VERIFY: 1366 1367 if (scmd->cmd_len < 10) { 1367 1368 fp = 9; 1368 1369 goto invalid_fld; 1369 1370 } 1370 1371 scsi_10_lba_len(cdb, &block, &n_block); 1371 - } else if (cdb[0] == VERIFY_16) { 1372 + break; 1373 + case VERIFY_16: 1372 1374 if (scmd->cmd_len < 16) { 1373 1375 fp = 15; 1374 1376 goto invalid_fld; 1375 1377 } 1376 1378 scsi_16_lba_len(cdb, &block, &n_block); 1377 - } else { 1379 + break; 1380 + default: 1378 1381 fp = 0; 1379 1382 goto invalid_fld; 1380 1383 } ··· 1509 1506 int rc; 1510 1507 u16 fp = 0; 1511 1508 1512 - if (cdb[0] == WRITE_10 || cdb[0] == WRITE_6 || cdb[0] == WRITE_16) 1509 + switch (cdb[0]) { 1510 + case WRITE_6: 1511 + case WRITE_10: 1512 + case WRITE_16: 1513 1513 tf_flags |= ATA_TFLAG_WRITE; 1514 + break; 1515 + } 1514 1516 1515 1517 /* Calculate the SCSI LBA, transfer length and FUA. */ 1516 1518 switch (cdb[0]) { ··· 2825 2817 * 12 and 16 byte CDBs use different offsets to 2826 2818 * provide the various register values. 2827 2819 */ 2828 - if (cdb[0] == ATA_16) { 2820 + switch (cdb[0]) { 2821 + case ATA_16: 2829 2822 /* 2830 2823 * 16-byte CDB - may contain extended commands. 2831 2824 * ··· 2852 2843 tf->lbah = cdb[12]; 2853 2844 tf->device = cdb[13]; 2854 2845 tf->command = cdb[14]; 2855 - } else if (cdb[0] == ATA_12) { 2846 + break; 2847 + case ATA_12: 2856 2848 /* 2857 2849 * 12-byte CDB - incapable of extended commands. 2858 2850 */ ··· 2866 2856 tf->lbah = cdb[7]; 2867 2857 tf->device = cdb[8]; 2868 2858 tf->command = cdb[9]; 2869 - } else { 2859 + break; 2860 + default: 2870 2861 /* 2871 2862 * 32-byte CDB - may contain extended command fields. 2872 2863 * ··· 2891 2880 tf->device = cdb[24]; 2892 2881 tf->command = cdb[25]; 2893 2882 tf->auxiliary = get_unaligned_be32(&cdb[28]); 2883 + break; 2894 2884 } 2895 2885 2896 2886 /* For NCQ commands copy the tag value */