aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Garrett <mjg@redhat.com>2012-06-25 04:13:04 -0400
committerJeff Garzik <jgarzik@redhat.com>2012-06-29 11:38:11 -0400
commit30dcf76acc695cbd2fa919e294670fe9552e16e7 (patch)
tree77156836889ea87b90058dd23f634f0f7d99b757
parent6b66d95895c149cbc04d4fac5a2f5477c543a8ae (diff)
libata: migrate ACPI code over to new bindings
Now that we have the ability to directly glue the ACPI namespace to the driver model in libata, we don't need the custom code to handle the same thing. Remove it and migrate the functions over to the new code. Signed-off-by: Matthew Garrett <mjg@redhat.com> Signed-off-by: Holger Macht <holger@homac.de> Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
-rw-r--r--drivers/ata/libata-acpi.c161
-rw-r--r--drivers/ata/libata-core.c3
-rw-r--r--drivers/ata/libata-pmp.c4
-rw-r--r--drivers/ata/libata.h5
-rw-r--r--drivers/ata/pata_acpi.c4
-rw-r--r--include/linux/libata.h7
6 files changed, 40 insertions, 144 deletions
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index b3025a7d71e3..c6f0101fd253 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -47,7 +47,14 @@ static void ata_acpi_clear_gtf(struct ata_device *dev)
47 dev->gtf_cache = NULL; 47 dev->gtf_cache = NULL;
48} 48}
49 49
50static acpi_handle ap_acpi_handle(struct ata_port *ap) 50/**
51 * ata_ap_acpi_handle - provide the acpi_handle for an ata_port
52 * @ap: the acpi_handle returned will correspond to this port
53 *
54 * Returns the acpi_handle for the ACPI namespace object corresponding to
55 * the ata_port passed into the function, or NULL if no such object exists
56 */
57acpi_handle ata_ap_acpi_handle(struct ata_port *ap)
51{ 58{
52 if (ap->flags & ATA_FLAG_ACPI_SATA) 59 if (ap->flags & ATA_FLAG_ACPI_SATA)
53 return NULL; 60 return NULL;
@@ -64,8 +71,16 @@ static acpi_handle ap_acpi_handle(struct ata_port *ap)
64 return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), 71 return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev),
65 ap->port_no); 72 ap->port_no);
66} 73}
74EXPORT_SYMBOL(ata_ap_acpi_handle);
67 75
68static acpi_handle dev_acpi_handle(struct ata_device *dev) 76/**
77 * ata_dev_acpi_handle - provide the acpi_handle for an ata_device
78 * @dev: the acpi_device returned will correspond to this port
79 *
80 * Returns the acpi_handle for the ACPI namespace object corresponding to
81 * the ata_device passed into the function, or NULL if no such object exists
82 */
83acpi_handle ata_dev_acpi_handle(struct ata_device *dev)
69{ 84{
70 acpi_integer adr; 85 acpi_integer adr;
71 struct ata_port *ap = dev->link->ap; 86 struct ata_port *ap = dev->link->ap;
@@ -77,66 +92,9 @@ static acpi_handle dev_acpi_handle(struct ata_device *dev)
77 adr = SATA_ADR(ap->port_no, dev->link->pmp); 92 adr = SATA_ADR(ap->port_no, dev->link->pmp);
78 return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), adr); 93 return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), adr);
79 } else 94 } else
80 return acpi_get_child(ap_acpi_handle(ap), dev->devno); 95 return acpi_get_child(ata_ap_acpi_handle(ap), dev->devno);
81}
82
83/**
84 * ata_acpi_associate_sata_port - associate SATA port with ACPI objects
85 * @ap: target SATA port
86 *
87 * Look up ACPI objects associated with @ap and initialize acpi_handle
88 * fields of @ap, the port and devices accordingly.
89 *
90 * LOCKING:
91 * EH context.
92 *
93 * RETURNS:
94 * 0 on success, -errno on failure.
95 */
96void ata_acpi_associate_sata_port(struct ata_port *ap)
97{
98 WARN_ON(!(ap->flags & ATA_FLAG_ACPI_SATA));
99
100 if (!sata_pmp_attached(ap)) {
101 u64 adr = SATA_ADR(ap->port_no, NO_PORT_MULT);
102
103 ap->link.device->acpi_handle =
104 acpi_get_child(ap->host->acpi_handle, adr);
105 } else {
106 struct ata_link *link;
107
108 ap->link.device->acpi_handle = NULL;
109
110 ata_for_each_link(link, ap, EDGE) {
111 u64 adr = SATA_ADR(ap->port_no, link->pmp);
112
113 link->device->acpi_handle =
114 acpi_get_child(ap->host->acpi_handle, adr);
115 }
116 }
117}
118
119static void ata_acpi_associate_ide_port(struct ata_port *ap)
120{
121 int max_devices, i;
122
123 ap->acpi_handle = acpi_get_child(ap->host->acpi_handle, ap->port_no);
124 if (!ap->acpi_handle)
125 return;
126
127 max_devices = 1;
128 if (ap->flags & ATA_FLAG_SLAVE_POSS)
129 max_devices++;
130
131 for (i = 0; i < max_devices; i++) {
132 struct ata_device *dev = &ap->link.device[i];
133
134 dev->acpi_handle = acpi_get_child(ap->acpi_handle, i);
135 }
136
137 if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0)
138 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
139} 96}
97EXPORT_SYMBOL(ata_dev_acpi_handle);
140 98
141/* @ap and @dev are the same as ata_acpi_handle_hotplug() */ 99/* @ap and @dev are the same as ata_acpi_handle_hotplug() */
142static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev) 100static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev)
@@ -262,56 +220,6 @@ static const struct acpi_dock_ops ata_acpi_ap_dock_ops = {
262}; 220};
263 221
264/** 222/**
265 * ata_acpi_associate - associate ATA host with ACPI objects
266 * @host: target ATA host
267 *
268 * Look up ACPI objects associated with @host and initialize
269 * acpi_handle fields of @host, its ports and devices accordingly.
270 *
271 * LOCKING:
272 * EH context.
273 *
274 * RETURNS:
275 * 0 on success, -errno on failure.
276 */
277void ata_acpi_associate(struct ata_host *host)
278{
279 int i, j;
280
281 if (!is_pci_dev(host->dev) || libata_noacpi)
282 return;
283
284 host->acpi_handle = DEVICE_ACPI_HANDLE(host->dev);
285 if (!host->acpi_handle)
286 return;
287
288 for (i = 0; i < host->n_ports; i++) {
289 struct ata_port *ap = host->ports[i];
290
291 if (host->ports[0]->flags & ATA_FLAG_ACPI_SATA)
292 ata_acpi_associate_sata_port(ap);
293 else
294 ata_acpi_associate_ide_port(ap);
295
296 if (ap->acpi_handle) {
297 /* we might be on a docking station */
298 register_hotplug_dock_device(ap->acpi_handle,
299 &ata_acpi_ap_dock_ops, ap);
300 }
301
302 for (j = 0; j < ata_link_max_devices(&ap->link); j++) {
303 struct ata_device *dev = &ap->link.device[j];
304
305 if (dev->acpi_handle) {
306 /* we might be on a docking station */
307 register_hotplug_dock_device(dev->acpi_handle,
308 &ata_acpi_dev_dock_ops, dev);
309 }
310 }
311 }
312}
313
314/**
315 * ata_acpi_dissociate - dissociate ATA host from ACPI objects 223 * ata_acpi_dissociate - dissociate ATA host from ACPI objects
316 * @host: target ATA host 224 * @host: target ATA host
317 * 225 *
@@ -332,7 +240,7 @@ void ata_acpi_dissociate(struct ata_host *host)
332 struct ata_port *ap = host->ports[i]; 240 struct ata_port *ap = host->ports[i];
333 const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); 241 const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap);
334 242
335 if (ap->acpi_handle && gtm) 243 if (ata_ap_acpi_handle(ap) && gtm)
336 ata_acpi_stm(ap, gtm); 244 ata_acpi_stm(ap, gtm);
337 } 245 }
338} 246}
@@ -357,7 +265,8 @@ int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
357 acpi_status status; 265 acpi_status status;
358 int rc = 0; 266 int rc = 0;
359