aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@google.com>2010-05-25 15:31:38 -0400
committerJeff Garzik <jgarzik@redhat.com>2010-10-21 20:21:03 -0400
commitd9027470b88631d0956ac37cdadfdeb9cdcf2c99 (patch)
treeb15273e88431ba734a24965dfc81132ac13bc8bd /drivers/ata/libata-core.c
parentf6f94e2ab1b33f0082ac22d71f66385a60d8157f (diff)
[libata] Add ATA transport class
This is a scheleton for libata transport class. All information is read only, exporting information from libata: - ata_port class: one per ATA port - ata_link class: one per ATA port or 15 for SATA Port Multiplier - ata_device class: up to 2 for PATA link, usually one for SATA. Signed-off-by: Gwendal Grignou <gwendal@google.com> Reviewed-by: Grant Grundler <grundler@google.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r--drivers/ata/libata-core.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 932eaee5024..4012b33e8b8 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -68,7 +68,7 @@
68#include <linux/ratelimit.h> 68#include <linux/ratelimit.h>
69 69
70#include "libata.h" 70#include "libata.h"
71 71#include "libata-transport.h"
72 72
73/* debounce timing parameters in msecs { interval, duration, timeout } */ 73/* debounce timing parameters in msecs { interval, duration, timeout } */
74const unsigned long sata_deb_timing_normal[] = { 5, 100, 2000 }; 74const unsigned long sata_deb_timing_normal[] = { 5, 100, 2000 };
@@ -1017,7 +1017,7 @@ const char *ata_mode_string(unsigned long xfer_mask)
1017 return "<n/a>"; 1017 return "<n/a>";
1018} 1018}
1019 1019
1020static const char *sata_spd_string(unsigned int spd) 1020const char *sata_spd_string(unsigned int spd)
1021{ 1021{
1022 static const char * const spd_str[] = { 1022 static const char * const spd_str[] = {
1023 "1.5 Gbps", 1023 "1.5 Gbps",
@@ -5517,7 +5517,8 @@ void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp)
5517 int i; 5517 int i;
5518 5518
5519 /* clear everything except for devices */ 5519 /* clear everything except for devices */
5520 memset(link, 0, offsetof(struct ata_link, device[0])); 5520 memset((void *)link + ATA_LINK_CLEAR_BEGIN, 0,
5521 ATA_LINK_CLEAR_END - ATA_LINK_CLEAR_BEGIN);
5521 5522
5522 link->ap = ap; 5523 link->ap = ap;
5523 link->pmp = pmp; 5524 link->pmp = pmp;
@@ -5591,7 +5592,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
5591 ap = kzalloc(sizeof(*ap), GFP_KERNEL); 5592 ap = kzalloc(sizeof(*ap), GFP_KERNEL);
5592 if (!ap) 5593 if (!ap)
5593 return NULL; 5594 return NULL;
5594 5595
5595 ap->pflags |= ATA_PFLAG_INITIALIZING; 5596 ap->pflags |= ATA_PFLAG_INITIALIZING;
5596 ap->lock = &host->lock; 5597 ap->lock = &host->lock;
5597 ap->print_id = -1; 5598 ap->print_id = -1;
@@ -6093,9 +6094,18 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
6093 for (i = 0; i < host->n_ports; i++) 6094 for (i = 0; i < host->n_ports; i++)
6094 host->ports[i]->print_id = ata_print_id++; 6095 host->ports[i]->print_id = ata_print_id++;
6095 6096
6097
6098 /* Create associated sysfs transport objects */
6099 for (i = 0; i < host->n_ports; i++) {
6100 rc = ata_tport_add(host->dev,host->ports[i]);
6101 if (rc) {
6102 goto err_tadd;
6103 }
6104 }
6105
6096 rc = ata_scsi_add_hosts(host, sht); 6106 rc = ata_scsi_add_hosts(host, sht);
6097 if (rc) 6107 if (rc)
6098 return rc; 6108 goto err_tadd;
6099 6109
6100 /* associate with ACPI nodes */ 6110 /* associate with ACPI nodes */
6101 ata_acpi_associate(host); 6111 ata_acpi_associate(host);
@@ -6136,6 +6146,13 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
6136 } 6146 }
6137 6147
6138 return 0; 6148 return 0;
6149
6150 err_tadd:
6151 while (--i >= 0) {
6152 ata_tport_delete(host->ports[i]);
6153 }
6154 return rc;
6155
6139} 6156}
6140 6157
6141/** 6158/**
@@ -6226,6 +6243,13 @@ static void ata_port_detach(struct ata_port *ap)
6226 cancel_rearming_delayed_work(&ap->hotplug_task); 6243 cancel_rearming_delayed_work(&ap->hotplug_task);
6227 6244
6228 skip_eh: 6245 skip_eh:
6246 if (ap->pmp_link) {
6247 int i;
6248 for (i = 0; i < SATA_PMP_MAX_PORTS; i++)
6249 ata_tlink_delete(&ap->pmp_link[i]);
6250 }
6251 ata_tport_delete(ap);
6252
6229 /* remove the associated SCSI host */ 6253 /* remove the associated SCSI host */
6230 scsi_remove_host(ap->scsi_host); 6254 scsi_remove_host(ap->scsi_host);
6231} 6255}
@@ -6542,7 +6566,7 @@ static void __init ata_parse_force_param(void)
6542 6566
6543static int __init ata_init(void) 6567static int __init ata_init(void)
6544{ 6568{
6545 int rc = -ENOMEM; 6569 int rc;
6546 6570
6547 ata_parse_force_param(); 6571 ata_parse_force_param();
6548 6572
@@ -6552,12 +6576,25 @@ static int __init ata_init(void)
6552 return rc; 6576 return rc;
6553 } 6577 }
6554 6578
6579 libata_transport_init();
6580 ata_scsi_transport_template = ata_attach_transport();
6581 if (!ata_scsi_transport_template) {
6582 ata_sff_exit();
6583 rc = -ENOMEM;
6584 goto err_out;
6585 }
6586
6555 printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n"); 6587 printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n");
6556 return 0; 6588 return 0;
6589
6590err_out:
6591 return rc;
6557} 6592}
6558 6593
6559static void __exit ata_exit(void) 6594static void __exit ata_exit(void)
6560{ 6595{
6596 ata_release_transport(ata_scsi_transport_template);
6597 libata_transport_exit();
6561 ata_sff_exit(); 6598 ata_sff_exit();
6562 kfree(ata_force_tbl); 6599 kfree(ata_force_tbl);
6563} 6600}