aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/macintosh')
-rw-r--r--drivers/macintosh/adb.c42
-rw-r--r--drivers/macintosh/ans-lcd.c9
-rw-r--r--drivers/macintosh/apm_emu.c13
-rw-r--r--drivers/macintosh/mac_hid.c2
-rw-r--r--drivers/macintosh/macio-adb.c16
-rw-r--r--drivers/macintosh/macio_asic.c100
-rw-r--r--drivers/macintosh/macio_sysfs.c10
-rw-r--r--drivers/macintosh/rack-meter.c2
-rw-r--r--drivers/macintosh/smu.c8
-rw-r--r--drivers/macintosh/therm_adt746x.c8
-rw-r--r--drivers/macintosh/therm_pm72.c8
-rw-r--r--drivers/macintosh/therm_windtunnel.c2
-rw-r--r--drivers/macintosh/via-cuda.c2
-rw-r--r--drivers/macintosh/via-pmu-led.c10
-rw-r--r--drivers/macintosh/via-pmu.c55
-rw-r--r--drivers/macintosh/windfarm_lm75_sensor.c2
-rw-r--r--drivers/macintosh/windfarm_max6690_sensor.c2
-rw-r--r--drivers/macintosh/windfarm_smu_controls.c8
-rw-r--r--drivers/macintosh/windfarm_smu_sat.c8
-rw-r--r--drivers/macintosh/windfarm_smu_sensors.c6
20 files changed, 91 insertions, 222 deletions
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index f729eebf771f..adfea3c7c62a 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -90,7 +90,7 @@ static int autopoll_devs;
90int __adb_probe_sync; 90int __adb_probe_sync;
91 91
92#ifdef CONFIG_PM 92#ifdef CONFIG_PM
93static int adb_notify_sleep(struct pmu_sleep_notifier *self, int when); 93static void adb_notify_sleep(struct pmu_sleep_notifier *self, int when);
94static struct pmu_sleep_notifier adb_sleep_notifier = { 94static struct pmu_sleep_notifier adb_sleep_notifier = {
95 adb_notify_sleep, 95 adb_notify_sleep,
96 SLEEP_LEVEL_ADB, 96 SLEEP_LEVEL_ADB,
@@ -340,11 +340,9 @@ __initcall(adb_init);
340/* 340/*
341 * notify clients before sleep and reset bus afterwards 341 * notify clients before sleep and reset bus afterwards
342 */ 342 */
343int 343void
344adb_notify_sleep(struct pmu_sleep_notifier *self, int when) 344adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
345{ 345{
346 int ret;
347
348 switch (when) { 346 switch (when) {
349 case PBOOK_SLEEP_REQUEST: 347 case PBOOK_SLEEP_REQUEST:
350 adb_got_sleep = 1; 348 adb_got_sleep = 1;
@@ -353,22 +351,8 @@ adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
353 /* Stop autopoll */ 351 /* Stop autopoll */
354 if (adb_controller->autopoll) 352 if (adb_controller->autopoll)
355 adb_controller->autopoll(0); 353 adb_controller->autopoll(0);
356 ret = blocking_notifier_call_chain(&adb_client_list, 354 blocking_notifier_call_chain(&adb_client_list,
357 ADB_MSG_POWERDOWN, NULL); 355 ADB_MSG_POWERDOWN, NULL);
358 if (ret & NOTIFY_STOP_MASK) {
359 up(&adb_probe_mutex);
360 return PBOOK_SLEEP_REFUSE;
361 }
362 break;
363 case PBOOK_SLEEP_REJECT:
364 if (adb_got_sleep) {
365 adb_got_sleep = 0;
366 up(&adb_probe_mutex);
367 adb_reset_bus();
368 }
369 break;
370
371 case PBOOK_SLEEP_NOW:
372 break; 356 break;
373 case PBOOK_WAKE: 357 case PBOOK_WAKE:
374 adb_got_sleep = 0; 358 adb_got_sleep = 0;
@@ -376,14 +360,13 @@ adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
376 adb_reset_bus(); 360 adb_reset_bus();
377 break; 361 break;
378 } 362 }
379 return PBOOK_SLEEP_OK;
380} 363}
381#endif /* CONFIG_PM */ 364#endif /* CONFIG_PM */
382 365
383static int 366static int
384do_adb_reset_bus(void) 367do_adb_reset_bus(void)
385{ 368{
386 int ret, nret; 369 int ret;
387 370
388 if (adb_controller == NULL) 371 if (adb_controller == NULL)
389 return -ENXIO; 372 return -ENXIO;
@@ -391,13 +374,8 @@ do_adb_reset_bus(void)
391 if (adb_controller->autopoll) 374 if (adb_controller->autopoll)
392 adb_controller->autopoll(0); 375 adb_controller->autopoll(0);
393 376
394 nret = blocking_notifier_call_chain(&adb_client_list, 377 blocking_notifier_call_chain(&adb_client_list,
395 ADB_MSG_PRE_RESET, NULL); 378 ADB_MSG_PRE_RESET, NULL);
396 if (nret & NOTIFY_STOP_MASK) {
397 if (adb_controller->autopoll)
398 adb_controller->autopoll(autopoll_devs);
399 return -EBUSY;
400 }
401 379
402 if (sleepy_trackpad) { 380 if (sleepy_trackpad) {
403 /* Let the trackpad settle down */ 381 /* Let the trackpad settle down */
@@ -427,10 +405,8 @@ do_adb_reset_bus(void)
427 } 405 }
428 up(&adb_handler_sem); 406 up(&adb_handler_sem);
429 407
430 nret = blocking_notifier_call_chain(&adb_client_list, 408 blocking_notifier_call_chain(&adb_client_list,
431 ADB_MSG_POST_RESET, NULL); 409 ADB_MSG_POST_RESET, NULL);
432 if (nret & NOTIFY_STOP_MASK)
433 return -EBUSY;
434 410
435 return ret; 411 return ret;
436} 412}
diff --git a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c
index cdd5a0f72e3c..e54c4d9f6365 100644
--- a/drivers/macintosh/ans-lcd.c
+++ b/drivers/macintosh/ans-lcd.c
@@ -145,11 +145,12 @@ anslcd_init(void)
145 int retval; 145 int retval;
146 struct device_node* node; 146 struct device_node* node;
147 147
148 node = find_devices("lcd"); 148 node = of_find_node_by_name(NULL, "lcd");
149 if (!node || !node->parent) 149 if (!node || !node->parent || strcmp(node->parent->name, "gc")) {
150 return -ENODEV; 150 of_node_put(node);
151 if (strcmp(node->parent->name, "gc"))
152 return -ENODEV; 151 return -ENODEV;
152 }
153 of_node_put(node);
153 154
154 anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20); 155 anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20);
155 156
diff --git a/drivers/macintosh/apm_emu.c b/drivers/macintosh/apm_emu.c
index c5e4d43f97fc..cdb0bead9917 100644
--- a/drivers/macintosh/apm_emu.c
+++ b/drivers/macintosh/apm_emu.c
@@ -96,7 +96,7 @@ static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
96static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue); 96static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
97static struct apm_user * user_list; 97static struct apm_user * user_list;
98 98
99static int apm_notify_sleep(struct pmu_sleep_notifier *self, int when); 99static void apm_notify_sleep(struct pmu_sleep_notifier *self, int when);
100static struct pmu_sleep_notifier apm_sleep_notifier = { 100static struct pmu_sleep_notifier apm_sleep_notifier = {
101 apm_notify_sleep, 101 apm_notify_sleep,
102 SLEEP_LEVEL_USERLAND, 102 SLEEP_LEVEL_USERLAND,
@@ -352,7 +352,7 @@ static int do_open(struct inode * inode, struct file * filp)
352 * doesn't provide a way to NAK, but this could be added 352 * doesn't provide a way to NAK, but this could be added
353 * here. 353 * here.
354 */ 354 */
355static int wait_all_suspend(void) 355static void wait_all_suspend(void)
356{ 356{
357 DECLARE_WAITQUEUE(wait, current); 357 DECLARE_WAITQUEUE(wait, current);
358 358
@@ -366,24 +366,19 @@ static int wait_all_suspend(void)
366 remove_wait_queue(&apm_suspend_waitqueue, &wait); 366 remove_wait_queue(&apm_suspend_waitqueue, &wait);
367 367
368 DBG("apm_emu: wait_all_suspend() - complete !\n"); 368 DBG("apm_emu: wait_all_suspend() - complete !\n");
369
370 return 1;
371} 369}
372 370
373static int apm_notify_sleep(struct pmu_sleep_notifier *self, int when) 371static void apm_notify_sleep(struct pmu_sleep_notifier *self, int when)
374{ 372{
375 switch(when) { 373 switch(when) {
376 case PBOOK_SLEEP_REQUEST: 374 case PBOOK_SLEEP_REQUEST:
377 queue_event(APM_SYS_SUSPEND, NULL); 375 queue_event(APM_SYS_SUSPEND, NULL);
378 if (!wait_all_suspend()) 376 wait_all_suspend();
379 return PBOOK_SLEEP_REFUSE;
380 break; 377 break;
381 case PBOOK_SLEEP_REJECT:
382 case PBOOK_WAKE: 378 case PBOOK_WAKE:
383 queue_event(APM_NORMAL_RESUME, NULL); 379 queue_event(APM_NORMAL_RESUME, NULL);
384 break; 380 break;
385 } 381 }
386 return PBOOK_SLEEP_OK;
387} 382}
388 383
389#define APM_CRITICAL 10 384#define APM_CRITICAL 10
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
index c1fd816e9f09..1599dc34f15f 100644
--- a/drivers/macintosh/mac_hid.c
+++ b/drivers/macintosh/mac_hid.c
@@ -102,8 +102,6 @@ int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down)
102 return 0; 102 return 0;
103} 103}
104 104
105EXPORT_SYMBOL(mac_hid_mouse_emulate_buttons);
106
107static int emumousebtn_input_register(void) 105static int emumousebtn_input_register(void)
108{ 106{
109 int ret; 107 int ret;
diff --git a/drivers/macintosh/macio-adb.c b/drivers/macintosh/macio-adb.c
index 026b67f4f659..79119f56e82d 100644
--- a/drivers/macintosh/macio-adb.c
+++ b/drivers/macintosh/macio-adb.c
@@ -82,7 +82,14 @@ struct adb_driver macio_adb_driver = {
82 82
83int macio_probe(void) 83int macio_probe(void)
84{ 84{
85 return find_compatible_devices("adb", "chrp,adb0")? 0: -ENODEV; 85 struct device_node *np;
86
87 np = of_find_compatible_node(NULL, "adb", "chrp,adb0");
88 if (np) {
89 of_node_put(np);
90 return 0;
91 }
92 return -ENODEV;
86} 93}
87 94
88int macio_init(void) 95int macio_init(void)
@@ -91,12 +98,14 @@ int macio_init(void)
91 struct resource r; 98 struct resource r;
92 unsigned int irq; 99 unsigned int irq;
93 100
94 adbs = find_compatible_devices("adb", "chrp,adb0"); 101 adbs = of_find_compatible_node(NULL, "adb", "chrp,adb0");
95 if (adbs == 0) 102 if (adbs == 0)
96 return -ENXIO; 103 return -ENXIO;
97 104
98 if (of_address_to_resource(adbs, 0, &r)) 105 if (of_address_to_resource(adbs, 0, &r)) {
106 of_node_put(adbs);
99 return -ENXIO; 107 return -ENXIO;
108 }
100 adb = ioremap(r.start, sizeof(struct adb_regs)); 109 adb = ioremap(r.start, sizeof(struct adb_regs));
101 110
102 out_8(&adb->ctrl.r, 0); 111 out_8(&adb->ctrl.r, 0);
@@ -107,6 +116,7 @@ int macio_init(void)
107 out_8(&adb->autopoll.r, APE); 116 out_8(&adb->autopoll.r, APE);
108 117
109 irq = irq_of_parse_and_map(adbs, 0); 118 irq = irq_of_parse_and_map(adbs, 0);
119 of_node_put(adbs);
110 if (request_irq(irq, macio_adb_interrupt, 0, "ADB", (void *)0)) { 120 if (request_irq(irq, macio_adb_interrupt, 0, "ADB", (void *)0)) {
111 printk(KERN_ERR "ADB: can't get irq %d\n", irq); 121 printk(KERN_ERR "ADB: can't get irq %d\n", irq);
112 return -EAGAIN; 122 return -EAGAIN;
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index d56216067549..c96b7fe882a4 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -134,108 +134,12 @@ static int macio_device_resume(struct device * dev)
134 return 0; 134 return 0;
135} 135}
136 136
137static int macio_uevent(struct device *dev, char **envp, int num_envp,
138 char *buffer, int buffer_size)
139{
140 struct macio_dev * macio_dev;
141 struct of_device * of;
142 char *scratch;
143 const char *compat, *compat2;
144
145 int i = 0;
146 int length, cplen, cplen2, seen = 0;
147
148 if (!dev)
149 return -ENODEV;
150
151 macio_dev = to_macio_device(dev);
152 if (!macio_dev)
153 return -ENODEV;
154
155 of = &macio_dev->ofdev;
156
157 /* stuff we want to pass to /sbin/hotplug */
158 envp[i++] = scratch = buffer;
159 length = scnprintf (scratch, buffer_size, "OF_NAME=%s", of->node->name);
160 ++length;
161 buffer_size -= length;
162 if ((buffer_size <= 0) || (i >= num_envp))
163 return -ENOMEM;
164 scratch += length;
165
166 envp[i++] = scratch;
167 length = scnprintf (scratch, buffer_size, "OF_TYPE=%s", of->node->type);
168 ++length;
169 buffer_size -= length;
170 if ((buffer_size <= 0) || (i >= num_envp))
171 return -ENOMEM;
172 scratch += length;
173
174 /* Since the compatible field can contain pretty much anything
175 * it's not really legal to split it out with commas. We split it
176 * up using a number of environment variables instead. */
177
178 compat = get_property(of->node, "compatible", &cplen);
179 compat2 = compat;
180 cplen2= cplen;
181 while (compat && cplen > 0) {
182 envp[i++] = scratch;
183 length = scnprintf (scratch, buffer_size,
184 "OF_COMPATIBLE_%d=%s", seen, compat);
185 ++length;
186 buffer_size -= length;
187 if ((buffer_size <= 0) || (i >= num_envp))
188 return -ENOMEM;
189 scratch += length;
190 length = strlen (compat) + 1;
191 compat += length;
192 cplen -= length;
193 seen++;
194 }
195
196 envp[i++] = scratch;
197 length = scnprintf (scratch, buffer_size, "OF_COMPATIBLE_N=%d", seen);
198 ++length;
199 buffer_size -= length;
200 if ((buffer_size <= 0) || (i >= num_envp))
201 return -ENOMEM;
202 scratch += length;
203
204 envp[i++] = scratch;
205 length = scnprintf (scratch, buffer_size, "MODALIAS=of:N%sT%s",
206 of->node->name, of->node->type);
207 /* overwrite '\0' */
208 buffer_size -= length;
209 if ((buffer_size <= 0) || (i >= num_envp))
210 return -ENOMEM;
211 scratch += length;
212
213 if (!compat2) {
214 compat2 = "";
215 cplen2 = 1;
216 }
217 while (cplen2 > 0) {
218 length = snprintf (scratch, buffer_size, "C%s", compat2);
219 buffer_size -= length;
220 if (buffer_size <= 0)
221 return -ENOMEM;
222 scratch += length;
223 length = strlen (compat2) + 1;
224 compat2 += length;
225 cplen2 -= length;
226 }
227
228 envp[i] = NULL;
229
230 return 0;
231}
232
233extern struct device_attribute macio_dev_attrs[]; 137extern struct device_attribute macio_dev_attrs[];
234 138
235struct bus_type macio_bus_type = { 139struct bus_type macio_bus_type = {
236 .name = "macio", 140 .name = "macio",
237 .match = macio_bus_match, 141 .match = macio_bus_match,
238 .uevent = macio_uevent, 142 .uevent = of_device_uevent,
239 .probe = macio_device_probe, 143 .probe = macio_device_probe,
240 .remove = macio_device_remove, 144 .remove = macio_device_remove,
241 .shutdown = macio_device_shutdown, 145 .shutdown = macio_device_shutdown,
@@ -491,7 +395,7 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip,
491#endif 395#endif
492 MAX_NODE_NAME_SIZE, np->name); 396 MAX_NODE_NAME_SIZE, np->name);
493 } else { 397 } else {
494 reg = get_property(np, "reg", NULL); 398 reg = of_get_property(np, "reg", NULL);
495 sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s", 399 sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s",
496 chip->lbus.index, 400 chip->lbus.index,
497 reg ? *reg : 0, MAX_NODE_NAME_SIZE, np->name); 401 reg ? *reg : 0, MAX_NODE_NAME_SIZE, np->name);
diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c
index 8566bdfdd4b8..cc8267912656 100644
--- a/drivers/macintosh/macio_sysfs.c
+++ b/drivers/macintosh/macio_sysfs.c
@@ -21,7 +21,7 @@ compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
21 int length = 0; 21 int length = 0;
22 22
23 of = &to_macio_device (dev)->ofdev; 23 of = &to_macio_device (dev)->ofdev;
24 compat = get_property(of->node, "compatible", &cplen); 24 compat = of_get_property(of->node, "compatible", &cplen);
25 if (!compat) { 25 if (!compat) {
26 *buf = '\0'; 26 *buf = '\0';
27 return 0; 27 return 0;
@@ -47,18 +47,20 @@ static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
47 int length; 47 int length;
48 48
49 of = &to_macio_device (dev)->ofdev; 49 of = &to_macio_device (dev)->ofdev;
50 compat = get_property(of->node, "compatible", &cplen); 50 compat = of_get_property(of->node, "compatible", &cplen);
51 if (!compat) compat = "", cplen = 1; 51 if (!compat) compat = "", cplen = 1;
52 length = sprintf (buf, "of:N%sT%s", of->node->name, of->node->type); 52 length = sprintf (buf, "of:N%sT%s", of->node->name, of->node->type);
53 buf += length; 53 buf += length;
54 while (cplen > 0) { 54 while (cplen > 0) {
55 int l; 55 int l;
56 length += sprintf (buf, "C%s", compat); 56 l = sprintf (buf, "C%s", compat);
57 buf += length; 57 length += l;
58 buf += l;
58 l = strlen (compat) + 1; 59 l = strlen (compat) + 1;
59 compat += l; 60 compat += l;
60 cplen -= l; 61 cplen -= l;
61 } 62 }
63 length += sprintf(buf, "\n");
62 64
63 return length; 65 return length;
64} 66}
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c
index f83fad2a3ff4..4177ff004753 100644
--- a/drivers/macintosh/rack-meter.c
+++ b/drivers/macintosh/rack-meter.c
@@ -387,7 +387,7 @@ static int __devinit rackmeter_probe(struct macio_dev* mdev,
387 if (strcmp(np->name, "lightshow") == 0) 387 if (strcmp(np->name, "lightshow") == 0)
388 break; 388 break;
389 if ((strcmp(np->name, "sound") == 0) && 389 if ((strcmp(np->name, "sound") == 0) &&
390 get_property(np, "virtual", NULL) != NULL) 390 of_get_property(np, "virtual", NULL) != NULL)
391 break; 391 break;
392 } 392 }
393 if (np == NULL) { 393 if (np == NULL) {
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index c9f3dc4fd3ee..a98a328b1cfc 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -491,7 +491,7 @@ int __init smu_init (void)
491 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n"); 491 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n");
492 goto fail; 492 goto fail;
493 } 493 }
494 data = get_property(smu->db_node, "reg", NULL); 494 data = of_get_property(smu->db_node, "reg", NULL);
495 if (data == NULL) { 495 if (data == NULL) {
496 of_node_put(smu->db_node); 496 of_node_put(smu->db_node);
497 smu->db_node = NULL; 497 smu->db_node = NULL;
@@ -512,7 +512,7 @@ int __init smu_init (void)
512 smu->msg_node = of_find_node_by_name(NULL, "smu-interrupt"); 512 smu->msg_node = of_find_node_by_name(NULL, "smu-interrupt");
513 if (smu->msg_node == NULL) 513 if (smu->msg_node == NULL)
514 break; 514 break;
515 data = get_property(smu->msg_node, "reg", NULL); 515 data = of_get_property(smu->msg_node, "reg", NULL);
516 if (data == NULL) { 516 if (data == NULL) {
517 of_node_put(smu->msg_node); 517 of_node_put(smu->msg_node);
518 smu->msg_node = NULL; 518 smu->msg_node = NULL;
@@ -952,7 +952,7 @@ static struct smu_sdbp_header *smu_create_sdb_partition(int id)
952 prop->name = ((char *)prop) + tlen - 18; 952 prop->name = ((char *)prop) + tlen - 18;
953 sprintf(prop->name, "sdb-partition-%02x", id); 953 sprintf(prop->name, "sdb-partition-%02x", id);
954 prop->length = len; 954 prop->length = len;
955 prop->value = (unsigned char *)hdr; 955 prop->value = hdr;
956 prop->next = NULL; 956 prop->next = NULL;
957 957
958 /* Read the datablock */ 958 /* Read the datablock */
@@ -1004,7 +1004,7 @@ const struct smu_sdbp_header *__smu_get_sdb_partition(int id,
1004 } else 1004 } else
1005 mutex_lock(&smu_part_access); 1005 mutex_lock(&smu_part_access);
1006 1006
1007 part = get_property(smu->of_node, pname, size); 1007 part = of_get_property(smu->of_node, pname, size);
1008 if (part == NULL) { 1008 if (part == NULL) {
1009 DPRINTK("trying to extract from SMU ...\n"); 1009 DPRINTK("trying to extract from SMU ...\n");
1010 part = smu_create_sdb_partition(id); 1010 part = smu_create_sdb_partition(id);
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index a7ce55926638..228903403cfc 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -567,13 +567,13 @@ thermostat_init(void)
567 else 567 else
568 return -ENODEV; 568 return -ENODEV;
569 569
570 prop = get_property(np, "hwsensor-params-version", NULL); 570 prop = of_get_property(np, "hwsensor-params-version", NULL);
571 printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop, 571 printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop,
572 (*prop == 1)?"":"un"); 572 (*prop == 1)?"":"un");
573 if (*prop != 1) 573 if (*prop != 1)
574 return -ENODEV; 574 return -ENODEV;
575 575
576 prop = get_property(np, "reg", NULL); 576 prop = of_get_property(np, "reg", NULL);
577 if (!prop) 577 if (!prop)
578 return -ENODEV; 578 return -ENODEV;
579 579
@@ -591,9 +591,9 @@ thermostat_init(void)
591 "limit_adjust: %d, fan_speed: %d\n", 591 "limit_adjust: %d, fan_speed: %d\n",
592 therm_bus, therm_address, limit_adjust, fan_speed); 592 therm_bus, therm_address, limit_adjust, fan_speed);
593 593
594 if (get_property(np, "hwsensor-location", NULL)) { 594 if (of_get_property(np, "hwsensor-location", NULL)) {
595 for (i = 0; i < 3; i++) { 595 for (i = 0; i < 3; i++) {
596 sensor_location[i] = get_property(np, 596 sensor_location[i] = of_get_property(np,
597 "hwsensor-location", NULL) + offset; 597 "hwsensor-location", NULL) + offset;
598 598
599 if (sensor_location[i] == NULL) 599 if (sensor_location[i] == NULL)
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 2e4ad44a8636..78ff18617139 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -674,7 +674,7 @@ static int read_eeprom(int cpu, struct mpu_data *out)
674 printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid node from device-tree\n"); 674 printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid node from device-tree\n");
675 return -ENODEV; 675 return -ENODEV;
676 } 676 }
677 data = get_property(np, "cpuid", &len); 677 data = of_get_property(np, "cpuid", &len);
678 if (data == NULL) { 678 if (data == NULL) {
679 printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid property from device-tree\n"); 679 printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid property from device-tree\n");
680 of_node_put(np); 680 of_node_put(np);
@@ -1337,7 +1337,7 @@ static int init_backside_state(struct backside_pid_state *state)
1337 */ 1337 */
1338 u3 = of_find_node_by_path("/u3@0,f8000000"); 1338 u3 = of_find_node_by_path("/u3@0,f8000000");
1339 if (u3 != NULL) { 1339 if (u3 != NULL) {
1340 const u32 *vers = get_property(u3, "device-rev", NULL); 1340 const u32 *vers = of_get_property(u3, "device-rev", NULL);
1341 if (vers) 1341 if (vers)
1342 if (((*vers) & 0x3f) < 0x34) 1342 if (((*vers) & 0x3f) < 0x34)
1343 u3h = 0; 1343 u3h = 0;
@@ -2129,8 +2129,8 @@ static void fcu_lookup_fans(struct device_node *fcu_node)
2129 continue; 2129 continue;
2130 2130
2131 /* Lookup for a matching location */ 2131 /* Lookup for a matching location */
2132 loc = get_property(np, "location", NULL); 2132 loc = of_get_property(np, "location", NULL);
2133 reg = get_property(np, "reg", NULL); 2133 reg = of_get_property(np, "reg", NULL);
2134 if (loc == NULL || reg == NULL) 2134 if (loc == NULL || reg == NULL)
2135 continue; 2135 continue;
2136 DBG(" matching location: %s, reg: 0x%08x\n", loc, *reg); 2136 DBG(" matching location: %s, reg: 0x%08x\n", loc, *reg);
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index a1d3a987cb3a..35233de460ad 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -492,7 +492,7 @@ g4fan_init( void )
492 492
493 if( !(np=of_find_node_by_name(NULL, "power-mgt")) ) 493 if( !(np=of_find_node_by_name(NULL, "power-mgt")) )
494 return -ENODEV; 494 return -ENODEV;
495 info = get_property(np, "thermal-info", NULL); 495 info = of_get_property(np, "thermal-info", NULL);
496 of_node_put(np); 496 of_node_put(np);
497 497
498 if( !info || !machine_is_compatible("PowerMac3,6") ) 498 if( !info || !machine_is_compatible("PowerMac3,6") )
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
index d58fcf6cca0a..76d21775fc35 100644
--- a/drivers/macintosh/via-cuda.c
+++ b/drivers/macintosh/via-cuda.c
@@ -131,7 +131,7 @@ int __init find_via_cuda(void)
131 if (vias == 0) 131 if (vias == 0)
132 return 0; 132 return 0;
133 133
134 reg = get_property(vias, "reg", NULL); 134 reg = of_get_property(vias, "reg", NULL);
135 if (reg == NULL) { 135 if (reg == NULL) {
136 printk(KERN_ERR "via-cuda: No \"reg\" property !\n"); 136 printk(KERN_ERR "via-cuda: No \"reg\" property !\n");
137 goto fail; 137 goto fail;
diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c
index 179af10105d9..fc89a7047cd0 100644
--- a/drivers/macintosh/via-pmu-led.c
+++ b/drivers/macintosh/via-pmu-led.c
@@ -81,7 +81,7 @@ static struct led_classdev pmu_led = {
81}; 81};
82 82
83#ifdef CONFIG_PM 83#ifdef CONFIG_PM
84static int pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when) 84static void pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when)
85{ 85{
86 unsigned long flags; 86 unsigned long flags;
87 87
@@ -99,8 +99,6 @@ static int pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when)
99 break; 99 break;
100 } 100 }
101 spin_unlock_irqrestore(&pmu_blink_lock, flags); 101 spin_unlock_irqrestore(&pmu_blink_lock, flags);
102
103 return PBOOK_SLEEP_OK;
104} 102}
105 103
106static struct pmu_sleep_notifier via_pmu_led_sleep_notif = { 104static struct pmu_sleep_notifier via_pmu_led_sleep_notif = {
@@ -120,11 +118,13 @@ static int __init via_pmu_led_init(void)
120 dt = of_find_node_by_path("/"); 118 dt = of_find_node_by_path("/");
121 if (dt == NULL) 119 if (dt == NULL)
122 return -ENODEV; 120 return -ENODEV;
123 model = get_property(dt, "model", NULL); 121 model = of_get_property(dt, "model", NULL);
124 if (model == NULL) 122 if (model == NULL)
125 return -ENODEV; 123 return -ENODEV;
126 if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 && 124 if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
127 strncmp(model, "iBook", strlen("iBook")) != 0) { 125 strncmp(model, "iBook", strlen("iBook")) != 0 &&
126 strcmp(model, "PowerMac7,2") != 0 &&
127 strcmp(model, "PowerMac7,3") != 0) {
128 of_node_put(dt); 128 of_node_put(dt);
129 /* ignore */ 129 /* ignore */
130 return -ENODEV; 130 return -ENODEV;
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index b6073bdb50c3..1729d3fd7a11 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -289,7 +289,7 @@ int __init find_via_pmu(void)
289 if (vias == NULL) 289 if (vias == NULL)
290 return 0; 290 return 0;
291 291
292 reg = get_property(vias, "reg", NULL); 292 reg = of_get_property(vias, "reg", NULL);
293 if (reg == NULL) { 293 if (reg == NULL) {
294 printk(KERN_ERR "via-pmu: No \"reg\" property !\n"); 294 printk(KERN_ERR "via-pmu: No \"reg\" property !\n");
295 goto fail; 295 goto fail;
@@ -319,10 +319,13 @@ int __init find_via_pmu(void)
319 else if (device_is_compatible(vias->parent, "Keylargo") 319 else if (device_is_compatible(vias->parent, "Keylargo")
320 || device_is_compatible(vias->parent, "K2-Keylargo")) { 320 || device_is_compatible(vias->parent, "K2-Keylargo")) {
321 struct device_node *gpiop; 321 struct device_node *gpiop;
322 struct device_node *adbp;
322 u64 gaddr = OF_BAD_ADDR; 323 u64 gaddr = OF_BAD_ADDR;
323 324
324 pmu_kind = PMU_KEYLARGO_BASED; 325 pmu_kind = PMU_KEYLARGO_BASED;
325 pmu_has_adb = (find_type_devices("adb") != NULL); 326 adbp = of_find_node_by_type(NULL, "adb");
327 pmu_has_adb = (adbp != NULL);
328 of_node_put(adbp);
326 pmu_intr_mask = PMU_INT_PCEJECT | 329 pmu_intr_mask = PMU_INT_PCEJECT |
327 PMU_INT_SNDBRT | 330 PMU_INT_SNDBRT |
328 PMU_INT_ADB | 331 PMU_INT_ADB |
@@ -331,7 +334,7 @@ int __init find_via_pmu(void)
331 334
332 gpiop = of_find_node_by_name(NULL, "gpio"); 335 gpiop = of_find_node_by_name(NULL, "gpio");
333 if (gpiop) { 336 if (gpiop) {
334 reg = get_property(gpiop, "reg", NULL); 337 reg = of_get_property(gpiop, "reg", NULL);
335 if (reg) 338 if (reg)
336 gaddr = of_translate_address(gpiop, reg); 339 gaddr = of_translate_address(gpiop, reg);
337 if (gaddr != OF_BAD_ADDR) 340 if (gaddr != OF_BAD_ADDR)
@@ -484,10 +487,11 @@ static int __init via_pmu_dev_init(void)
484 pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART; 487 pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART;
485 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; 488 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART;
486 } else { 489 } else {
487 struct device_node* prim = find_devices("power-mgt"); 490 struct device_node* prim =
491 of_find_node_by_name(NULL, "power-mgt");
488 const u32 *prim_info = NULL; 492 const u32 *prim_info = NULL;
489 if (prim) 493 if (prim)
490 prim_info = get_property(prim, "prim-info", NULL); 494 prim_info = of_get_property(prim, "prim-info", NULL);
491 if (prim_info) { 495 if (prim_info) {
492 /* Other stuffs here yet unknown */ 496 /* Other stuffs here yet unknown */
493 pmu_battery_count = (prim_info[6] >> 16) & 0xff; 497 pmu_battery_count = (prim_info[6] >> 16) & 0xff;
@@ -495,6 +499,7 @@ static int __init via_pmu_dev_init(void)
495 if (pmu_battery_count > 1) 499 if (pmu_battery_count > 1)
496 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; 500 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART;
497 } 501 }
502 of_node_put(prim);
498 } 503 }
499#endif /* CONFIG_PPC32 */ 504#endif /* CONFIG_PPC32 */
500 505
@@ -1769,35 +1774,21 @@ EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
1769#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 1774#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
1770 1775
1771/* Sleep is broadcast last-to-first */ 1776/* Sleep is broadcast last-to-first */
1772static int 1777static void broadcast_sleep(int when)
1773broadcast_sleep(int when, int fallback)
1774{ 1778{
1775 int ret = PBOOK_SLEEP_OK;
1776 struct list_head *list; 1779 struct list_head *list;
1777 struct pmu_sleep_notifier *notifier; 1780 struct pmu_sleep_notifier *notifier;
1778 1781
1779 for (list = sleep_notifiers.prev; list != &sleep_notifiers; 1782 for (list = sleep_notifiers.prev; list != &sleep_notifiers;
1780 list = list->prev) { 1783 list = list->prev) {
1781 notifier = list_entry(list, struct pmu_sleep_notifier, list); 1784 notifier = list_entry(list, struct pmu_sleep_notifier, list);
1782 ret = notifier->notifier_call(notifier, when); 1785 notifier->notifier_call(notifier, when);
1783 if (ret != PBOOK_SLEEP_OK) {
1784 printk(KERN_DEBUG "sleep %d rejected by %p (%p)\n",
1785 when, notifier, notifier->notifier_call);
1786 for (; list != &sleep_notifiers; list = list->next) {
1787 notifier = list_entry(list, struct pmu_sleep_notifier, list);
1788 notifier->notifier_call(notifier, fallback);
1789 }
1790 return ret;
1791 }
1792 } 1786 }
1793 return ret;
1794} 1787}
1795 1788
1796/* Wake is broadcast first-to-last */ 1789/* Wake is broadcast first-to-last */
1797static int 1790static void broadcast_wake(void)
1798broadcast_wake(void)
1799{ 1791{
1800 int ret = PBOOK_SLEEP_OK;
1801 struct list_head *list; 1792 struct list_head *list;
1802 struct pmu_sleep_notifier *notifier; 1793 struct pmu_sleep_notifier *notifier;
1803 1794
@@ -1806,7 +1797,6 @@ broadcast_wake(void)
1806 notifier = list_entry(list, struct pmu_sleep_notifier, list); 1797 notifier = list_entry(list, struct pmu_sleep_notifier, list);
1807 notifier->notifier_call(notifier, PBOOK_WAKE); 1798 notifier->notifier_call(notifier, PBOOK_WAKE);
1808 } 1799 }
1809 return ret;
1810} 1800}
1811 1801
1812/* 1802/*
@@ -2013,12 +2003,8 @@ pmac_suspend_devices(void)
2013 2003
2014 pm_prepare_console(); 2004 pm_prepare_console();
2015 2005
2016 /* Notify old-style device drivers & userland */ 2006 /* Notify old-style device drivers */
2017 ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT); 2007 broadcast_sleep(PBOOK_SLEEP_REQUEST);
2018 if (ret != PBOOK_SLEEP_OK) {
2019 printk(KERN_ERR "Sleep rejected by drivers\n");
2020 return -EBUSY;
2021 }
2022 2008
2023 /* Sync the disks. */ 2009 /* Sync the disks. */
2024 /* XXX It would be nice to have some way to ensure that 2010 /* XXX It would be nice to have some way to ensure that
@@ -2028,12 +2014,7 @@ pmac_suspend_devices(void)
2028 */ 2014 */
2029 sys_sync(); 2015 sys_sync();
2030 2016
2031 /* Sleep can fail now. May not be very robust but useful for debugging */ 2017 broadcast_sleep(PBOOK_SLEEP_NOW);
2032 ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
2033 if (ret != PBOOK_SLEEP_OK) {
2034 printk(KERN_ERR "Driver sleep failed\n");
2035 return -EBUSY;
2036 }
2037 2018
2038 /* Send suspend call to devices, hold the device core's dpm_sem */ 2019 /* Send suspend call to devices, hold the device core's dpm_sem */
2039 ret = device_suspend(PMSG_SUSPEND); 2020 ret = device_suspend(PMSG_SUSPEND);
@@ -2154,7 +2135,7 @@ static int powerbook_sleep_grackle(void)
2154 int ret; 2135 int ret;
2155 struct pci_dev *grackle; 2136 struct pci_dev *grackle;
2156 2137
2157 grackle = pci_find_slot(0, 0); 2138 grackle = pci_get_bus_and_slot(0, 0);
2158 if (!grackle) 2139 if (!grackle)
2159 return -ENODEV; 2140 return -ENODEV;
2160 2141
@@ -2202,6 +2183,8 @@ static int powerbook_sleep_grackle(void)
2202 pmcr1 &= ~(GRACKLE_PM|GRACKLE_DOZE|GRACKLE_SLEEP|GRACKLE_NAP); 2183 pmcr1 &= ~(GRACKLE_PM|GRACKLE_DOZE|GRACKLE_SLEEP|GRACKLE_NAP);
2203 pci_write_config_word(grackle, 0x70, pmcr1); 2184 pci_write_config_word(grackle, 0x70, pmcr1);
2204 2185
2186 pci_dev_put(grackle);
2187
2205 /* Make sure the PMU is idle */ 2188 /* Make sure the PMU is idle */
2206 pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0); 2189 pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0);
2207 restore_via_state(); 2190 restore_via_state();
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c
index 3f7967feaf5b..ab4d1b63f63e 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -176,7 +176,7 @@ static int wf_lm75_attach(struct i2c_adapter *adapter)
176 for (dev = NULL; 176 for (dev = NULL;
177 (dev = of_get_next_child(busnode, dev)) != NULL;) { 177 (dev = of_get_next_child(busnode, dev)) != NULL;) {
178 const char *loc = 178 const char *loc =
179 get_property(dev, "hwsensor-location", NULL); 179 of_get_property(dev, "hwsensor-location", NULL);
180 u8 addr; 180 u8 addr;
181 181
182 /* We must re-match the adapter in order to properly check 182 /* We must re-match the adapter in order to properly check
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c b/drivers/macintosh/windfarm_max6690_sensor.c
index eae1189d6c41..eaa74afa175b 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -134,7 +134,7 @@ static int wf_max6690_attach(struct i2c_adapter *adapter)
134 if (!device_is_compatible(dev, "max6690")) 134 if (!device_is_compatible(dev, "max6690"))
135 continue; 135 continue;
136 addr = pmac_i2c_get_dev_addr(dev); 136 addr = pmac_i2c_get_dev_addr(dev);
137 loc = get_property(dev, "hwsensor-location", NULL); 137 loc = of_get_property(dev, "hwsensor-location", NULL);
138 if (loc == NULL || addr == 0) 138 if (loc == NULL || addr == 0)
139 continue; 139 continue;
140 printk("found max6690, loc=%s addr=0x%02x\n", loc, addr); 140 printk("found max6690, loc=%s addr=0x%02x\n", loc, addr);
diff --git a/drivers/macintosh/windfarm_smu_controls.c b/drivers/macintosh/windfarm_smu_controls.c
index 31b750d61206..ff398adc0283 100644
--- a/drivers/macintosh/windfarm_smu_controls.c
+++ b/drivers/macintosh/windfarm_smu_controls.c
@@ -167,7 +167,7 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node,
167 if (fct == NULL) 167 if (fct == NULL)
168 return NULL; 168 return NULL;
169 fct->ctrl.ops = &smu_fan_ops; 169 fct->ctrl.ops = &smu_fan_ops;
170 l = get_property(node, "location", NULL); 170 l = of_get_property(node, "location", NULL);
171 if (l == NULL) 171 if (l == NULL)
172 goto fail; 172 goto fail;
173 173
@@ -224,17 +224,17 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node,
224 goto fail; 224 goto fail;
225 225
226 /* Get min & max values*/ 226 /* Get min & max values*/
227 v = get_property(node, "min-value", NULL); 227 v = of_get_property(node, "min-value", NULL);
228 if (v == NULL) 228 if (v == NULL)
229 goto fail; 229 goto fail;
230 fct->min = *v; 230 fct->min = *v;
231 v = get_property(node, "max-value", NULL); 231 v = of_get_property(node, "max-value", NULL);
232 if (v == NULL) 232 if (v == NULL)
233 goto fail; 233 goto fail;
234 fct->max = *v; 234 fct->max = *v;
235 235
236 /* Get "reg" value */ 236 /* Get "reg" value */
237 reg = get_property(node, "reg", NULL); 237 reg = of_get_property(node, "reg", NULL);
238 if (reg == NULL) 238 if (reg == NULL)
239 goto fail; 239 goto fail;
240 fct->reg = *reg; 240 fct->reg = *reg;
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
index 83f79de7174b..9a6c2cf8fd0e 100644
--- a/drivers/macintosh/windfarm_smu_sat.c
+++ b/drivers/macintosh/windfarm_smu_sat.c
@@ -241,7 +241,7 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev)
241 char *name; 241 char *name;
242 int vsens[2], isens[2]; 242 int vsens[2], isens[2];
243 243
244 reg = get_property(dev, "reg", NULL); 244 reg = of_get_property(dev, "reg", NULL);
245 if (reg == NULL) 245 if (reg == NULL)
246 return; 246 return;
247 addr = *reg; 247 addr = *reg;
@@ -268,9 +268,9 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev)
268 isens[0] = isens[1] = -1; 268 isens[0] = isens[1] = -1;
269 child = NULL; 269 child = NULL;
270 while ((child = of_get_next_child(dev, child)) != NULL) { 270 while ((child = of_get_next_child(dev, child)) != NULL) {
271 reg = get_property(child, "reg", NULL); 271 reg = of_get_property(child, "reg", NULL);
272 type = get_property(child, "device_type", NULL); 272 type = of_get_property(child, "device_type", NULL);
273 loc = get_property(child, "location", NULL); 273 loc = of_get_property(child, "location", NULL);
274 if (reg == NULL || loc == NULL) 274 if (reg == NULL || loc == NULL)
275 continue; 275 continue;
276 276
diff --git a/drivers/macintosh/windfarm_smu_sensors.c b/drivers/macintosh/windfarm_smu_sensors.c
index 01b4c50143dd..9c567b93f417 100644
--- a/drivers/macintosh/windfarm_smu_sensors.c
+++ b/drivers/macintosh/windfarm_smu_sensors.c
@@ -204,8 +204,8 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
204 ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL); 204 ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL);
205 if (ads == NULL) 205 if (ads == NULL)
206 return NULL; 206 return NULL;
207 c = get_property(node, "device_type", NULL); 207 c = of_get_property(node, "device_type", NULL);
208 l = get_property(node, "location", NULL); 208 l = of_get_property(node, "location", NULL);
209 if (c == NULL || l == NULL) 209 if (c == NULL || l == NULL)
210 goto fail; 210 goto fail;
211 211
@@ -255,7 +255,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
255 } else 255 } else
256 goto fail; 256 goto fail;
257 257
258 v = get_property(node, "reg", NULL); 258 v = of_get_property(node, "reg", NULL);
259 if (v == NULL) 259 if (v == NULL)
260 goto fail; 260 goto fail;
261 ads->reg = *v; 261 ads->reg = *v;