aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/acpi/internal.h2
-rw-r--r--drivers/pnp/pnpacpi/core.c91
-rw-r--r--include/acpi/acpi_bus.h2
3 files changed, 28 insertions, 67 deletions
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 7de5b603f272..151f3e76d47a 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -84,8 +84,6 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
84 int type, unsigned long long sta); 84 int type, unsigned long long sta);
85void acpi_device_add_finalize(struct acpi_device *device); 85void acpi_device_add_finalize(struct acpi_device *device);
86void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); 86void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
87int acpi_bind_one(struct device *dev, struct acpi_device *adev);
88int acpi_unbind_one(struct device *dev);
89bool acpi_device_is_present(struct acpi_device *adev); 87bool acpi_device_is_present(struct acpi_device *adev);
90bool acpi_device_is_battery(struct acpi_device *adev); 88bool acpi_device_is_battery(struct acpi_device *adev);
91 89
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index a5c6cb773e5f..d2b780aade89 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -67,8 +67,8 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
67 67
68 pnp_dbg(&dev->dev, "set resources\n"); 68 pnp_dbg(&dev->dev, "set resources\n");
69 69
70 handle = ACPI_HANDLE(&dev->dev); 70 acpi_dev = ACPI_COMPANION(&dev->dev);
71 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) { 71 if (!acpi_dev) {
72 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 72 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
73 return -ENODEV; 73 return -ENODEV;
74 } 74 }
@@ -76,6 +76,7 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
76 if (WARN_ON_ONCE(acpi_dev != dev->data)) 76 if (WARN_ON_ONCE(acpi_dev != dev->data))
77 dev->data = acpi_dev; 77 dev->data = acpi_dev;
78 78
79 handle = acpi_dev->handle;
79 if (acpi_has_method(handle, METHOD_NAME__SRS)) { 80 if (acpi_has_method(handle, METHOD_NAME__SRS)) {
80 struct acpi_buffer buffer; 81 struct acpi_buffer buffer;
81 82
@@ -93,8 +94,8 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
93 } 94 }
94 kfree(buffer.pointer); 95 kfree(buffer.pointer);
95 } 96 }
96 if (!ret && acpi_bus_power_manageable(handle)) 97 if (!ret && acpi_device_power_manageable(acpi_dev))
97 ret = acpi_bus_set_power(handle, ACPI_STATE_D0); 98 ret = acpi_device_set_power(acpi_dev, ACPI_STATE_D0);
98 99
99 return ret; 100 return ret;
100} 101}
@@ -102,23 +103,22 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
102static int pnpacpi_disable_resources(struct pnp_dev *dev) 103static int pnpacpi_disable_resources(struct pnp_dev *dev)
103{ 104{
104 struct acpi_device *acpi_dev; 105 struct acpi_device *acpi_dev;
105 acpi_handle handle;
106 acpi_status status; 106 acpi_status status;
107 107
108 dev_dbg(&dev->dev, "disable resources\n"); 108 dev_dbg(&dev->dev, "disable resources\n");
109 109
110 handle = ACPI_HANDLE(&dev->dev); 110 acpi_dev = ACPI_COMPANION(&dev->dev);
111 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) { 111 if (!acpi_dev) {
112 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 112 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
113 return 0; 113 return 0;
114 } 114 }
115 115
116 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */ 116 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */
117 if (acpi_bus_power_manageable(handle)) 117 if (acpi_device_power_manageable(acpi_dev))
118 acpi_bus_set_power(handle, ACPI_STATE_D3_COLD); 118 acpi_device_set_power(acpi_dev, ACPI_STATE_D3_COLD);
119 119
120 /* continue even if acpi_bus_set_power() fails */ 120 /* continue even if acpi_device_set_power() fails */
121 status = acpi_evaluate_object(handle, "_DIS", NULL, NULL); 121 status = acpi_evaluate_object(acpi_dev->handle, "_DIS", NULL, NULL);
122 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) 122 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
123 return -ENODEV; 123 return -ENODEV;
124 124
@@ -128,26 +128,22 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
128#ifdef CONFIG_ACPI_SLEEP 128#ifdef CONFIG_ACPI_SLEEP
129static bool pnpacpi_can_wakeup(struct pnp_dev *dev) 129static bool pnpacpi_can_wakeup(struct pnp_dev *dev)
130{ 130{
131 struct acpi_device *acpi_dev; 131 struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev);
132 acpi_handle handle;
133 132
134 handle = ACPI_HANDLE(&dev->dev); 133 if (!acpi_dev) {
135 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) {
136 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 134 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
137 return false; 135 return false;
138 } 136 }
139 137
140 return acpi_bus_can_wakeup(handle); 138 return acpi_bus_can_wakeup(acpi_dev->handle);
141} 139}
142 140
143static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state) 141static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
144{ 142{
145 struct acpi_device *acpi_dev; 143 struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev);
146 acpi_handle handle;
147 int error = 0; 144 int error = 0;
148 145
149 handle = ACPI_HANDLE(&dev->dev); 146 if (!acpi_dev) {
150 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) {
151 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 147 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
152 return 0; 148 return 0;
153 } 149 }
@@ -159,7 +155,7 @@ static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
159 return error; 155 return error;
160 } 156 }
161 157
162 if (acpi_bus_power_manageable(handle)) { 158 if (acpi_device_power_manageable(acpi_dev)) {
163 int power_state = acpi_pm_device_sleep_state(&dev->dev, NULL, 159 int power_state = acpi_pm_device_sleep_state(&dev->dev, NULL,
164 ACPI_STATE_D3_COLD); 160 ACPI_STATE_D3_COLD);
165 if (power_state < 0) 161 if (power_state < 0)
@@ -167,12 +163,12 @@ static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
167 ACPI_STATE_D0 : ACPI_STATE_D3_COLD; 163 ACPI_STATE_D0 : ACPI_STATE_D3_COLD;
168 164
169 /* 165 /*
170 * acpi_bus_set_power() often fails (keyboard port can't be 166 * acpi_device_set_power() can fail (keyboard port can't be
171 * powered-down?), and in any case, our return value is ignored 167 * powered-down?), and in any case, our return value is ignored
172 * by pnp_bus_suspend(). Hence we don't revert the wakeup 168 * by pnp_bus_suspend(). Hence we don't revert the wakeup
173 * setting if the set_power fails. 169 * setting if the set_power fails.
174 */ 170 */
175 error = acpi_bus_set_power(handle, power_state); 171 error = acpi_device_set_power(acpi_dev, power_state);
176 } 172 }
177 173
178 return error; 174 return error;
@@ -180,11 +176,10 @@ static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
180 176
181static int pnpacpi_resume(struct pnp_dev *dev) 177static int pnpacpi_resume(struct pnp_dev *dev)
182{ 178{
183 struct acpi_device *acpi_dev; 179 struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev);
184 acpi_handle handle = ACPI_HANDLE(&dev->dev);
185 int error = 0; 180 int error = 0;
186 181
187 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) { 182 if (!acpi_dev) {
188 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 183 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
189 return -ENODEV; 184 return -ENODEV;
190 } 185 }
@@ -192,8 +187,8 @@ static int pnpacpi_resume(struct pnp_dev *dev)
192 if (device_may_wakeup(&dev->dev)) 187 if (device_may_wakeup(&dev->dev))
193 acpi_pm_device_sleep_wake(&dev->dev, false); 188 acpi_pm_device_sleep_wake(&dev->dev, false);
194 189
195 if (acpi_bus_power_manageable(handle)) 190 if (acpi_device_power_manageable(acpi_dev))
196 error = acpi_bus_set_power(handle, ACPI_STATE_D0); 191 error = acpi_device_set_power(acpi_dev, ACPI_STATE_D0);
197 192
198 return error; 193 return error;
199} 194}
@@ -295,9 +290,11 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
295 return error; 290 return error;
296 } 291 }
297 292
293 error = acpi_bind_one(&dev->dev, device);
294
298 num++; 295 num++;
299 296
300 return 0; 297 return error;
301} 298}
302 299
303static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, 300static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
@@ -313,40 +310,6 @@ static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
313 return AE_OK; 310 return AE_OK;
314} 311}
315 312
316static int __init acpi_pnp_match(struct device *dev, void *_pnp)
317{
318 struct acpi_device *acpi = to_acpi_device(dev);
319 struct pnp_dev *pnp = _pnp;
320
321 /* true means it matched */
322 return pnp->data == acpi;
323}
324
325static struct acpi_device * __init acpi_pnp_find_companion(struct device *dev)
326{
327 dev = bus_find_device(&acpi_bus_type, NULL, to_pnp_dev(dev),
328 acpi_pnp_match);
329 if (!dev)
330 return NULL;
331
332 put_device(dev);
333 return to_acpi_device(dev);
334}
335
336/* complete initialization of a PNPACPI device includes having
337 * pnpdev->dev.archdata.acpi_handle point to its ACPI sibling.
338 */
339static bool acpi_pnp_bus_match(struct device *dev)
340{
341 return dev->bus == &pnp_bus_type;
342}
343
344static struct acpi_bus_type __initdata acpi_pnp_bus = {
345 .name = "PNP",
346 .match = acpi_pnp_bus_match,
347 .find_companion = acpi_pnp_find_companion,
348};
349
350int pnpacpi_disabled __initdata; 313int pnpacpi_disabled __initdata;
351static int __init pnpacpi_init(void) 314static int __init pnpacpi_init(void)
352{ 315{
@@ -356,10 +319,8 @@ static int __init pnpacpi_init(void)
356 } 319 }
357 printk(KERN_INFO "pnp: PnP ACPI init\n"); 320 printk(KERN_INFO "pnp: PnP ACPI init\n");
358 pnp_register_protocol(&pnpacpi_protocol); 321 pnp_register_protocol(&pnpacpi_protocol);
359 register_acpi_bus_type(&acpi_pnp_bus);
360 acpi_get_devices(NULL, pnpacpi_add_device_handler, NULL, NULL); 322 acpi_get_devices(NULL, pnpacpi_add_device_handler, NULL, NULL);
361 printk(KERN_INFO "pnp: PnP ACPI: found %d devices\n", num); 323 printk(KERN_INFO "pnp: PnP ACPI: found %d devices\n", num);
362 unregister_acpi_bus_type(&acpi_pnp_bus);
363 pnp_platform_devices = 1; 324 pnp_platform_devices = 1;
364 return 0; 325 return 0;
365} 326}
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index b5714580801a..4bcbb941bc09 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -487,6 +487,8 @@ struct acpi_bus_type {
487}; 487};
488int register_acpi_bus_type(struct acpi_bus_type *); 488int register_acpi_bus_type(struct acpi_bus_type *);
489int unregister_acpi_bus_type(struct acpi_bus_type *); 489int unregister_acpi_bus_type(struct acpi_bus_type *);
490int acpi_bind_one(struct device *dev, struct acpi_device *adev);
491int acpi_unbind_one(struct device *dev);
490 492
491struct acpi_pci_root { 493struct acpi_pci_root {
492 struct acpi_device * device; 494 struct acpi_device * device;