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

ata: libata: Add ata_port_classify() helper

Add an ata_port_classify() helper to print out the results from
the device classification and remove the debugging statements
from ata_dev_classify().

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

authored by

Hannes Reinecke and committed by
Damien Le Moal
6c952a0d bb6a42d7

+42 -21
+1 -1
drivers/ata/libahci.c
··· 1300 1300 tf.lbal = (tmp >> 8) & 0xff; 1301 1301 tf.nsect = (tmp) & 0xff; 1302 1302 1303 - return ata_dev_classify(&tf); 1303 + return ata_port_classify(ap, &tf); 1304 1304 } 1305 1305 EXPORT_SYMBOL_GPL(ahci_dev_classify); 1306 1306
+5 -16
drivers/ata/libata-core.c
··· 1007 1007 * SEMB signature. This is worked around in 1008 1008 * ata_dev_read_id(). 1009 1009 */ 1010 - if ((tf->lbam == 0) && (tf->lbah == 0)) { 1011 - DPRINTK("found ATA device by sig\n"); 1010 + if (tf->lbam == 0 && tf->lbah == 0) 1012 1011 return ATA_DEV_ATA; 1013 - } 1014 1012 1015 - if ((tf->lbam == 0x14) && (tf->lbah == 0xeb)) { 1016 - DPRINTK("found ATAPI device by sig\n"); 1013 + if (tf->lbam == 0x14 && tf->lbah == 0xeb) 1017 1014 return ATA_DEV_ATAPI; 1018 - } 1019 1015 1020 - if ((tf->lbam == 0x69) && (tf->lbah == 0x96)) { 1021 - DPRINTK("found PMP device by sig\n"); 1016 + if (tf->lbam == 0x69 && tf->lbah == 0x96) 1022 1017 return ATA_DEV_PMP; 1023 - } 1024 1018 1025 - if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3)) { 1026 - DPRINTK("found SEMB device by sig (could be ATA device)\n"); 1019 + if (tf->lbam == 0x3c && tf->lbah == 0xc3) 1027 1020 return ATA_DEV_SEMB; 1028 - } 1029 1021 1030 - if ((tf->lbam == 0xcd) && (tf->lbah == 0xab)) { 1031 - DPRINTK("found ZAC device by sig\n"); 1022 + if (tf->lbam == 0xcd && tf->lbah == 0xab) 1032 1023 return ATA_DEV_ZAC; 1033 - } 1034 1024 1035 - DPRINTK("unknown device\n"); 1036 1025 return ATA_DEV_UNKNOWN; 1037 1026 } 1038 1027 EXPORT_SYMBOL_GPL(ata_dev_classify);
+1 -1
drivers/ata/libata-sff.c
··· 1853 1853 return ATA_DEV_NONE; 1854 1854 1855 1855 /* determine if device is ATA or ATAPI */ 1856 - class = ata_dev_classify(&tf); 1856 + class = ata_port_classify(ap, &tf); 1857 1857 1858 1858 if (class == ATA_DEV_UNKNOWN) { 1859 1859 /* If the device failed diagnostic, it's likely to
+30
drivers/ata/libata-transport.c
··· 321 321 return error; 322 322 } 323 323 324 + /** 325 + * ata_port_classify - determine device type based on ATA-spec signature 326 + * @ap: ATA port device on which the classification should be run 327 + * @tf: ATA taskfile register set for device to be identified 328 + * 329 + * A wrapper around ata_dev_classify() to provide additional logging 330 + * 331 + * RETURNS: 332 + * Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP, 333 + * %ATA_DEV_ZAC, or %ATA_DEV_UNKNOWN the event of failure. 334 + */ 335 + unsigned int ata_port_classify(struct ata_port *ap, 336 + const struct ata_taskfile *tf) 337 + { 338 + int i; 339 + unsigned int class = ata_dev_classify(tf); 340 + 341 + /* Start with index '1' to skip the 'unknown' entry */ 342 + for (i = 1; i < ARRAY_SIZE(ata_class_names); i++) { 343 + if (ata_class_names[i].value == class) { 344 + ata_port_dbg(ap, "found %s device by sig\n", 345 + ata_class_names[i].name); 346 + return class; 347 + } 348 + } 349 + 350 + ata_port_info(ap, "found unknown device (class %u)\n", class); 351 + return class; 352 + } 353 + EXPORT_SYMBOL_GPL(ata_port_classify); 324 354 325 355 /* 326 356 * ATA link attributes
+1 -1
drivers/ata/sata_fsl.c
··· 814 814 tf.lbal = (temp >> 8) & 0xff; 815 815 tf.nsect = temp & 0xff; 816 816 817 - return ata_dev_classify(&tf); 817 + return ata_port_classify(ap, &tf); 818 818 } 819 819 820 820 static int sata_fsl_hardreset(struct ata_link *link, unsigned int *class,
+1 -1
drivers/ata/sata_inic162x.c
··· 657 657 } 658 658 659 659 inic_tf_read(ap, &tf); 660 - *class = ata_dev_classify(&tf); 660 + *class = ata_port_classify(ap, &tf); 661 661 } 662 662 663 663 return 0;
+1 -1
drivers/ata/sata_sil24.c
··· 680 680 } 681 681 682 682 sil24_read_tf(ap, 0, &tf); 683 - *class = ata_dev_classify(&tf); 683 + *class = ata_port_classify(ap, &tf); 684 684 685 685 DPRINTK("EXIT, class=%u\n", *class); 686 686 return 0;
+2
include/linux/libata.h
··· 1160 1160 extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 1161 1161 unsigned int n_elem); 1162 1162 extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); 1163 + extern unsigned int ata_port_classify(struct ata_port *ap, 1164 + const struct ata_taskfile *tf); 1163 1165 extern void ata_dev_disable(struct ata_device *adev); 1164 1166 extern void ata_id_string(const u16 *id, unsigned char *s, 1165 1167 unsigned int ofs, unsigned int len);