diff options
author | Tejun Heo <htejun@gmail.com> | 2007-08-06 05:36:23 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-10-12 14:55:31 -0400 |
commit | 4fb37a25b976e8d1b34461330b3f2c6d9b94c133 (patch) | |
tree | ab3086480897077f434e4a1a217f0251e3428782 /drivers/ata/libata-core.c | |
parent | 0c88758b5a6325428aaadab619886242db20ceae (diff) |
libata-link: separate out link initialization functions
Separate out link initialization into ata_link_init() and
ata_link_init_sata_spd().
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r-- | drivers/ata/libata-core.c | 84 |
1 files changed, 64 insertions, 20 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 2be30c7a2226..3da642bd2ee2 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -6061,6 +6061,68 @@ void ata_dev_init(struct ata_device *dev) | |||
6061 | } | 6061 | } |
6062 | 6062 | ||
6063 | /** | 6063 | /** |
6064 | * ata_link_init - Initialize an ata_link structure | ||
6065 | * @ap: ATA port link is attached to | ||
6066 | * @link: Link structure to initialize | ||
6067 | * | ||
6068 | * Initialize @link. | ||
6069 | * | ||
6070 | * LOCKING: | ||
6071 | * Kernel thread context (may sleep) | ||
6072 | */ | ||
6073 | static void ata_link_init(struct ata_port *ap, struct ata_link *link) | ||
6074 | { | ||
6075 | int i; | ||
6076 | |||
6077 | /* clear everything except for devices */ | ||
6078 | memset(link, 0, offsetof(struct ata_link, device[0])); | ||
6079 | |||
6080 | link->ap = ap; | ||
6081 | link->active_tag = ATA_TAG_POISON; | ||
6082 | link->hw_sata_spd_limit = UINT_MAX; | ||
6083 | |||
6084 | /* can't use iterator, ap isn't initialized yet */ | ||
6085 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | ||
6086 | struct ata_device *dev = &link->device[i]; | ||
6087 | |||
6088 | dev->link = link; | ||
6089 | dev->devno = dev - link->device; | ||
6090 | ata_dev_init(dev); | ||
6091 | } | ||
6092 | } | ||
6093 | |||
6094 | /** | ||
6095 | * sata_link_init_spd - Initialize link->sata_spd_limit | ||
6096 | * @link: Link to configure sata_spd_limit for | ||
6097 | * | ||
6098 | * Initialize @link->[hw_]sata_spd_limit to the currently | ||
6099 | * configured value. | ||
6100 | * | ||
6101 | * LOCKING: | ||
6102 | * Kernel thread context (may sleep). | ||
6103 | * | ||
6104 | * RETURNS: | ||
6105 | * 0 on success, -errno on failure. | ||
6106 | */ | ||
6107 | static int sata_link_init_spd(struct ata_link *link) | ||
6108 | { | ||
6109 | u32 scontrol, spd; | ||
6110 | int rc; | ||
6111 | |||
6112 | rc = sata_scr_read(link, SCR_CONTROL, &scontrol); | ||
6113 | if (rc) | ||
6114 | return rc; | ||
6115 | |||
6116 | spd = (scontrol >> 4) & 0xf; | ||
6117 | if (spd) | ||
6118 | link->hw_sata_spd_limit &= (1 << spd) - 1; | ||
6119 | |||
6120 | link->sata_spd_limit = link->hw_sata_spd_limit; | ||
6121 | |||
6122 | return 0; | ||
6123 | } | ||
6124 | |||
6125 | /** | ||
6064 | * ata_port_alloc - allocate and initialize basic ATA port resources | 6126 | * ata_port_alloc - allocate and initialize basic ATA port resources |
6065 | * @host: ATA host this allocated port belongs to | 6127 | * @host: ATA host this allocated port belongs to |
6066 | * | 6128 | * |
@@ -6075,7 +6137,6 @@ void ata_dev_init(struct ata_device *dev) | |||
6075 | struct ata_port *ata_port_alloc(struct ata_host *host) | 6137 | struct ata_port *ata_port_alloc(struct ata_host *host) |
6076 | { | 6138 | { |
6077 | struct ata_port *ap; | 6139 | struct ata_port *ap; |
6078 | unsigned int i; | ||
6079 | 6140 | ||
6080 | DPRINTK("ENTER\n"); | 6141 | DPRINTK("ENTER\n"); |
6081 | 6142 | ||
@@ -6090,9 +6151,6 @@ struct ata_port *ata_port_alloc(struct ata_host *host) | |||
6090 | ap->ctl = ATA_DEVCTL_OBS; | 6151 | ap->ctl = ATA_DEVCTL_OBS; |
6091 | ap->host = host; | 6152 | ap->host = host; |
6092 | ap->dev = host->dev; | 6153 | ap->dev = host->dev; |
6093 | |||
6094 | ap->link.hw_sata_spd_limit = UINT_MAX; | ||
6095 | ap->link.active_tag = ATA_TAG_POISON; | ||
6096 | ap->last_ctl = 0xFF; | 6154 | ap->last_ctl = 0xFF; |
6097 | 6155 | ||
6098 | #if defined(ATA_VERBOSE_DEBUG) | 6156 | #if defined(ATA_VERBOSE_DEBUG) |
@@ -6115,15 +6173,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host) | |||
6115 | 6173 | ||
6116 | ap->cbl = ATA_CBL_NONE; | 6174 | ap->cbl = ATA_CBL_NONE; |
6117 | 6175 | ||
6118 | ap->link.ap = ap; | 6176 | ata_link_init(ap, &ap->link); |
6119 | |||
6120 | /* can't use iterator, ap isn't initialized yet */ | ||
6121 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | ||
6122 | struct ata_device *dev = &ap->link.device[i]; | ||
6123 | dev->link = &ap->link; | ||
6124 | dev->devno = i; | ||
6125 | ata_dev_init(dev); | ||
6126 | } | ||
6127 | 6177 | ||
6128 | #ifdef ATA_IRQ_TRAP | 6178 | #ifdef ATA_IRQ_TRAP |
6129 | ap->stats.unhandled_irq = 1; | 6179 | ap->stats.unhandled_irq = 1; |
@@ -6406,7 +6456,6 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
6406 | for (i = 0; i < host->n_ports; i++) { | 6456 | for (i = 0; i < host->n_ports; i++) { |
6407 | struct ata_port *ap = host->ports[i]; | 6457 | struct ata_port *ap = host->ports[i]; |
6408 | int irq_line; | 6458 | int irq_line; |
6409 | u32 scontrol; | ||
6410 | unsigned long xfer_mask; | 6459 | unsigned long xfer_mask; |
6411 | 6460 | ||
6412 | /* set SATA cable type if still unset */ | 6461 | /* set SATA cable type if still unset */ |
@@ -6414,12 +6463,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
6414 | ap->cbl = ATA_CBL_SATA; | 6463 | ap->cbl = ATA_CBL_SATA; |
6415 | 6464 | ||
6416 | /* init sata_spd_limit to the current value */ | 6465 | /* init sata_spd_limit to the current value */ |
6417 | if (sata_scr_read(&ap->link, SCR_CONTROL, &scontrol) == 0) { | 6466 | sata_link_init_spd(&ap->link); |
6418 | int spd = (scontrol >> 4) & 0xf; | ||
6419 | if (spd) | ||
6420 | ap->link.hw_sata_spd_limit &= (1 << spd) - 1; | ||
6421 | } | ||
6422 | ap->link.sata_spd_limit = ap->link.hw_sata_spd_limit; | ||
6423 | 6467 | ||
6424 | /* report the secondary IRQ for second channel legacy */ | 6468 | /* report the secondary IRQ for second channel legacy */ |
6425 | irq_line = host->irq; | 6469 | irq_line = host->irq; |