aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ata/libata-acpi.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 1c33f78040c6..f6d80e342310 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -60,7 +60,8 @@ acpi_handle ata_ap_acpi_handle(struct ata_port *ap)
60 if (ap->flags & ATA_FLAG_ACPI_SATA) 60 if (ap->flags & ATA_FLAG_ACPI_SATA)
61 return NULL; 61 return NULL;
62 62
63 return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), ap->port_no); 63 return ap->scsi_host ?
64 DEVICE_ACPI_HANDLE(&ap->scsi_host->shost_gendev) : NULL;
64} 65}
65EXPORT_SYMBOL(ata_ap_acpi_handle); 66EXPORT_SYMBOL(ata_ap_acpi_handle);
66 67
@@ -239,28 +240,15 @@ void ata_acpi_dissociate(struct ata_host *host)
239 } 240 }
240} 241}
241 242
242/** 243static int __ata_acpi_gtm(struct ata_port *ap, acpi_handle handle,
243 * ata_acpi_gtm - execute _GTM 244 struct ata_acpi_gtm *gtm)
244 * @ap: target ATA port
245 * @gtm: out parameter for _GTM result
246 *
247 * Evaluate _GTM and store the result in @gtm.
248 *
249 * LOCKING:
250 * EH context.
251 *
252 * RETURNS:
253 * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
254 */
255int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
256{ 245{
257 struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER }; 246 struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER };
258 union acpi_object *out_obj; 247 union acpi_object *out_obj;
259 acpi_status status; 248 acpi_status status;
260 int rc = 0; 249 int rc = 0;
261 250
262 status = acpi_evaluate_object(ata_ap_acpi_handle(ap), "_GTM", NULL, 251 status = acpi_evaluate_object(handle, "_GTM", NULL, &output);
263 &output);
264 252
265 rc = -ENOENT; 253 rc = -ENOENT;
266 if (status == AE_NOT_FOUND) 254 if (status == AE_NOT_FOUND)
@@ -294,6 +282,27 @@ int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
294 return rc; 282 return rc;
295} 283}
296 284
285/**
286 * ata_acpi_gtm - execute _GTM
287 * @ap: target ATA port
288 * @gtm: out parameter for _GTM result
289 *
290 * Evaluate _GTM and store the result in @gtm.
291 *
292 * LOCKING:
293 * EH context.
294 *
295 * RETURNS:
296 * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
297 */
298int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
299{
300 if (ata_ap_acpi_handle(ap))
301 return __ata_acpi_gtm(ap, ata_ap_acpi_handle(ap), gtm);
302 else
303 return -EINVAL;
304}
305
297EXPORT_SYMBOL_GPL(ata_acpi_gtm); 306EXPORT_SYMBOL_GPL(ata_acpi_gtm);
298 307
299/** 308/**
@@ -1047,7 +1056,7 @@ static int ata_acpi_bind_host(struct ata_port *ap, acpi_handle *handle)
1047 if (!*handle) 1056 if (!*handle)
1048 return -ENODEV; 1057 return -ENODEV;
1049 1058
1050 if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0) 1059 if (__ata_acpi_gtm(ap, *handle, &ap->__acpi_init_gtm) == 0)
1051 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; 1060 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
1052 1061
1053 return 0; 1062 return 0;