1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2008 ioogle, Inc. All rights reserved.
5 * Libata transport class.
7 * The ATA transport class contains common code to deal with ATA HBAs,
8 * an approximated representation of ATA topologies in the driver model,
9 * and various sysfs attributes to expose these topologies and management
10 * interfaces to user-space.
12 * There are 3 objects defined in this class:
16 * Each port has a link object. Each link can have up to two devices for PATA
17 * and generally one for SATA.
18 * If there is SATA port multiplier [PMP], 15 additional ata_link object are
21 * These objects are created when the ata host is initialized and when a PMP is
22 * found. They are removed only when the HBA is removed, cleaned before the
27 #include <linux/kernel.h>
28 #include <linux/blkdev.h>
29 #include <linux/spinlock.h>
30 #include <linux/slab.h>
31 #include <scsi/scsi_transport.h>
32 #include <linux/libata.h>
33 #include <linux/hdreg.h>
34 #include <linux/uaccess.h>
35 #include <linux/pm_runtime.h>
38 #include "libata-transport.h"
40 #define ATA_PORT_ATTRS 3
41 #define ATA_LINK_ATTRS 3
42 #define ATA_DEV_ATTRS 9
44 struct scsi_transport_template
;
45 struct scsi_transport_template
*ata_scsi_transport_template
;
48 struct scsi_transport_template t
;
50 struct device_attribute private_port_attrs
[ATA_PORT_ATTRS
];
51 struct device_attribute private_link_attrs
[ATA_LINK_ATTRS
];
52 struct device_attribute private_dev_attrs
[ATA_DEV_ATTRS
];
54 struct transport_container link_attr_cont
;
55 struct transport_container dev_attr_cont
;
58 * The array of null terminated pointers to attributes
59 * needed by scsi_sysfs.c
61 struct device_attribute
*link_attrs
[ATA_LINK_ATTRS
+ 1];
62 struct device_attribute
*port_attrs
[ATA_PORT_ATTRS
+ 1];
63 struct device_attribute
*dev_attrs
[ATA_DEV_ATTRS
+ 1];
65 #define to_ata_internal(tmpl) container_of(tmpl, struct ata_internal, t)
68 #define tdev_to_device(d) \
69 container_of((d), struct ata_device, tdev)
70 #define transport_class_to_dev(dev) \
71 tdev_to_device((dev)->parent)
73 #define tdev_to_link(d) \
74 container_of((d), struct ata_link, tdev)
75 #define transport_class_to_link(dev) \
76 tdev_to_link((dev)->parent)
78 #define tdev_to_port(d) \
79 container_of((d), struct ata_port, tdev)
80 #define transport_class_to_port(dev) \
81 tdev_to_port((dev)->parent)
84 * Hack to allow attributes of the same name in different objects.
86 #define ATA_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \
87 struct device_attribute device_attr_##_prefix##_##_name = \
88 __ATTR(_name,_mode,_show,_store)
90 #define ata_bitfield_name_match(title, table) \
92 get_ata_##title##_names(u32 table_key, char *buf) \
98 for (i = 0; i < ARRAY_SIZE(table); i++) { \
99 if (table[i].value & table_key) { \
100 len += sprintf(buf + len, "%s%s", \
101 prefix, table[i].name); \
105 len += sprintf(buf + len, "\n"); \
109 #define ata_bitfield_name_search(title, table) \
111 get_ata_##title##_names(u32 table_key, char *buf) \
116 for (i = 0; i < ARRAY_SIZE(table); i++) { \
117 if (table[i].value == table_key) { \
118 len += sprintf(buf + len, "%s", \
123 len += sprintf(buf + len, "\n"); \
130 } ata_class_names
[] = {
131 { ATA_DEV_UNKNOWN
, "unknown" },
132 { ATA_DEV_ATA
, "ata" },
133 { ATA_DEV_ATA_UNSUP
, "ata" },
134 { ATA_DEV_ATAPI
, "atapi" },
135 { ATA_DEV_ATAPI_UNSUP
, "atapi" },
136 { ATA_DEV_PMP
, "pmp" },
137 { ATA_DEV_PMP_UNSUP
, "pmp" },
138 { ATA_DEV_SEMB
, "semb" },
139 { ATA_DEV_SEMB_UNSUP
, "semb" },
140 { ATA_DEV_ZAC
, "zac" },
141 { ATA_DEV_NONE
, "none" }
143 ata_bitfield_name_search(class, ata_class_names
)
149 } ata_err_names
[] = {
150 { AC_ERR_DEV
, "DeviceError" },
151 { AC_ERR_HSM
, "HostStateMachineError" },
152 { AC_ERR_TIMEOUT
, "Timeout" },
153 { AC_ERR_MEDIA
, "MediaError" },
154 { AC_ERR_ATA_BUS
, "BusError" },
155 { AC_ERR_HOST_BUS
, "HostBusError" },
156 { AC_ERR_SYSTEM
, "SystemError" },
157 { AC_ERR_INVALID
, "InvalidArg" },
158 { AC_ERR_OTHER
, "Unknown" },
159 { AC_ERR_NODEV_HINT
, "NoDeviceHint" },
160 { AC_ERR_NCQ
, "NCQError" }
162 ata_bitfield_name_match(err
, ata_err_names
)
167 } ata_xfer_names
[] = {
168 { XFER_UDMA_7
, "XFER_UDMA_7" },
169 { XFER_UDMA_6
, "XFER_UDMA_6" },
170 { XFER_UDMA_5
, "XFER_UDMA_5" },
171 { XFER_UDMA_4
, "XFER_UDMA_4" },
172 { XFER_UDMA_3
, "XFER_UDMA_3" },
173 { XFER_UDMA_2
, "XFER_UDMA_2" },
174 { XFER_UDMA_1
, "XFER_UDMA_1" },
175 { XFER_UDMA_0
, "XFER_UDMA_0" },
176 { XFER_MW_DMA_4
, "XFER_MW_DMA_4" },
177 { XFER_MW_DMA_3
, "XFER_MW_DMA_3" },
178 { XFER_MW_DMA_2
, "XFER_MW_DMA_2" },
179 { XFER_MW_DMA_1
, "XFER_MW_DMA_1" },
180 { XFER_MW_DMA_0
, "XFER_MW_DMA_0" },
181 { XFER_SW_DMA_2
, "XFER_SW_DMA_2" },
182 { XFER_SW_DMA_1
, "XFER_SW_DMA_1" },
183 { XFER_SW_DMA_0
, "XFER_SW_DMA_0" },
184 { XFER_PIO_6
, "XFER_PIO_6" },
185 { XFER_PIO_5
, "XFER_PIO_5" },
186 { XFER_PIO_4
, "XFER_PIO_4" },
187 { XFER_PIO_3
, "XFER_PIO_3" },
188 { XFER_PIO_2
, "XFER_PIO_2" },
189 { XFER_PIO_1
, "XFER_PIO_1" },
190 { XFER_PIO_0
, "XFER_PIO_0" },
191 { XFER_PIO_SLOW
, "XFER_PIO_SLOW" }
193 ata_bitfield_name_search(xfer
, ata_xfer_names
)
196 * ATA Port attributes
198 #define ata_port_show_simple(field, name, format_string, cast) \
200 show_ata_port_##name(struct device *dev, \
201 struct device_attribute *attr, char *buf) \
203 struct ata_port *ap = transport_class_to_port(dev); \
205 return scnprintf(buf, 20, format_string, cast ap->field); \
208 #define ata_port_simple_attr(field, name, format_string, type) \
209 ata_port_show_simple(field, name, format_string, (type)) \
210 static DEVICE_ATTR(name, S_IRUGO, show_ata_port_##name, NULL)
212 ata_port_simple_attr(nr_pmp_links
, nr_pmp_links
, "%d\n", int);
213 ata_port_simple_attr(stats
.idle_irq
, idle_irq
, "%ld\n", unsigned long);
214 /* We want the port_no sysfs attibute to start at 1 (ap->port_no starts at 0) */
215 ata_port_simple_attr(port_no
+ 1, port_no
, "%u\n", unsigned int);
217 static DECLARE_TRANSPORT_CLASS(ata_port_class
,
218 "ata_port", NULL
, NULL
, NULL
);
220 static void ata_tport_release(struct device
*dev
)
222 struct ata_port
*ap
= tdev_to_port(dev
);
223 ata_host_put(ap
->host
);
227 * ata_is_port -- check if a struct device represents a ATA port
228 * @dev: device to check
231 * %1 if the device represents a ATA Port, %0 else
233 static int ata_is_port(const struct device
*dev
)
235 return dev
->release
== ata_tport_release
;
238 static int ata_tport_match(struct attribute_container
*cont
,
241 if (!ata_is_port(dev
))
243 return &ata_scsi_transport_template
->host_attrs
.ac
== cont
;
247 * ata_tport_delete -- remove ATA PORT
248 * @ap: ATA PORT to remove
250 * Removes the specified ATA PORT. Remove the associated link as well.
252 void ata_tport_delete(struct ata_port
*ap
)
254 struct device
*dev
= &ap
->tdev
;
256 ata_tlink_delete(&ap
->link
);
258 transport_remove_device(dev
);
260 transport_destroy_device(dev
);
263 EXPORT_SYMBOL_GPL(ata_tport_delete
);
265 static const struct device_type ata_port_sas_type
= {
266 .name
= ATA_PORT_TYPE_NAME
,
269 /** ata_tport_add - initialize a transport ATA port structure
271 * @parent: parent device
272 * @ap: existing ata_port structure
274 * Initialize a ATA port structure for sysfs. It will be added to the device
275 * tree below the device specified by @parent which could be a PCI device.
277 * Returns %0 on success
279 int ata_tport_add(struct device
*parent
,
283 struct device
*dev
= &ap
->tdev
;
285 device_initialize(dev
);
286 if (ap
->flags
& ATA_FLAG_SAS_HOST
)
287 dev
->type
= &ata_port_sas_type
;
289 dev
->type
= &ata_port_type
;
291 dev
->parent
= parent
;
292 ata_host_get(ap
->host
);
293 dev
->release
= ata_tport_release
;
294 dev_set_name(dev
, "ata%d", ap
->print_id
);
295 transport_setup_device(dev
);
296 ata_acpi_bind_port(ap
);
297 error
= device_add(dev
);
302 device_enable_async_suspend(dev
);
303 pm_runtime_set_active(dev
);
304 pm_runtime_enable(dev
);
305 pm_runtime_forbid(dev
);
307 error
= transport_add_device(dev
);
309 goto tport_transport_add_err
;
310 transport_configure_device(dev
);
312 error
= ata_tlink_add(&ap
->link
);
319 transport_remove_device(dev
);
320 tport_transport_add_err
:
324 transport_destroy_device(dev
);
328 EXPORT_SYMBOL_GPL(ata_tport_add
);
331 * ata_port_classify - determine device type based on ATA-spec signature
332 * @ap: ATA port device on which the classification should be run
333 * @tf: ATA taskfile register set for device to be identified
335 * A wrapper around ata_dev_classify() to provide additional logging
338 * Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP,
339 * %ATA_DEV_ZAC, or %ATA_DEV_UNKNOWN the event of failure.
341 unsigned int ata_port_classify(struct ata_port
*ap
,
342 const struct ata_taskfile
*tf
)
345 unsigned int class = ata_dev_classify(tf
);
347 /* Start with index '1' to skip the 'unknown' entry */
348 for (i
= 1; i
< ARRAY_SIZE(ata_class_names
); i
++) {
349 if (ata_class_names
[i
].value
== class) {
350 ata_port_dbg(ap
, "found %s device by sig\n",
351 ata_class_names
[i
].name
);
356 ata_port_info(ap
, "found unknown device (class %u)\n", class);
359 EXPORT_SYMBOL_GPL(ata_port_classify
);
362 * ATA device attributes
365 #define ata_dev_show_class(title, field) \
367 show_ata_dev_##field(struct device *dev, \
368 struct device_attribute *attr, char *buf) \
370 struct ata_device *ata_dev = transport_class_to_dev(dev); \
372 return get_ata_##title##_names(ata_dev->field, buf); \
375 #define ata_dev_attr(title, field) \
376 ata_dev_show_class(title, field) \
377 static DEVICE_ATTR(field, S_IRUGO, show_ata_dev_##field, NULL)
379 ata_dev_attr(class, class);
380 ata_dev_attr(xfer
, pio_mode
);
381 ata_dev_attr(xfer
, dma_mode
);
382 ata_dev_attr(xfer
, xfer_mode
);
385 #define ata_dev_show_simple(field, format_string, cast) \
387 show_ata_dev_##field(struct device *dev, \
388 struct device_attribute *attr, char *buf) \
390 struct ata_device *ata_dev = transport_class_to_dev(dev); \
392 return scnprintf(buf, 20, format_string, cast ata_dev->field); \
395 #define ata_dev_simple_attr(field, format_string, type) \
396 ata_dev_show_simple(field, format_string, (type)) \
397 static DEVICE_ATTR(field, S_IRUGO, \
398 show_ata_dev_##field, NULL)
400 ata_dev_simple_attr(spdn_cnt
, "%d\n", int);
402 struct ata_show_ering_arg
{
407 static int ata_show_ering(struct ata_ering_entry
*ent
, void *void_arg
)
409 struct ata_show_ering_arg
* arg
= void_arg
;
413 seconds
= div_u64_rem(ent
->timestamp
, HZ
, &rem
);
414 arg
->written
+= sprintf(arg
->buf
+ arg
->written
,
415 "[%5llu.%09lu]", seconds
,
416 rem
* NSEC_PER_SEC
/ HZ
);
417 arg
->written
+= get_ata_err_names(ent
->err_mask
,
418 arg
->buf
+ arg
->written
);
423 show_ata_dev_ering(struct device
*dev
,
424 struct device_attribute
*attr
, char *buf
)
426 struct ata_device
*ata_dev
= transport_class_to_dev(dev
);
427 struct ata_show_ering_arg arg
= { buf
, 0 };
429 ata_ering_map(&ata_dev
->ering
, ata_show_ering
, &arg
);
434 static DEVICE_ATTR(ering
, S_IRUGO
, show_ata_dev_ering
, NULL
);
437 show_ata_dev_id(struct device
*dev
,
438 struct device_attribute
*attr
, char *buf
)
440 struct ata_device
*ata_dev
= transport_class_to_dev(dev
);
441 int written
= 0, i
= 0;
443 if (ata_dev
->class == ATA_DEV_PMP
)
445 for(i
=0;i
<ATA_ID_WORDS
;i
++) {
446 written
+= scnprintf(buf
+written
, 20, "%04x%c",
448 ((i
+1) & 7) ? ' ' : '\n');
453 static DEVICE_ATTR(id
, S_IRUGO
, show_ata_dev_id
, NULL
);
456 show_ata_dev_gscr(struct device
*dev
,
457 struct device_attribute
*attr
, char *buf
)
459 struct ata_device
*ata_dev
= transport_class_to_dev(dev
);
460 int written
= 0, i
= 0;
462 if (ata_dev
->class != ATA_DEV_PMP
)
464 for(i
=0;i
<SATA_PMP_GSCR_DWORDS
;i
++) {
465 written
+= scnprintf(buf
+written
, 20, "%08x%c",
467 ((i
+1) & 3) ? ' ' : '\n');
469 if (SATA_PMP_GSCR_DWORDS
& 3)
470 buf
[written
-1] = '\n';
474 static DEVICE_ATTR(gscr
, S_IRUGO
, show_ata_dev_gscr
, NULL
);
477 show_ata_dev_trim(struct device
*dev
,
478 struct device_attribute
*attr
, char *buf
)
480 struct ata_device
*ata_dev
= transport_class_to_dev(dev
);
483 if (!ata_id_has_trim(ata_dev
->id
))
484 mode
= "unsupported";
485 else if (ata_dev
->quirks
& ATA_QUIRK_NOTRIM
)
486 mode
= "forced_unsupported";
487 else if (ata_dev
->quirks
& ATA_QUIRK_NO_NCQ_TRIM
)
488 mode
= "forced_unqueued";
489 else if (ata_fpdma_dsm_supported(ata_dev
))
494 return scnprintf(buf
, 20, "%s\n", mode
);
497 static DEVICE_ATTR(trim
, S_IRUGO
, show_ata_dev_trim
, NULL
);
499 static DECLARE_TRANSPORT_CLASS(ata_dev_class
,
500 "ata_device", NULL
, NULL
, NULL
);
502 static void ata_tdev_release(struct device
*dev
)
507 * ata_is_ata_dev -- check if a struct device represents a ATA device
508 * @dev: device to check
511 * true if the device represents a ATA device, false otherwise
513 static bool ata_is_ata_dev(const struct device
*dev
)
515 return dev
->release
== ata_tdev_release
;
518 static int ata_tdev_match(struct attribute_container
*cont
,
521 struct ata_internal
*i
= to_ata_internal(ata_scsi_transport_template
);
523 if (!ata_is_ata_dev(dev
))
525 return &i
->dev_attr_cont
.ac
== cont
;
529 * ata_tdev_free -- free an ATA transport device
530 * @dev: struct ata_device owning the transport device to free
532 * Free the ATA transport device for the specified ATA device.
535 * This function must only be called for a ATA transport device that has not
536 * yet successfully been added using ata_tdev_add().
538 static void ata_tdev_free(struct ata_device
*dev
)
540 transport_destroy_device(&dev
->tdev
);
541 put_device(&dev
->tdev
);
545 * ata_tdev_delete -- remove an ATA transport device
546 * @ata_dev: struct ata_device owning the transport device to delete
548 * Removes the ATA transport device for the specified ATA device.
550 static void ata_tdev_delete(struct ata_device
*ata_dev
)
552 struct device
*dev
= &ata_dev
->tdev
;
554 transport_remove_device(dev
);
556 ata_tdev_free(ata_dev
);
560 * ata_tdev_add -- initialize an ATA transport device
561 * @ata_dev: struct ata_device owning the transport device to add
563 * Initialize an ATA transport device for sysfs. It will be added in the
564 * device tree below the ATA link device it belongs to.
566 * Returns %0 on success and a negative error code on error.
568 static int ata_tdev_add(struct ata_device
*ata_dev
)
570 struct device
*dev
= &ata_dev
->tdev
;
571 struct ata_link
*link
= ata_dev
->link
;
572 struct ata_port
*ap
= link
->ap
;
575 device_initialize(dev
);
576 dev
->parent
= &link
->tdev
;
577 dev
->release
= ata_tdev_release
;
578 if (ata_is_host_link(link
))
579 dev_set_name(dev
, "dev%d.%d", ap
->print_id
,ata_dev
->devno
);
581 dev_set_name(dev
, "dev%d.%d.0", ap
->print_id
, link
->pmp
);
583 transport_setup_device(dev
);
584 ata_acpi_bind_dev(ata_dev
);
585 error
= device_add(dev
);
587 ata_tdev_free(ata_dev
);
591 error
= transport_add_device(dev
);
594 ata_tdev_free(ata_dev
);
598 transport_configure_device(dev
);
603 * ATA link attributes
605 static int noop(int x
)
610 #define ata_link_show_linkspeed(field, format) \
612 show_ata_link_##field(struct device *dev, \
613 struct device_attribute *attr, char *buf) \
615 struct ata_link *link = transport_class_to_link(dev); \
617 return sprintf(buf, "%s\n", \
618 sata_spd_string(format(link->field))); \
621 #define ata_link_linkspeed_attr(field, format) \
622 ata_link_show_linkspeed(field, format) \
623 static DEVICE_ATTR(field, 0444, show_ata_link_##field, NULL)
625 ata_link_linkspeed_attr(hw_sata_spd_limit
, fls
);
626 ata_link_linkspeed_attr(sata_spd_limit
, fls
);
627 ata_link_linkspeed_attr(sata_spd
, noop
);
629 static DECLARE_TRANSPORT_CLASS(ata_link_class
,
630 "ata_link", NULL
, NULL
, NULL
);
632 static void ata_tlink_release(struct device
*dev
)
637 * ata_is_link -- check if a struct device represents a ATA link
638 * @dev: device to check
641 * true if the device represents a ATA link, false otherwise
643 static bool ata_is_link(const struct device
*dev
)
645 return dev
->release
== ata_tlink_release
;
648 static int ata_tlink_match(struct attribute_container
*cont
,
651 struct ata_internal
*i
= to_ata_internal(ata_scsi_transport_template
);
653 if (!ata_is_link(dev
))
655 return &i
->link_attr_cont
.ac
== cont
;
659 * ata_tlink_delete -- remove an ATA link transport device
660 * @link: struct ata_link owning the link transport device to remove
662 * Removes the link transport device of the specified ATA link. This also
663 * removes the ATA device(s) associated with the link as well.
665 void ata_tlink_delete(struct ata_link
*link
)
667 struct device
*dev
= &link
->tdev
;
668 struct ata_device
*ata_dev
;
670 ata_for_each_dev(ata_dev
, link
, ALL
) {
671 ata_tdev_delete(ata_dev
);
674 transport_remove_device(dev
);
676 transport_destroy_device(dev
);
681 * ata_tlink_add -- initialize an ATA link transport device
682 * @link: struct ata_link owning the link transport device to initialize
684 * Initialize an ATA link transport device for sysfs. It will be added in the
685 * device tree below the ATA port it belongs to.
687 * Returns %0 on success and a negative error code on error.
689 int ata_tlink_add(struct ata_link
*link
)
691 struct device
*dev
= &link
->tdev
;
692 struct ata_port
*ap
= link
->ap
;
693 struct ata_device
*ata_dev
;
696 device_initialize(dev
);
697 dev
->parent
= &ap
->tdev
;
698 dev
->release
= ata_tlink_release
;
699 if (ata_is_host_link(link
))
700 dev_set_name(dev
, "link%d", ap
->print_id
);
702 dev_set_name(dev
, "link%d.%d", ap
->print_id
, link
->pmp
);
704 transport_setup_device(dev
);
706 error
= device_add(dev
);
710 error
= transport_add_device(dev
);
712 goto tlink_transport_err
;
713 transport_configure_device(dev
);
715 ata_for_each_dev(ata_dev
, link
, ALL
) {
716 error
= ata_tdev_add(ata_dev
);
722 while (--ata_dev
>= link
->device
)
723 ata_tdev_delete(ata_dev
);
724 transport_remove_device(dev
);
728 transport_destroy_device(dev
);
734 * Setup / Teardown code
737 #define SETUP_TEMPLATE(attrb, field, perm, test) \
738 i->private_##attrb[count] = dev_attr_##field; \
739 i->private_##attrb[count].attr.mode = perm; \
740 i->attrb[count] = &i->private_##attrb[count]; \
744 #define SETUP_LINK_ATTRIBUTE(field) \
745 SETUP_TEMPLATE(link_attrs, field, S_IRUGO, 1)
747 #define SETUP_PORT_ATTRIBUTE(field) \
748 SETUP_TEMPLATE(port_attrs, field, S_IRUGO, 1)
750 #define SETUP_DEV_ATTRIBUTE(field) \
751 SETUP_TEMPLATE(dev_attrs, field, S_IRUGO, 1)
754 * ata_attach_transport -- instantiate ATA transport template
756 struct scsi_transport_template
*ata_attach_transport(void)
758 struct ata_internal
*i
;
761 i
= kzalloc(sizeof(struct ata_internal
), GFP_KERNEL
);
765 i
->t
.eh_strategy_handler
= ata_scsi_error
;
766 i
->t
.user_scan
= ata_scsi_user_scan
;
768 i
->t
.host_attrs
.ac
.attrs
= &i
->port_attrs
[0];
769 i
->t
.host_attrs
.ac
.class = &ata_port_class
.class;
770 i
->t
.host_attrs
.ac
.match
= ata_tport_match
;
771 transport_container_register(&i
->t
.host_attrs
);
773 i
->link_attr_cont
.ac
.class = &ata_link_class
.class;
774 i
->link_attr_cont
.ac
.attrs
= &i
->link_attrs
[0];
775 i
->link_attr_cont
.ac
.match
= ata_tlink_match
;
776 transport_container_register(&i
->link_attr_cont
);
778 i
->dev_attr_cont
.ac
.class = &ata_dev_class
.class;
779 i
->dev_attr_cont
.ac
.attrs
= &i
->dev_attrs
[0];
780 i
->dev_attr_cont
.ac
.match
= ata_tdev_match
;
781 transport_container_register(&i
->dev_attr_cont
);
784 SETUP_PORT_ATTRIBUTE(nr_pmp_links
);
785 SETUP_PORT_ATTRIBUTE(idle_irq
);
786 SETUP_PORT_ATTRIBUTE(port_no
);
787 BUG_ON(count
> ATA_PORT_ATTRS
);
788 i
->port_attrs
[count
] = NULL
;
791 SETUP_LINK_ATTRIBUTE(hw_sata_spd_limit
);
792 SETUP_LINK_ATTRIBUTE(sata_spd_limit
);
793 SETUP_LINK_ATTRIBUTE(sata_spd
);
794 BUG_ON(count
> ATA_LINK_ATTRS
);
795 i
->link_attrs
[count
] = NULL
;
798 SETUP_DEV_ATTRIBUTE(class);
799 SETUP_DEV_ATTRIBUTE(pio_mode
);
800 SETUP_DEV_ATTRIBUTE(dma_mode
);
801 SETUP_DEV_ATTRIBUTE(xfer_mode
);
802 SETUP_DEV_ATTRIBUTE(spdn_cnt
);
803 SETUP_DEV_ATTRIBUTE(ering
);
804 SETUP_DEV_ATTRIBUTE(id
);
805 SETUP_DEV_ATTRIBUTE(gscr
);
806 SETUP_DEV_ATTRIBUTE(trim
);
807 BUG_ON(count
> ATA_DEV_ATTRS
);
808 i
->dev_attrs
[count
] = NULL
;
814 * ata_release_transport -- release ATA transport template instance
815 * @t: transport template instance
817 void ata_release_transport(struct scsi_transport_template
*t
)
819 struct ata_internal
*i
= to_ata_internal(t
);
821 transport_container_unregister(&i
->t
.host_attrs
);
822 transport_container_unregister(&i
->link_attr_cont
);
823 transport_container_unregister(&i
->dev_attr_cont
);
828 __init
int libata_transport_init(void)
832 error
= transport_class_register(&ata_link_class
);
834 goto out_unregister_transport
;
835 error
= transport_class_register(&ata_port_class
);
837 goto out_unregister_link
;
838 error
= transport_class_register(&ata_dev_class
);
840 goto out_unregister_port
;
844 transport_class_unregister(&ata_port_class
);
846 transport_class_unregister(&ata_link_class
);
847 out_unregister_transport
:
852 void __exit
libata_transport_exit(void)
854 transport_class_unregister(&ata_link_class
);
855 transport_class_unregister(&ata_port_class
);
856 transport_class_unregister(&ata_dev_class
);