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)
143 ata_bitfield_name_search(class, ata_class_names)
205 return scnprintf(buf, 20, format_string, cast ap->field); \
212 ata_port_simple_attr(nr_pmp_links, nr_pmp_links, "%d\n", int);
214 /* We want the port_no sysfs attibute to start at 1 (ap->port_no starts at 0) */
223 ata_host_put(ap->host); in ata_tport_release()
227 * ata_is_port -- check if a struct device represents a ATA port
235 return dev->release == ata_tport_release; in ata_is_port()
243 return &ata_scsi_transport_template->host_attrs.ac == cont; in ata_tport_match()
247 * ata_tport_delete -- remove ATA PORT
254 struct device *dev = &ap->tdev; in ata_tport_delete()
256 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 if (ap->flags & ATA_FLAG_SAS_HOST) in ata_tport_add()
287 dev->type = &ata_port_sas_type; in ata_tport_add()
289 dev->type = &ata_port_type; in ata_tport_add()
291 dev->parent = parent; in ata_tport_add()
292 ata_host_get(ap->host); in ata_tport_add()
293 dev->release = ata_tport_release; in ata_tport_add()
294 dev_set_name(dev, "ata%d", ap->print_id); in ata_tport_add()
312 error = ata_tlink_add(&ap->link); in ata_tport_add()
331 * ata_port_classify - determine device type based on ATA-spec signature
345 unsigned int class = ata_dev_classify(tf); in ata_port_classify() local
349 if (ata_class_names[i].value == class) { in ata_port_classify()
352 return class; in ata_port_classify()
356 ata_port_info(ap, "found unknown device (class %u)\n", class); in ata_port_classify()
357 return class; in ata_port_classify()
372 return get_ata_##title##_names(ata_dev->field, buf); \
379 ata_dev_attr(class, class);
392 return scnprintf(buf, 20, format_string, cast ata_dev->field); \
400 ata_dev_simple_attr(spdn_cnt, "%d\n", int);
413 seconds = div_u64_rem(ent->timestamp, HZ, &rem); in ata_show_ering()
414 arg->written += sprintf(arg->buf + arg->written, in ata_show_ering()
417 arg->written += get_ata_err_names(ent->err_mask, in ata_show_ering()
418 arg->buf + arg->written); in ata_show_ering()
429 ata_ering_map(&ata_dev->ering, ata_show_ering, &arg); in show_ata_dev_ering()
443 if (ata_dev->class == ATA_DEV_PMP) in show_ata_dev_id()
447 ata_dev->id[i], in show_ata_dev_id()
462 if (ata_dev->class != ATA_DEV_PMP) in show_ata_dev_gscr()
466 ata_dev->gscr[i], in show_ata_dev_gscr()
470 buf[written-1] = '\n'; in show_ata_dev_gscr()
483 if (!ata_id_has_trim(ata_dev->id)) in show_ata_dev_trim()
485 else if (ata_dev->quirks & ATA_QUIRK_NOTRIM) in show_ata_dev_trim()
487 else if (ata_dev->quirks & ATA_QUIRK_NO_NCQ_TRIM) in show_ata_dev_trim()
507 * ata_is_ata_dev -- check if a struct device represents a ATA device
515 return dev->release == ata_tdev_release; in ata_is_ata_dev()
525 return &i->dev_attr_cont.ac == cont; in ata_tdev_match()
529 * ata_tdev_free -- free an ATA transport device
540 transport_destroy_device(&dev->tdev); in ata_tdev_free()
541 put_device(&dev->tdev); in ata_tdev_free()
545 * ata_tdev_delete -- remove an ATA transport device
552 struct device *dev = &ata_dev->tdev; in ata_tdev_delete()
560 * ata_tdev_add -- initialize an ATA transport device
570 struct device *dev = &ata_dev->tdev; in ata_tdev_add()
571 struct ata_link *link = ata_dev->link; in ata_tdev_add()
572 struct ata_port *ap = link->ap; in ata_tdev_add()
576 dev->parent = &link->tdev; in ata_tdev_add()
577 dev->release = ata_tdev_release; in ata_tdev_add()
579 dev_set_name(dev, "dev%d.%d", ap->print_id,ata_dev->devno); in ata_tdev_add()
581 dev_set_name(dev, "dev%d.%d.0", ap->print_id, link->pmp); in ata_tdev_add()
618 sata_spd_string(format(link->field))); \
637 * ata_is_link -- check if a struct device represents a ATA link
645 return dev->release == ata_tlink_release; in ata_is_link()
655 return &i->link_attr_cont.ac == cont; in ata_tlink_match()
659 * ata_tlink_delete -- remove an ATA link transport device
667 struct device *dev = &link->tdev; in ata_tlink_delete()
681 * ata_tlink_add -- initialize an ATA link transport device
691 struct device *dev = &link->tdev; in ata_tlink_add()
692 struct ata_port *ap = link->ap; in ata_tlink_add()
697 dev->parent = &ap->tdev; in ata_tlink_add()
698 dev->release = ata_tlink_release; in ata_tlink_add()
700 dev_set_name(dev, "link%d", ap->print_id); in ata_tlink_add()
702 dev_set_name(dev, "link%d.%d", ap->print_id, link->pmp); in ata_tlink_add()
722 while (--ata_dev >= link->device) in ata_tlink_add()
738 i->private_##attrb[count] = dev_attr_##field; \
739 i->private_##attrb[count].attr.mode = perm; \
740 i->attrb[count] = &i->private_##attrb[count]; \
754 * ata_attach_transport -- instantiate ATA transport template
765 i->t.eh_strategy_handler = ata_scsi_error; in ata_attach_transport()
766 i->t.user_scan = ata_scsi_user_scan; in ata_attach_transport()
768 i->t.host_attrs.ac.attrs = &i->port_attrs[0]; in ata_attach_transport()
769 i->t.host_attrs.ac.class = &ata_port_class.class; in ata_attach_transport()
770 i->t.host_attrs.ac.match = ata_tport_match; in ata_attach_transport()
771 transport_container_register(&i->t.host_attrs); in ata_attach_transport()
773 i->link_attr_cont.ac.class = &ata_link_class.class; in ata_attach_transport()
774 i->link_attr_cont.ac.attrs = &i->link_attrs[0]; in ata_attach_transport()
775 i->link_attr_cont.ac.match = ata_tlink_match; in ata_attach_transport()
776 transport_container_register(&i->link_attr_cont); in ata_attach_transport()
778 i->dev_attr_cont.ac.class = &ata_dev_class.class; in ata_attach_transport()
779 i->dev_attr_cont.ac.attrs = &i->dev_attrs[0]; in ata_attach_transport()
780 i->dev_attr_cont.ac.match = ata_tdev_match; in ata_attach_transport()
781 transport_container_register(&i->dev_attr_cont); in ata_attach_transport()
788 i->port_attrs[count] = NULL; in ata_attach_transport()
795 i->link_attrs[count] = NULL; in ata_attach_transport()
798 SETUP_DEV_ATTRIBUTE(class); in ata_attach_transport()
808 i->dev_attrs[count] = NULL; in ata_attach_transport()
810 return &i->t; in ata_attach_transport()
814 * ata_release_transport -- release ATA transport template instance
821 transport_container_unregister(&i->t.host_attrs); in ata_release_transport()
822 transport_container_unregister(&i->link_attr_cont); in ata_release_transport()
823 transport_container_unregister(&i->dev_attr_cont); in ata_release_transport()