2019-05-28 17:10:12 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2010-05-25 19:31:38 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2008 ioogle, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Libata transport class.
|
|
|
|
*
|
|
|
|
* The ATA transport class contains common code to deal with ATA HBAs,
|
|
|
|
* an approximated representation of ATA topologies in the driver model,
|
|
|
|
* and various sysfs attributes to expose these topologies and management
|
|
|
|
* interfaces to user-space.
|
|
|
|
*
|
2022-06-04 14:29:27 +00:00
|
|
|
* There are 3 objects defined in this class:
|
2010-05-25 19:31:38 +00:00
|
|
|
* - ata_port
|
|
|
|
* - ata_link
|
|
|
|
* - ata_device
|
|
|
|
* Each port has a link object. Each link can have up to two devices for PATA
|
|
|
|
* and generally one for SATA.
|
|
|
|
* If there is SATA port multiplier [PMP], 15 additional ata_link object are
|
|
|
|
* created.
|
|
|
|
*
|
|
|
|
* These objects are created when the ata host is initialized and when a PMP is
|
|
|
|
* found. They are removed only when the HBA is removed, cleaned before the
|
|
|
|
* error handler runs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/spinlock.h>
|
2010-08-19 20:11:32 +00:00
|
|
|
#include <linux/slab.h>
|
2010-05-25 19:31:38 +00:00
|
|
|
#include <scsi/scsi_transport.h>
|
|
|
|
#include <linux/libata.h>
|
|
|
|
#include <linux/hdreg.h>
|
|
|
|
#include <linux/uaccess.h>
|
2011-12-05 01:20:28 +00:00
|
|
|
#include <linux/pm_runtime.h>
|
2010-05-25 19:31:38 +00:00
|
|
|
|
|
|
|
#include "libata.h"
|
|
|
|
#include "libata-transport.h"
|
|
|
|
|
2013-05-14 18:48:40 +00:00
|
|
|
#define ATA_PORT_ATTRS 3
|
2010-05-25 19:31:38 +00:00
|
|
|
#define ATA_LINK_ATTRS 3
|
|
|
|
#define ATA_DEV_ATTRS 9
|
|
|
|
|
|
|
|
struct scsi_transport_template;
|
|
|
|
struct scsi_transport_template *ata_scsi_transport_template;
|
|
|
|
|
|
|
|
struct ata_internal {
|
|
|
|
struct scsi_transport_template t;
|
|
|
|
|
|
|
|
struct device_attribute private_port_attrs[ATA_PORT_ATTRS];
|
|
|
|
struct device_attribute private_link_attrs[ATA_LINK_ATTRS];
|
|
|
|
struct device_attribute private_dev_attrs[ATA_DEV_ATTRS];
|
|
|
|
|
|
|
|
struct transport_container link_attr_cont;
|
|
|
|
struct transport_container dev_attr_cont;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The array of null terminated pointers to attributes
|
|
|
|
* needed by scsi_sysfs.c
|
|
|
|
*/
|
|
|
|
struct device_attribute *link_attrs[ATA_LINK_ATTRS + 1];
|
|
|
|
struct device_attribute *port_attrs[ATA_PORT_ATTRS + 1];
|
|
|
|
struct device_attribute *dev_attrs[ATA_DEV_ATTRS + 1];
|
|
|
|
};
|
|
|
|
#define to_ata_internal(tmpl) container_of(tmpl, struct ata_internal, t)
|
|
|
|
|
|
|
|
|
|
|
|
#define tdev_to_device(d) \
|
|
|
|
container_of((d), struct ata_device, tdev)
|
|
|
|
#define transport_class_to_dev(dev) \
|
|
|
|
tdev_to_device((dev)->parent)
|
|
|
|
|
|
|
|
#define tdev_to_link(d) \
|
|
|
|
container_of((d), struct ata_link, tdev)
|
|
|
|
#define transport_class_to_link(dev) \
|
|
|
|
tdev_to_link((dev)->parent)
|
|
|
|
|
|
|
|
#define tdev_to_port(d) \
|
|
|
|
container_of((d), struct ata_port, tdev)
|
|
|
|
#define transport_class_to_port(dev) \
|
|
|
|
tdev_to_port((dev)->parent)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hack to allow attributes of the same name in different objects.
|
|
|
|
*/
|
|
|
|
#define ATA_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \
|
|
|
|
struct device_attribute device_attr_##_prefix##_##_name = \
|
|
|
|
__ATTR(_name,_mode,_show,_store)
|
|
|
|
|
|
|
|
#define ata_bitfield_name_match(title, table) \
|
|
|
|
static ssize_t \
|
|
|
|
get_ata_##title##_names(u32 table_key, char *buf) \
|
|
|
|
{ \
|
|
|
|
char *prefix = ""; \
|
|
|
|
ssize_t len = 0; \
|
|
|
|
int i; \
|
|
|
|
\
|
|
|
|
for (i = 0; i < ARRAY_SIZE(table); i++) { \
|
|
|
|
if (table[i].value & table_key) { \
|
|
|
|
len += sprintf(buf + len, "%s%s", \
|
|
|
|
prefix, table[i].name); \
|
|
|
|
prefix = ", "; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
len += sprintf(buf + len, "\n"); \
|
|
|
|
return len; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ata_bitfield_name_search(title, table) \
|
|
|
|
static ssize_t \
|
|
|
|
get_ata_##title##_names(u32 table_key, char *buf) \
|
|
|
|
{ \
|
|
|
|
ssize_t len = 0; \
|
|
|
|
int i; \
|
|
|
|
\
|
|
|
|
for (i = 0; i < ARRAY_SIZE(table); i++) { \
|
|
|
|
if (table[i].value == table_key) { \
|
|
|
|
len += sprintf(buf + len, "%s", \
|
|
|
|
table[i].name); \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
len += sprintf(buf + len, "\n"); \
|
|
|
|
return len; \
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
u32 value;
|
|
|
|
char *name;
|
|
|
|
} ata_class_names[] = {
|
|
|
|
{ ATA_DEV_UNKNOWN, "unknown" },
|
|
|
|
{ ATA_DEV_ATA, "ata" },
|
|
|
|
{ ATA_DEV_ATA_UNSUP, "ata" },
|
|
|
|
{ ATA_DEV_ATAPI, "atapi" },
|
|
|
|
{ ATA_DEV_ATAPI_UNSUP, "atapi" },
|
|
|
|
{ ATA_DEV_PMP, "pmp" },
|
|
|
|
{ ATA_DEV_PMP_UNSUP, "pmp" },
|
|
|
|
{ ATA_DEV_SEMB, "semb" },
|
|
|
|
{ ATA_DEV_SEMB_UNSUP, "semb" },
|
2014-11-05 12:08:21 +00:00
|
|
|
{ ATA_DEV_ZAC, "zac" },
|
2010-05-25 19:31:38 +00:00
|
|
|
{ ATA_DEV_NONE, "none" }
|
|
|
|
};
|
|
|
|
ata_bitfield_name_search(class, ata_class_names)
|
|
|
|
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
u32 value;
|
|
|
|
char *name;
|
|
|
|
} ata_err_names[] = {
|
|
|
|
{ AC_ERR_DEV, "DeviceError" },
|
|
|
|
{ AC_ERR_HSM, "HostStateMachineError" },
|
|
|
|
{ AC_ERR_TIMEOUT, "Timeout" },
|
|
|
|
{ AC_ERR_MEDIA, "MediaError" },
|
|
|
|
{ AC_ERR_ATA_BUS, "BusError" },
|
|
|
|
{ AC_ERR_HOST_BUS, "HostBusError" },
|
|
|
|
{ AC_ERR_SYSTEM, "SystemError" },
|
|
|
|
{ AC_ERR_INVALID, "InvalidArg" },
|
|
|
|
{ AC_ERR_OTHER, "Unknown" },
|
|
|
|
{ AC_ERR_NODEV_HINT, "NoDeviceHint" },
|
2021-12-21 07:20:25 +00:00
|
|
|
{ AC_ERR_NCQ, "NCQError" }
|
2010-05-25 19:31:38 +00:00
|
|
|
};
|
|
|
|
ata_bitfield_name_match(err, ata_err_names)
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
u32 value;
|
|
|
|
char *name;
|
|
|
|
} ata_xfer_names[] = {
|
|
|
|
{ XFER_UDMA_7, "XFER_UDMA_7" },
|
|
|
|
{ XFER_UDMA_6, "XFER_UDMA_6" },
|
|
|
|
{ XFER_UDMA_5, "XFER_UDMA_5" },
|
|
|
|
{ XFER_UDMA_4, "XFER_UDMA_4" },
|
|
|
|
{ XFER_UDMA_3, "XFER_UDMA_3" },
|
|
|
|
{ XFER_UDMA_2, "XFER_UDMA_2" },
|
|
|
|
{ XFER_UDMA_1, "XFER_UDMA_1" },
|
|
|
|
{ XFER_UDMA_0, "XFER_UDMA_0" },
|
|
|
|
{ XFER_MW_DMA_4, "XFER_MW_DMA_4" },
|
|
|
|
{ XFER_MW_DMA_3, "XFER_MW_DMA_3" },
|
|
|
|
{ XFER_MW_DMA_2, "XFER_MW_DMA_2" },
|
|
|
|
{ XFER_MW_DMA_1, "XFER_MW_DMA_1" },
|
|
|
|
{ XFER_MW_DMA_0, "XFER_MW_DMA_0" },
|
|
|
|
{ XFER_SW_DMA_2, "XFER_SW_DMA_2" },
|
|
|
|
{ XFER_SW_DMA_1, "XFER_SW_DMA_1" },
|
|
|
|
{ XFER_SW_DMA_0, "XFER_SW_DMA_0" },
|
|
|
|
{ XFER_PIO_6, "XFER_PIO_6" },
|
|
|
|
{ XFER_PIO_5, "XFER_PIO_5" },
|
|
|
|
{ XFER_PIO_4, "XFER_PIO_4" },
|
|
|
|
{ XFER_PIO_3, "XFER_PIO_3" },
|
|
|
|
{ XFER_PIO_2, "XFER_PIO_2" },
|
|
|
|
{ XFER_PIO_1, "XFER_PIO_1" },
|
|
|
|
{ XFER_PIO_0, "XFER_PIO_0" },
|
|
|
|
{ XFER_PIO_SLOW, "XFER_PIO_SLOW" }
|
|
|
|
};
|
ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files
The {dma|pio}_mode sysfs files are incorrectly documented as having a
list of the supported DMA/PIO transfer modes, while the corresponding
fields of the *struct* ata_device hold the transfer mode IDs, not masks.
To match these docs, the {dma|pio}_mode (and even xfer_mode!) sysfs
files are handled by the ata_bitfield_name_match() macro which leads to
reading such kind of nonsense from them:
$ cat /sys/class/ata_device/dev3.0/pio_mode
XFER_UDMA_7, XFER_UDMA_6, XFER_UDMA_5, XFER_UDMA_4, XFER_MW_DMA_4,
XFER_PIO_6, XFER_PIO_5, XFER_PIO_4, XFER_PIO_3, XFER_PIO_2, XFER_PIO_1,
XFER_PIO_0
Using the correct ata_bitfield_name_search() macro fixes that:
$ cat /sys/class/ata_device/dev3.0/pio_mode
XFER_PIO_4
While fixing the file documentation, somewhat reword the {dma|pio}_mode
file doc and add a note about being mostly useful for PATA devices to
the xfer_mode file doc...
Fixes: d9027470b886 ("[libata] Add ATA transport class")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-08 19:51:07 +00:00
|
|
|
ata_bitfield_name_search(xfer, ata_xfer_names)
|
2010-05-25 19:31:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ATA Port attributes
|
|
|
|
*/
|
|
|
|
#define ata_port_show_simple(field, name, format_string, cast) \
|
|
|
|
static ssize_t \
|
|
|
|
show_ata_port_##name(struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
|
|
|
{ \
|
|
|
|
struct ata_port *ap = transport_class_to_port(dev); \
|
|
|
|
\
|
2020-03-11 07:11:00 +00:00
|
|
|
return scnprintf(buf, 20, format_string, cast ap->field); \
|
2010-05-25 19:31:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ata_port_simple_attr(field, name, format_string, type) \
|
|
|
|
ata_port_show_simple(field, name, format_string, (type)) \
|
|
|
|
static DEVICE_ATTR(name, S_IRUGO, show_ata_port_##name, NULL)
|
|
|
|
|
|
|
|
ata_port_simple_attr(nr_pmp_links, nr_pmp_links, "%d\n", int);
|
|
|
|
ata_port_simple_attr(stats.idle_irq, idle_irq, "%ld\n", unsigned long);
|
2024-07-03 18:44:22 +00:00
|
|
|
/* We want the port_no sysfs attibute to start at 1 (ap->port_no starts at 0) */
|
|
|
|
ata_port_simple_attr(port_no + 1, port_no, "%u\n", unsigned int);
|
2010-05-25 19:31:38 +00:00
|
|
|
|
|
|
|
static DECLARE_TRANSPORT_CLASS(ata_port_class,
|
|
|
|
"ata_port", NULL, NULL, NULL);
|
|
|
|
|
|
|
|
static void ata_tport_release(struct device *dev)
|
|
|
|
{
|
2018-03-09 08:34:41 +00:00
|
|
|
struct ata_port *ap = tdev_to_port(dev);
|
|
|
|
ata_host_put(ap->host);
|
2010-05-25 19:31:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ata_is_port -- check if a struct device represents a ATA port
|
|
|
|
* @dev: device to check
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* %1 if the device represents a ATA Port, %0 else
|
|
|
|
*/
|
2012-04-17 01:04:41 +00:00
|
|
|
static int ata_is_port(const struct device *dev)
|
2010-05-25 19:31:38 +00:00
|
|
|
{
|
|
|
|
return dev->release == ata_tport_release;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ata_tport_match(struct attribute_container *cont,
|
|
|
|
struct device *dev)
|
|
|
|
{
|
|
|
|
if (!ata_is_port(dev))
|
|
|
|
return 0;
|
|
|
|
return &ata_scsi_transport_template->host_attrs.ac == cont;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ata_tport_delete -- remove ATA PORT
|
2021-02-01 14:39:21 +00:00
|
|
|
* @ap: ATA PORT to remove
|
2010-05-25 19:31:38 +00:00
|
|
|
*
|
|
|
|
* Removes the specified ATA PORT. Remove the associated link as well.
|
|
|
|
*/
|
|
|
|
void ata_tport_delete(struct ata_port *ap)
|
|
|
|
{
|
|
|
|
struct device *dev = &ap->tdev;
|
|
|
|
|
|
|
|
ata_tlink_delete(&ap->link);
|
|
|
|
|
|
|
|
transport_remove_device(dev);
|
|
|
|
device_del(dev);
|
|
|
|
transport_destroy_device(dev);
|
|
|
|
put_device(dev);
|
|
|
|
}
|
2024-07-03 18:44:18 +00:00
|
|
|
EXPORT_SYMBOL_GPL(ata_tport_delete);
|
2010-05-25 19:31:38 +00:00
|
|
|
|
2023-09-08 11:04:52 +00:00
|
|
|
static const struct device_type ata_port_sas_type = {
|
|
|
|
.name = ATA_PORT_TYPE_NAME,
|
|
|
|
};
|
|
|
|
|
2010-05-25 19:31:38 +00:00
|
|
|
/** ata_tport_add - initialize a transport ATA port structure
|
|
|
|
*
|
|
|
|
* @parent: parent device
|
|
|
|
* @ap: existing ata_port structure
|
|
|
|
*
|
|
|
|
* Initialize a ATA port structure for sysfs. It will be added to the device
|
|
|
|
* tree below the device specified by @parent which could be a PCI device.
|
|
|
|
*
|
|
|
|
* Returns %0 on success
|
|
|
|
*/
|
|
|
|
int ata_tport_add(struct device *parent,
|
|
|
|
struct ata_port *ap)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct device *dev = &ap->tdev;
|
|
|
|
|
|
|
|
device_initialize(dev);
|
2023-09-08 11:04:52 +00:00
|
|
|
if (ap->flags & ATA_FLAG_SAS_HOST)
|
|
|
|
dev->type = &ata_port_sas_type;
|
|
|
|
else
|
|
|
|
dev->type = &ata_port_type;
|
2010-05-25 19:31:38 +00:00
|
|
|
|
2017-03-03 17:00:09 +00:00
|
|
|
dev->parent = parent;
|
2018-03-09 08:34:41 +00:00
|
|
|
ata_host_get(ap->host);
|
2010-05-25 19:31:38 +00:00
|
|
|
dev->release = ata_tport_release;
|
|
|
|
dev_set_name(dev, "ata%d", ap->print_id);
|
|
|
|
transport_setup_device(dev);
|
ata: acpi: rework the ata acpi bind support
Binding ACPI handle to SCSI device has several drawbacks, namely:
1 During ATA device initialization time, ACPI handle will be needed
while SCSI devices are not created yet. So each time ACPI handle is
needed, instead of retrieving the handle by ACPI_HANDLE macro,
a namespace scan is performed to find the handle for the corresponding
ATA device. This is inefficient, and also expose a restriction on
calling path not holding any lock.
2 The binding to SCSI device tree makes code complex, while at the same
time doesn't bring us any benefit. All ACPI handlings are still done
in ATA module, not in SCSI.
Rework the ATA ACPI binding code to bind ACPI handle to ATA transport
devices(ATA port and ATA device). The binding needs to be done only once,
since the ATA transport devices do not go away with hotplug. And due to
this, the flush_work call in hotplug handler for ATA bay is no longer
needed.
Tested on an Intel test platform for binding and runtime power off for
ODD(ZPODD) and hard disk; on an ASUS S400C for binding and normal boot
and S3, where its SATA port node has _SDD and _GTF control methods when
configured as an AHCI controller and its PATA device node has _GTF
control method when configured as an IDE controller. SATA PMP binding
and ATA hotplug is not tested.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Tested-by: Dirk Griesbach <spamthis@freenet.de>
Signed-off-by: Tejun Heo <tj@kernel.org>
2013-08-23 02:17:54 +00:00
|
|
|
ata_acpi_bind_port(ap);
|
2010-05-25 19:31:38 +00:00
|
|
|
error = device_add(dev);
|
|
|
|
if (error) {
|
|
|
|
goto tport_err;
|
|
|
|
}
|
|
|
|
|
[libata] enable ata port async suspend
This saves devices suspend/resume time.
Tested system suspend/resume with SATA IDE/AHCI mode 3 times.
Below is the time took for devices suspend/resume.
SATA mode vanilla-kernel patched-kernel
--------- --------------------- ---------------------
IDE suspend: 0.744 suspend: 0.432
(0.716, 0.768, 0.748) (0.440, 0.428, 0.428)
resume: 5.084 resume: 2.209
(5.100, 5.064, 5.088) (2.168, 2.232, 2.228)
AHCI: suspend: 0.725 suspend: 0.449
(0.740, 0.708, 0.728) (0.456, 0.448, 0.444)
resume: 2.556 resume: 1.896
(2.604, 2.492, 2.572) (1.932, 1.872, 1.884)
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2012-01-16 05:23:23 +00:00
|
|
|
device_enable_async_suspend(dev);
|
2011-12-05 01:20:28 +00:00
|
|
|
pm_runtime_set_active(dev);
|
|
|
|
pm_runtime_enable(dev);
|
2012-04-18 01:29:47 +00:00
|
|
|
pm_runtime_forbid(dev);
|
2011-12-05 01:20:28 +00:00
|
|
|
|
2022-11-08 13:40:02 +00:00
|
|
|
error = transport_add_device(dev);
|
|
|
|
if (error)
|
|
|
|
goto tport_transport_add_err;
|
2010-05-25 19:31:38 +00:00
|
|
|
transport_configure_device(dev);
|
|
|
|
|
|
|
|
error = ata_tlink_add(&ap->link);
|
|
|
|
if (error) {
|
|
|
|
goto tport_link_err;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
tport_link_err:
|
|
|
|
transport_remove_device(dev);
|
2022-11-08 13:40:02 +00:00
|
|
|
tport_transport_add_err:
|
2010-05-25 19:31:38 +00:00
|
|
|
device_del(dev);
|
|
|
|
|
|
|
|
tport_err:
|
|
|
|
transport_destroy_device(dev);
|
|
|
|
put_device(dev);
|
|
|
|
return error;
|
|
|
|
}
|
2024-07-03 18:44:18 +00:00
|
|
|
EXPORT_SYMBOL_GPL(ata_tport_add);
|
2010-05-25 19:31:38 +00:00
|
|
|
|
2021-12-21 07:20:26 +00:00
|
|
|
/**
|
|
|
|
* ata_port_classify - determine device type based on ATA-spec signature
|
|
|
|
* @ap: ATA port device on which the classification should be run
|
|
|
|
* @tf: ATA taskfile register set for device to be identified
|
|
|
|
*
|
|
|
|
* A wrapper around ata_dev_classify() to provide additional logging
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
* Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP,
|
|
|
|
* %ATA_DEV_ZAC, or %ATA_DEV_UNKNOWN the event of failure.
|
|
|
|
*/
|
|
|
|
unsigned int ata_port_classify(struct ata_port *ap,
|
|
|
|
const struct ata_taskfile *tf)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned int class = ata_dev_classify(tf);
|
|
|
|
|
|
|
|
/* Start with index '1' to skip the 'unknown' entry */
|
|
|
|
for (i = 1; i < ARRAY_SIZE(ata_class_names); i++) {
|
|
|
|
if (ata_class_names[i].value == class) {
|
|
|
|
ata_port_dbg(ap, "found %s device by sig\n",
|
|
|
|
ata_class_names[i].name);
|
|
|
|
return class;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ata_port_info(ap, "found unknown device (class %u)\n", class);
|
|
|
|
return class;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(ata_port_classify);
|
2010-05-25 19:31:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ATA device attributes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define ata_dev_show_class(title, field) \
|
|
|
|
static ssize_t \
|
|
|
|
show_ata_dev_##field(struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
|
|
|
{ \
|
|
|
|
struct ata_device *ata_dev = transport_class_to_dev(dev); \
|
|
|
|
\
|
|
|
|
return get_ata_##title##_names(ata_dev->field, buf); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ata_dev_attr(title, field) \
|
|
|
|
ata_dev_show_class(title, field) \
|
|
|
|
static DEVICE_ATTR(field, S_IRUGO, show_ata_dev_##field, NULL)
|
|
|
|
|
|
|
|
ata_dev_attr(class, class);
|
|
|
|
ata_dev_attr(xfer, pio_mode);
|
|
|
|
ata_dev_attr(xfer, dma_mode);
|
|
|
|
ata_dev_attr(xfer, xfer_mode);
|
|
|
|
|
|
|
|
|
2021-12-21 07:20:25 +00:00
|
|
|
#define ata_dev_show_simple(field, format_string, cast) \
|
2010-05-25 19:31:38 +00:00
|
|
|
static ssize_t \
|
|
|
|
show_ata_dev_##field(struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
|
|
|
{ \
|
|
|
|
struct ata_device *ata_dev = transport_class_to_dev(dev); \
|
|
|
|
\
|
2020-03-11 07:11:00 +00:00
|
|
|
return scnprintf(buf, 20, format_string, cast ata_dev->field); \
|
2010-05-25 19:31:38 +00:00
|
|
|
}
|
|
|
|
|
2021-12-21 07:20:25 +00:00
|
|
|
#define ata_dev_simple_attr(field, format_string, type) \
|
2010-05-25 19:31:38 +00:00
|
|
|
ata_dev_show_simple(field, format_string, (type)) \
|
2021-12-21 07:20:25 +00:00
|
|
|
static DEVICE_ATTR(field, S_IRUGO, \
|
2010-05-25 19:31:38 +00:00
|
|
|
show_ata_dev_##field, NULL)
|
|
|
|
|
|
|
|
ata_dev_simple_attr(spdn_cnt, "%d\n", int);
|
|
|
|
|
|
|
|
struct ata_show_ering_arg {
|
|
|
|
char* buf;
|
|
|
|
int written;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int ata_show_ering(struct ata_ering_entry *ent, void *void_arg)
|
|
|
|
{
|
|
|
|
struct ata_show_ering_arg* arg = void_arg;
|
2016-06-17 15:37:12 +00:00
|
|
|
u64 seconds;
|
|
|
|
u32 rem;
|
2010-05-25 19:31:38 +00:00
|
|
|
|
2016-06-17 15:37:12 +00:00
|
|
|
seconds = div_u64_rem(ent->timestamp, HZ, &rem);
|
2010-05-25 19:31:38 +00:00
|
|
|
arg->written += sprintf(arg->buf + arg->written,
|
2021-12-21 07:20:25 +00:00
|
|
|
"[%5llu.%09lu]", seconds,
|
2016-06-17 15:37:12 +00:00
|
|
|
rem * NSEC_PER_SEC / HZ);
|
2010-05-25 19:31:38 +00:00
|
|
|
arg->written += get_ata_err_names(ent->err_mask,
|
|
|
|
arg->buf + arg->written);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
show_ata_dev_ering(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct ata_device *ata_dev = transport_class_to_dev(dev);
|
|
|
|
struct ata_show_ering_arg arg = { buf, 0 };
|
|
|
|
|
|
|
|
ata_ering_map(&ata_dev->ering, ata_show_ering, &arg);
|
|
|
|
return arg.written;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static DEVICE_ATTR(ering, S_IRUGO, show_ata_dev_ering, NULL);
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
show_ata_dev_id(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct ata_device *ata_dev = transport_class_to_dev(dev);
|
|
|
|
int written = 0, i = 0;
|
|
|
|
|
|
|
|
if (ata_dev->class == ATA_DEV_PMP)
|
|
|
|
return 0;
|
|
|
|
for(i=0;i<ATA_ID_WORDS;i++) {
|
2020-03-11 07:11:00 +00:00
|
|
|
written += scnprintf(buf+written, 20, "%04x%c",
|
2010-05-25 19:31:38 +00:00
|
|
|
ata_dev->id[i],
|
|
|
|
((i+1) & 7) ? ' ' : '\n');
|
|
|
|
}
|
|
|
|
return written;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(id, S_IRUGO, show_ata_dev_id, NULL);
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
show_ata_dev_gscr(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct ata_device *ata_dev = transport_class_to_dev(dev);
|
|
|
|
int written = 0, i = 0;
|
|
|
|
|
|
|
|
if (ata_dev->class != ATA_DEV_PMP)
|
|
|
|
return 0;
|
|
|
|
for(i=0;i<SATA_PMP_GSCR_DWORDS;i++) {
|
2020-03-11 07:11:00 +00:00
|
|
|
written += scnprintf(buf+written, 20, "%08x%c",
|
2010-05-25 19:31:38 +00:00
|
|
|
ata_dev->gscr[i],
|
|
|
|
((i+1) & 3) ? ' ' : '\n');
|
|
|
|
}
|
|
|
|
if (SATA_PMP_GSCR_DWORDS & 3)
|
|
|
|
buf[written-1] = '\n';
|
|
|
|
return written;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(gscr, S_IRUGO, show_ata_dev_gscr, NULL);
|
|
|
|
|
2015-05-05 01:54:19 +00:00
|
|
|
static ssize_t
|
|
|
|
show_ata_dev_trim(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct ata_device *ata_dev = transport_class_to_dev(dev);
|
|
|
|
unsigned char *mode;
|
|
|
|
|
|
|
|
if (!ata_id_has_trim(ata_dev->id))
|
|
|
|
mode = "unsupported";
|
2024-07-18 07:59:06 +00:00
|
|
|
else if (ata_dev->quirks & ATA_QUIRK_NOTRIM)
|
2015-07-15 11:54:36 +00:00
|
|
|
mode = "forced_unsupported";
|
2024-07-18 07:59:06 +00:00
|
|
|
else if (ata_dev->quirks & ATA_QUIRK_NO_NCQ_TRIM)
|
|
|
|
mode = "forced_unqueued";
|
2015-05-05 01:54:19 +00:00
|
|
|
else if (ata_fpdma_dsm_supported(ata_dev))
|
|
|
|
mode = "queued";
|
|
|
|
else
|
|
|
|
mode = "unqueued";
|
|
|
|
|
2020-03-11 07:11:00 +00:00
|
|
|
return scnprintf(buf, 20, "%s\n", mode);
|
2015-05-05 01:54:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(trim, S_IRUGO, show_ata_dev_trim, NULL);
|
|
|
|
|
2010-05-25 19:31:38 +00:00
|
|
|
static DECLARE_TRANSPORT_CLASS(ata_dev_class,
|
|
|
|
"ata_device", NULL, NULL, NULL);
|
|
|
|
|
|
|
|
static void ata_tdev_release(struct device *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ata_is_ata_dev -- check if a struct device represents a ATA device
|
|
|
|
* @dev: device to check
|
|
|
|
*
|
|
|
|
* Returns:
|
2024-08-19 02:32:15 +00:00
|
|
|
* true if the device represents a ATA device, false otherwise
|
2010-05-25 19:31:38 +00:00
|
|
|
*/
|
2024-08-19 02:32:15 +00:00
|
|
|
static bool ata_is_ata_dev(const struct device *dev)
|
2010-05-25 19:31:38 +00:00
|
|
|
{
|
|
|
|
return dev->release == ata_tdev_release;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ata_tdev_match(struct attribute_container *cont,
|
|
|
|
struct device *dev)
|
|
|
|
{
|
2024-08-19 02:32:15 +00:00
|
|
|
struct ata_internal *i = to_ata_internal(ata_scsi_transport_template);
|
|
|
|
|
2010-05-25 19:31:38 +00:00
|
|
|
if (!ata_is_ata_dev(dev))
|
|
|
|
return 0;
|
|
|
|
return &i->dev_attr_cont.ac == cont;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-08-19 02:32:15 +00:00
|
|
|
* ata_tdev_free -- free an ATA transport device
|
|
|
|
* @dev: struct ata_device owning the transport device to free
|
2010-05-25 19:31:38 +00:00
|
|
|
*
|
2024-08-19 02:32:15 +00:00
|
|
|
* Free the ATA transport device for the specified ATA device.
|
2010-05-25 19:31:38 +00:00
|
|
|
*
|
|
|
|
* Note:
|
2024-08-19 02:32:15 +00:00
|
|
|
* This function must only be called for a ATA transport device that has not
|
|
|
|
* yet successfully been added using ata_tdev_add().
|
2010-05-25 19:31:38 +00:00
|
|
|
*/
|
|
|
|
static void ata_tdev_free(struct ata_device *dev)
|
|
|
|
{
|
|
|
|
transport_destroy_device(&dev->tdev);
|
|
|
|
put_device(&dev->tdev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-08-19 02:32:15 +00:00
|
|
|
* ata_tdev_delete -- remove an ATA transport device
|
|
|
|
* @ata_dev: struct ata_device owning the transport device to delete
|
2010-05-25 19:31:38 +00:00
|
|
|
*
|
2024-08-19 02:32:15 +00:00
|
|
|
* Removes the ATA transport device for the specified ATA device.
|
2010-05-25 19:31:38 +00:00
|
|
|
*/
|
|
|
|
static void ata_tdev_delete(struct ata_device *ata_dev)
|
|
|
|
{
|
|
|
|
struct device *dev = &ata_dev->tdev;
|
|
|
|
|
|
|
|
transport_remove_device(dev);
|
|
|
|
device_del(dev);
|
|
|
|
ata_tdev_free(ata_dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-08-19 02:32:15 +00:00
|
|
|
* ata_tdev_add -- initialize an ATA transport device
|
|
|
|
* @ata_dev: struct ata_device owning the transport device to add
|
2010-05-25 19:31:38 +00:00
|
|
|
*
|
2024-08-19 02:32:15 +00:00
|
|
|
* Initialize an ATA transport device for sysfs. It will be added in the
|
|
|
|
* device tree below the ATA link device it belongs to.
|
2010-05-25 19:31:38 +00:00
|
|
|
*
|
2024-08-19 02:32:15 +00:00
|
|
|
* Returns %0 on success and a negative error code on error.
|
2010-05-25 19:31:38 +00:00
|
|
|
*/
|
|
|
|
static int ata_tdev_add(struct ata_device *ata_dev)
|
|
|
|
{
|
|
|
|
struct device *dev = &ata_dev->tdev;
|
|
|
|
struct ata_link *link = ata_dev->link;
|
|
|
|
struct ata_port *ap = link->ap;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
device_initialize(dev);
|
2017-03-03 17:00:09 +00:00
|
|
|
dev->parent = &link->tdev;
|
2010-05-25 19:31:38 +00:00
|
|
|
dev->release = ata_tdev_release;
|
|
|
|
if (ata_is_host_link(link))
|
|
|
|
dev_set_name(dev, "dev%d.%d", ap->print_id,ata_dev->devno);
|
2021-12-21 07:20:25 +00:00
|
|
|
else
|
2010-05-25 19:31:38 +00:00
|
|
|
dev_set_name(dev, "dev%d.%d.0", ap->print_id, link->pmp);
|
|
|
|
|
|
|
|
transport_setup_device(dev);
|
ata: acpi: rework the ata acpi bind support
Binding ACPI handle to SCSI device has several drawbacks, namely:
1 During ATA device initialization time, ACPI handle will be needed
while SCSI devices are not created yet. So each time ACPI handle is
needed, instead of retrieving the handle by ACPI_HANDLE macro,
a namespace scan is performed to find the handle for the corresponding
ATA device. This is inefficient, and also expose a restriction on
calling path not holding any lock.
2 The binding to SCSI device tree makes code complex, while at the same
time doesn't bring us any benefit. All ACPI handlings are still done
in ATA module, not in SCSI.
Rework the ATA ACPI binding code to bind ACPI handle to ATA transport
devices(ATA port and ATA device). The binding needs to be done only once,
since the ATA transport devices do not go away with hotplug. And due to
this, the flush_work call in hotplug handler for ATA bay is no longer
needed.
Tested on an Intel test platform for binding and runtime power off for
ODD(ZPODD) and hard disk; on an ASUS S400C for binding and normal boot
and S3, where its SATA port node has _SDD and _GTF control methods when
configured as an AHCI controller and its PATA device node has _GTF
control method when configured as an IDE controller. SATA PMP binding
and ATA hotplug is not tested.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Tested-by: Dirk Griesbach <spamthis@freenet.de>
Signed-off-by: Tejun Heo <tj@kernel.org>
2013-08-23 02:17:54 +00:00
|
|
|
ata_acpi_bind_dev(ata_dev);
|
2010-05-25 19:31:38 +00:00
|
|
|
error = device_add(dev);
|
|
|
|
if (error) {
|
|
|
|
ata_tdev_free(ata_dev);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2022-11-08 13:40:04 +00:00
|
|
|
error = transport_add_device(dev);
|
|
|
|
if (error) {
|
|
|
|
device_del(dev);
|
|
|
|
ata_tdev_free(ata_dev);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2010-05-25 19:31:38 +00:00
|
|
|
transport_configure_device(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-08-19 02:32:15 +00:00
|
|
|
/*
|
|
|
|
* ATA link attributes
|
|
|
|
*/
|
|
|
|
static int noop(int x)
|
|
|
|
{
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ata_link_show_linkspeed(field, format) \
|
|
|
|
static ssize_t \
|
|
|
|
show_ata_link_##field(struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
|
|
|
{ \
|
|
|
|
struct ata_link *link = transport_class_to_link(dev); \
|
|
|
|
\
|
|
|
|
return sprintf(buf, "%s\n", \
|
|
|
|
sata_spd_string(format(link->field))); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ata_link_linkspeed_attr(field, format) \
|
|
|
|
ata_link_show_linkspeed(field, format) \
|
|
|
|
static DEVICE_ATTR(field, 0444, show_ata_link_##field, NULL)
|
|
|
|
|
|
|
|
ata_link_linkspeed_attr(hw_sata_spd_limit, fls);
|
|
|
|
ata_link_linkspeed_attr(sata_spd_limit, fls);
|
|
|
|
ata_link_linkspeed_attr(sata_spd, noop);
|
|
|
|
|
|
|
|
static DECLARE_TRANSPORT_CLASS(ata_link_class,
|
|
|
|
"ata_link", NULL, NULL, NULL);
|
|
|
|
|
|
|
|
static void ata_tlink_release(struct device *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ata_is_link -- check if a struct device represents a ATA link
|
|
|
|
* @dev: device to check
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* true if the device represents a ATA link, false otherwise
|
|
|
|
*/
|
|
|
|
static bool ata_is_link(const struct device *dev)
|
|
|
|
{
|
|
|
|
return dev->release == ata_tlink_release;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ata_tlink_match(struct attribute_container *cont,
|
|
|
|
struct device *dev)
|
|
|
|
{
|
|
|
|
struct ata_internal *i = to_ata_internal(ata_scsi_transport_template);
|
|
|
|
|
|
|
|
if (!ata_is_link(dev))
|
|
|
|
return 0;
|
|
|
|
return &i->link_attr_cont.ac == cont;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ata_tlink_delete -- remove an ATA link transport device
|
|
|
|
* @link: struct ata_link owning the link transport device to remove
|
|
|
|
*
|
|
|
|
* Removes the link transport device of the specified ATA link. This also
|
|
|
|
* removes the ATA device(s) associated with the link as well.
|
|
|
|
*/
|
|
|
|
void ata_tlink_delete(struct ata_link *link)
|
|
|
|
{
|
|
|
|
struct device *dev = &link->tdev;
|
|
|
|
struct ata_device *ata_dev;
|
|
|
|
|
|
|
|
ata_for_each_dev(ata_dev, link, ALL) {
|
|
|
|
ata_tdev_delete(ata_dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
transport_remove_device(dev);
|
|
|
|
device_del(dev);
|
|
|
|
transport_destroy_device(dev);
|
|
|
|
put_device(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ata_tlink_add -- initialize an ATA link transport device
|
2024-09-07 01:56:32 +00:00
|
|
|
* @link: struct ata_link owning the link transport device to initialize
|
2024-08-19 02:32:15 +00:00
|
|
|
*
|
|
|
|
* Initialize an ATA link transport device for sysfs. It will be added in the
|
|
|
|
* device tree below the ATA port it belongs to.
|
|
|
|
*
|
|
|
|
* Returns %0 on success and a negative error code on error.
|
|
|
|
*/
|
|
|
|
int ata_tlink_add(struct ata_link *link)
|
|
|
|
{
|
|
|
|
struct device *dev = &link->tdev;
|
|
|
|
struct ata_port *ap = link->ap;
|
|
|
|
struct ata_device *ata_dev;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
device_initialize(dev);
|
|
|
|
dev->parent = &ap->tdev;
|
|
|
|
dev->release = ata_tlink_release;
|
|
|
|
if (ata_is_host_link(link))
|
|
|
|
dev_set_name(dev, "link%d", ap->print_id);
|
|
|
|
else
|
|
|
|
dev_set_name(dev, "link%d.%d", ap->print_id, link->pmp);
|
|
|
|
|
|
|
|
transport_setup_device(dev);
|
|
|
|
|
|
|
|
error = device_add(dev);
|
|
|
|
if (error)
|
|
|
|
goto tlink_err;
|
|
|
|
|
|
|
|
error = transport_add_device(dev);
|
|
|
|
if (error)
|
|
|
|
goto tlink_transport_err;
|
|
|
|
transport_configure_device(dev);
|
|
|
|
|
|
|
|
ata_for_each_dev(ata_dev, link, ALL) {
|
|
|
|
error = ata_tdev_add(ata_dev);
|
|
|
|
if (error)
|
|
|
|
goto tlink_dev_err;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
tlink_dev_err:
|
|
|
|
while (--ata_dev >= link->device)
|
|
|
|
ata_tdev_delete(ata_dev);
|
|
|
|
transport_remove_device(dev);
|
|
|
|
tlink_transport_err:
|
|
|
|
device_del(dev);
|
|
|
|
tlink_err:
|
|
|
|
transport_destroy_device(dev);
|
|
|
|
put_device(dev);
|
|
|
|
return error;
|
|
|
|
}
|
2010-05-25 19:31:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup / Teardown code
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SETUP_TEMPLATE(attrb, field, perm, test) \
|
2021-12-21 07:20:25 +00:00
|
|
|
i->private_##attrb[count] = dev_attr_##field; \
|
2010-05-25 19:31:38 +00:00
|
|
|
i->private_##attrb[count].attr.mode = perm; \
|
|
|
|
i->attrb[count] = &i->private_##attrb[count]; \
|
|
|
|
if (test) \
|
|
|
|
count++
|
|
|
|
|
|
|
|
#define SETUP_LINK_ATTRIBUTE(field) \
|
|
|
|
SETUP_TEMPLATE(link_attrs, field, S_IRUGO, 1)
|
|
|
|
|
|
|
|
#define SETUP_PORT_ATTRIBUTE(field) \
|
|
|
|
SETUP_TEMPLATE(port_attrs, field, S_IRUGO, 1)
|
|
|
|
|
|
|
|
#define SETUP_DEV_ATTRIBUTE(field) \
|
|
|
|
SETUP_TEMPLATE(dev_attrs, field, S_IRUGO, 1)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ata_attach_transport -- instantiate ATA transport template
|
|
|
|
*/
|
|
|
|
struct scsi_transport_template *ata_attach_transport(void)
|
|
|
|
{
|
|
|
|
struct ata_internal *i;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
i = kzalloc(sizeof(struct ata_internal), GFP_KERNEL);
|
|
|
|
if (!i)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
i->t.eh_strategy_handler = ata_scsi_error;
|
|
|
|
i->t.user_scan = ata_scsi_user_scan;
|
|
|
|
|
|
|
|
i->t.host_attrs.ac.attrs = &i->port_attrs[0];
|
|
|
|
i->t.host_attrs.ac.class = &ata_port_class.class;
|
|
|
|
i->t.host_attrs.ac.match = ata_tport_match;
|
|
|
|
transport_container_register(&i->t.host_attrs);
|
|
|
|
|
|
|
|
i->link_attr_cont.ac.class = &ata_link_class.class;
|
|
|
|
i->link_attr_cont.ac.attrs = &i->link_attrs[0];
|
|
|
|
i->link_attr_cont.ac.match = ata_tlink_match;
|
|
|
|
transport_container_register(&i->link_attr_cont);
|
|
|
|
|
|
|
|
i->dev_attr_cont.ac.class = &ata_dev_class.class;
|
|
|
|
i->dev_attr_cont.ac.attrs = &i->dev_attrs[0];
|
|
|
|
i->dev_attr_cont.ac.match = ata_tdev_match;
|
|
|
|
transport_container_register(&i->dev_attr_cont);
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
SETUP_PORT_ATTRIBUTE(nr_pmp_links);
|
|
|
|
SETUP_PORT_ATTRIBUTE(idle_irq);
|
2013-05-14 18:48:40 +00:00
|
|
|
SETUP_PORT_ATTRIBUTE(port_no);
|
2010-05-25 19:31:38 +00:00
|
|
|
BUG_ON(count > ATA_PORT_ATTRS);
|
|
|
|
i->port_attrs[count] = NULL;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
SETUP_LINK_ATTRIBUTE(hw_sata_spd_limit);
|
|
|
|
SETUP_LINK_ATTRIBUTE(sata_spd_limit);
|
|
|
|
SETUP_LINK_ATTRIBUTE(sata_spd);
|
|
|
|
BUG_ON(count > ATA_LINK_ATTRS);
|
|
|
|
i->link_attrs[count] = NULL;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
SETUP_DEV_ATTRIBUTE(class);
|
|
|
|
SETUP_DEV_ATTRIBUTE(pio_mode);
|
|
|
|
SETUP_DEV_ATTRIBUTE(dma_mode);
|
|
|
|
SETUP_DEV_ATTRIBUTE(xfer_mode);
|
|
|
|
SETUP_DEV_ATTRIBUTE(spdn_cnt);
|
|
|
|
SETUP_DEV_ATTRIBUTE(ering);
|
|
|
|
SETUP_DEV_ATTRIBUTE(id);
|
|
|
|
SETUP_DEV_ATTRIBUTE(gscr);
|
2015-05-05 01:54:19 +00:00
|
|
|
SETUP_DEV_ATTRIBUTE(trim);
|
2010-05-25 19:31:38 +00:00
|
|
|
BUG_ON(count > ATA_DEV_ATTRS);
|
|
|
|
i->dev_attrs[count] = NULL;
|
|
|
|
|
|
|
|
return &i->t;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ata_release_transport -- release ATA transport template instance
|
|
|
|
* @t: transport template instance
|
|
|
|
*/
|
|
|
|
void ata_release_transport(struct scsi_transport_template *t)
|
|
|
|
{
|
|
|
|
struct ata_internal *i = to_ata_internal(t);
|
|
|
|
|
|
|
|
transport_container_unregister(&i->t.host_attrs);
|
|
|
|
transport_container_unregister(&i->link_attr_cont);
|
|
|
|
transport_container_unregister(&i->dev_attr_cont);
|
|
|
|
|
|
|
|
kfree(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
__init int libata_transport_init(void)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = transport_class_register(&ata_link_class);
|
|
|
|
if (error)
|
|
|
|
goto out_unregister_transport;
|
|
|
|
error = transport_class_register(&ata_port_class);
|
|
|
|
if (error)
|
|
|
|
goto out_unregister_link;
|
|
|
|
error = transport_class_register(&ata_dev_class);
|
|
|
|
if (error)
|
|
|
|
goto out_unregister_port;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_unregister_port:
|
|
|
|
transport_class_unregister(&ata_port_class);
|
|
|
|
out_unregister_link:
|
|
|
|
transport_class_unregister(&ata_link_class);
|
|
|
|
out_unregister_transport:
|
|
|
|
return error;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void __exit libata_transport_exit(void)
|
|
|
|
{
|
|
|
|
transport_class_unregister(&ata_link_class);
|
|
|
|
transport_class_unregister(&ata_port_class);
|
|
|
|
transport_class_unregister(&ata_dev_class);
|
|
|
|
}
|