Lines Matching +full:class +full:- +full:d

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Libata transport class.
7 * The ATA transport class contains common code to deal with ATA HBAs,
10 * interfaces to user-space.
12 * There are 3 objects defined in this class:
13 * - ata_port
14 * - ata_link
15 * - ata_device
38 #include "libata-transport.h"
68 #define tdev_to_device(d) \ argument
69 container_of((d), struct ata_device, tdev)
71 tdev_to_device((dev)->parent)
73 #define tdev_to_link(d) \ argument
74 container_of((d), struct ata_link, tdev)
76 tdev_to_link((dev)->parent)
78 #define tdev_to_port(d) \ argument
79 container_of((d), struct ata_port, tdev)
81 tdev_to_port((dev)->parent)
149 ata_bitfield_name_search(class, ata_class_names)
211 return scnprintf(buf, 20, format_string, cast ap->field); \
218 ata_port_simple_attr(nr_pmp_links, nr_pmp_links, "%d\n", int);
228 ata_host_put(ap->host); in ata_tport_release()
232 * ata_is_port -- check if a struct device represents a ATA port
240 return dev->release == ata_tport_release; in ata_is_port()
248 return &ata_scsi_transport_template->host_attrs.ac == cont; in ata_tport_match()
252 * ata_tport_delete -- remove ATA PORT
259 struct device *dev = &ap->tdev; in ata_tport_delete()
261 ata_tlink_delete(&ap->link); in ata_tport_delete()
269 /** ata_tport_add - initialize a transport ATA port structure
283 struct device *dev = &ap->tdev; in ata_tport_add()
286 dev->type = &ata_port_type; in ata_tport_add()
288 dev->parent = parent; in ata_tport_add()
289 ata_host_get(ap->host); in ata_tport_add()
290 dev->release = ata_tport_release; in ata_tport_add()
291 dev_set_name(dev, "ata%d", ap->print_id); in ata_tport_add()
309 error = ata_tlink_add(&ap->link); in ata_tport_add()
327 * ata_port_classify - determine device type based on ATA-spec signature
341 unsigned int class = ata_dev_classify(tf); in ata_port_classify() local
345 if (ata_class_names[i].value == class) { in ata_port_classify()
348 return class; in ata_port_classify()
352 ata_port_info(ap, "found unknown device (class %u)\n", class); in ata_port_classify()
353 return class; in ata_port_classify()
369 return sprintf(buf, "%s\n", sata_spd_string(format(link->field))); \
389 * ata_is_link -- check if a struct device represents a ATA link
397 return dev->release == ata_tlink_release; in ata_is_link()
406 return &i->link_attr_cont.ac == cont; in ata_tlink_match()
410 * ata_tlink_delete -- remove ATA LINK
417 struct device *dev = &link->tdev; in ata_tlink_delete()
431 * ata_tlink_add -- initialize a transport ATA link structure
441 struct device *dev = &link->tdev; in ata_tlink_add()
442 struct ata_port *ap = link->ap; in ata_tlink_add()
447 dev->parent = &ap->tdev; in ata_tlink_add()
448 dev->release = ata_tlink_release; in ata_tlink_add()
450 dev_set_name(dev, "link%d", ap->print_id); in ata_tlink_add()
452 dev_set_name(dev, "link%d.%d", ap->print_id, link->pmp); in ata_tlink_add()
474 while (--ata_dev >= link->device) { in ata_tlink_add()
497 return get_ata_##title##_names(ata_dev->field, buf); \
504 ata_dev_attr(class, class);
517 return scnprintf(buf, 20, format_string, cast ata_dev->field); \
525 ata_dev_simple_attr(spdn_cnt, "%d\n", int);
538 seconds = div_u64_rem(ent->timestamp, HZ, &rem); in ata_show_ering()
539 arg->written += sprintf(arg->buf + arg->written, in ata_show_ering()
542 arg->written += get_ata_err_names(ent->err_mask, in ata_show_ering()
543 arg->buf + arg->written); in ata_show_ering()
554 ata_ering_map(&ata_dev->ering, ata_show_ering, &arg); in show_ata_dev_ering()
568 if (ata_dev->class == ATA_DEV_PMP) in show_ata_dev_id()
572 ata_dev->id[i], in show_ata_dev_id()
587 if (ata_dev->class != ATA_DEV_PMP) in show_ata_dev_gscr()
591 ata_dev->gscr[i], in show_ata_dev_gscr()
595 buf[written-1] = '\n'; in show_ata_dev_gscr()
608 if (!ata_id_has_trim(ata_dev->id)) in show_ata_dev_trim()
610 else if (ata_dev->horkage & ATA_HORKAGE_NOTRIM) in show_ata_dev_trim()
612 else if (ata_dev->horkage & ATA_HORKAGE_NO_NCQ_TRIM) in show_ata_dev_trim()
632 * ata_is_ata_dev -- check if a struct device represents a ATA device
640 return dev->release == ata_tdev_release; in ata_is_ata_dev()
649 return &i->dev_attr_cont.ac == cont; in ata_tdev_match()
653 * ata_tdev_free -- free a ATA LINK
664 transport_destroy_device(&dev->tdev); in ata_tdev_free()
665 put_device(&dev->tdev); in ata_tdev_free()
669 * ata_tdev_delete -- remove ATA device
676 struct device *dev = &ata_dev->tdev; in ata_tdev_delete()
685 * ata_tdev_add -- initialize a transport ATA device structure.
695 struct device *dev = &ata_dev->tdev; in ata_tdev_add()
696 struct ata_link *link = ata_dev->link; in ata_tdev_add()
697 struct ata_port *ap = link->ap; in ata_tdev_add()
701 dev->parent = &link->tdev; in ata_tdev_add()
702 dev->release = ata_tdev_release; in ata_tdev_add()
704 dev_set_name(dev, "dev%d.%d", ap->print_id,ata_dev->devno); in ata_tdev_add()
706 dev_set_name(dev, "dev%d.%d.0", ap->print_id, link->pmp); in ata_tdev_add()
733 i->private_##attrb[count] = dev_attr_##field; \
734 i->private_##attrb[count].attr.mode = perm; \
735 i->attrb[count] = &i->private_##attrb[count]; \
749 * ata_attach_transport -- instantiate ATA transport template
760 i->t.eh_strategy_handler = ata_scsi_error; in ata_attach_transport()
761 i->t.user_scan = ata_scsi_user_scan; in ata_attach_transport()
763 i->t.host_attrs.ac.attrs = &i->port_attrs[0]; in ata_attach_transport()
764 i->t.host_attrs.ac.class = &ata_port_class.class; in ata_attach_transport()
765 i->t.host_attrs.ac.match = ata_tport_match; in ata_attach_transport()
766 transport_container_register(&i->t.host_attrs); in ata_attach_transport()
768 i->link_attr_cont.ac.class = &ata_link_class.class; in ata_attach_transport()
769 i->link_attr_cont.ac.attrs = &i->link_attrs[0]; in ata_attach_transport()
770 i->link_attr_cont.ac.match = ata_tlink_match; in ata_attach_transport()
771 transport_container_register(&i->link_attr_cont); in ata_attach_transport()
773 i->dev_attr_cont.ac.class = &ata_dev_class.class; in ata_attach_transport()
774 i->dev_attr_cont.ac.attrs = &i->dev_attrs[0]; in ata_attach_transport()
775 i->dev_attr_cont.ac.match = ata_tdev_match; in ata_attach_transport()
776 transport_container_register(&i->dev_attr_cont); in ata_attach_transport()
783 i->port_attrs[count] = NULL; in ata_attach_transport()
790 i->link_attrs[count] = NULL; in ata_attach_transport()
793 SETUP_DEV_ATTRIBUTE(class); in ata_attach_transport()
803 i->dev_attrs[count] = NULL; in ata_attach_transport()
805 return &i->t; in ata_attach_transport()
809 * ata_release_transport -- release ATA transport template instance
816 transport_container_unregister(&i->t.host_attrs); in ata_release_transport()
817 transport_container_unregister(&i->link_attr_cont); in ata_release_transport()
818 transport_container_unregister(&i->dev_attr_cont); in ata_release_transport()