aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/macintosh')
-rw-r--r--drivers/macintosh/adb.c23
-rw-r--r--drivers/macintosh/adbhid.c2
-rw-r--r--drivers/macintosh/ans-lcd.c2
-rw-r--r--drivers/macintosh/macio_sysfs.c12
-rw-r--r--drivers/macintosh/mediabay.c34
-rw-r--r--drivers/macintosh/smu.c38
-rw-r--r--drivers/macintosh/therm_adt746x.c15
-rw-r--r--drivers/macintosh/therm_pm72.c4
-rw-r--r--drivers/macintosh/therm_windtunnel.c18
-rw-r--r--drivers/macintosh/via-pmu.c3
-rw-r--r--drivers/macintosh/via-pmu68k.c5
11 files changed, 98 insertions, 58 deletions
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index dbaad39020a1..e5d446804d32 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -46,7 +46,6 @@
46#endif 46#endif
47 47
48 48
49EXPORT_SYMBOL(adb_controller);
50EXPORT_SYMBOL(adb_client_list); 49EXPORT_SYMBOL(adb_client_list);
51 50
52extern struct adb_driver via_macii_driver; 51extern struct adb_driver via_macii_driver;
@@ -80,7 +79,7 @@ static struct adb_driver *adb_driver_list[] = {
80 79
81static struct class *adb_dev_class; 80static struct class *adb_dev_class;
82 81
83struct adb_driver *adb_controller; 82static struct adb_driver *adb_controller;
84BLOCKING_NOTIFIER_HEAD(adb_client_list); 83BLOCKING_NOTIFIER_HEAD(adb_client_list);
85static int adb_got_sleep; 84static int adb_got_sleep;
86static int adb_inited; 85static int adb_inited;
@@ -290,7 +289,7 @@ static int adb_resume(struct platform_device *dev)
290} 289}
291#endif /* CONFIG_PM */ 290#endif /* CONFIG_PM */
292 291
293int __init adb_init(void) 292static int __init adb_init(void)
294{ 293{
295 struct adb_driver *driver; 294 struct adb_driver *driver;
296 int i; 295 int i;
@@ -644,12 +643,18 @@ do_adb_query(struct adb_request *req)
644static int adb_open(struct inode *inode, struct file *file) 643static int adb_open(struct inode *inode, struct file *file)
645{ 644{
646 struct adbdev_state *state; 645 struct adbdev_state *state;
646 int ret = 0;
647 647
648 if (iminor(inode) > 0 || adb_controller == NULL) 648 lock_kernel();
649 return -ENXIO; 649 if (iminor(inode) > 0 || adb_controller == NULL) {
650 ret = -ENXIO;
651 goto out;
652 }
650 state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL); 653 state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
651 if (state == 0) 654 if (state == 0) {
652 return -ENOMEM; 655 ret = -ENOMEM;
656 goto out;
657 }
653 file->private_data = state; 658 file->private_data = state;
654 spin_lock_init(&state->lock); 659 spin_lock_init(&state->lock);
655 atomic_set(&state->n_pending, 0); 660 atomic_set(&state->n_pending, 0);
@@ -657,7 +662,9 @@ static int adb_open(struct inode *inode, struct file *file)
657 init_waitqueue_head(&state->wait_queue); 662 init_waitqueue_head(&state->wait_queue);
658 state->inuse = 1; 663 state->inuse = 1;
659 664
660 return 0; 665out:
666 unlock_kernel();
667 return ret;
661} 668}
662 669
663static int adb_release(struct inode *inode, struct file *file) 670static int adb_release(struct inode *inode, struct file *file)
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c
index b7f41d3823a6..5396c67ba0a4 100644
--- a/drivers/macintosh/adbhid.c
+++ b/drivers/macintosh/adbhid.c
@@ -75,7 +75,7 @@ static struct notifier_block adbhid_adb_notifier = {
75#define ADB_KEY_POWER_OLD 0x7e 75#define ADB_KEY_POWER_OLD 0x7e
76#define ADB_KEY_POWER 0x7f 76#define ADB_KEY_POWER 0x7f
77 77
78u16 adb_to_linux_keycodes[128] = { 78static const u16 adb_to_linux_keycodes[128] = {
79 /* 0x00 */ KEY_A, /* 30 */ 79 /* 0x00 */ KEY_A, /* 30 */
80 /* 0x01 */ KEY_S, /* 31 */ 80 /* 0x01 */ KEY_S, /* 31 */
81 /* 0x02 */ KEY_D, /* 32 */ 81 /* 0x02 */ KEY_D, /* 32 */
diff --git a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c
index 73c50bc02095..6a8221893256 100644
--- a/drivers/macintosh/ans-lcd.c
+++ b/drivers/macintosh/ans-lcd.c
@@ -3,6 +3,7 @@
3 */ 3 */
4 4
5#include <linux/types.h> 5#include <linux/types.h>
6#include <linux/smp_lock.h>
6#include <linux/errno.h> 7#include <linux/errno.h>
7#include <linux/kernel.h> 8#include <linux/kernel.h>
8#include <linux/miscdevice.h> 9#include <linux/miscdevice.h>
@@ -119,6 +120,7 @@ anslcd_ioctl( struct inode * inode, struct file * file,
119static int 120static int
120anslcd_open( struct inode * inode, struct file * file ) 121anslcd_open( struct inode * inode, struct file * file )
121{ 122{
123 cycle_kernel_lock();
122 return 0; 124 return 0;
123} 125}
124 126
diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c
index 112e5ef728f1..9e9453b58425 100644
--- a/drivers/macintosh/macio_sysfs.c
+++ b/drivers/macintosh/macio_sysfs.c
@@ -44,7 +44,7 @@ static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
44 struct of_device *ofdev = to_of_device(dev); 44 struct of_device *ofdev = to_of_device(dev);
45 int len; 45 int len;
46 46
47 len = of_device_get_modalias(ofdev, buf, PAGE_SIZE); 47 len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2);
48 48
49 buf[len] = '\n'; 49 buf[len] = '\n';
50 buf[len+1] = 0; 50 buf[len+1] = 0;
@@ -52,6 +52,15 @@ static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
52 return len+1; 52 return len+1;
53} 53}
54 54
55static ssize_t devspec_show(struct device *dev,
56 struct device_attribute *attr, char *buf)
57{
58 struct of_device *ofdev;
59
60 ofdev = to_of_device(dev);
61 return sprintf(buf, "%s\n", ofdev->node->full_name);
62}
63
55macio_config_of_attr (name, "%s\n"); 64macio_config_of_attr (name, "%s\n");
56macio_config_of_attr (type, "%s\n"); 65macio_config_of_attr (type, "%s\n");
57 66
@@ -60,5 +69,6 @@ struct device_attribute macio_dev_attrs[] = {
60 __ATTR_RO(type), 69 __ATTR_RO(type),
61 __ATTR_RO(compatible), 70 __ATTR_RO(compatible),
62 __ATTR_RO(modalias), 71 __ATTR_RO(modalias),
72 __ATTR_RO(devspec),
63 __ATTR_NULL 73 __ATTR_NULL
64}; 74};
diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c
index 82add26cc665..b1e5b4705250 100644
--- a/drivers/macintosh/mediabay.c
+++ b/drivers/macintosh/mediabay.c
@@ -21,6 +21,7 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/ide.h> 22#include <linux/ide.h>
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/mutex.h>
24#include <asm/prom.h> 25#include <asm/prom.h>
25#include <asm/pgtable.h> 26#include <asm/pgtable.h>
26#include <asm/io.h> 27#include <asm/io.h>
@@ -77,14 +78,14 @@ struct media_bay_info {
77 int index; 78 int index;
78 int cached_gpio; 79 int cached_gpio;
79 int sleeping; 80 int sleeping;
80 struct semaphore lock; 81 struct mutex lock;
81#ifdef CONFIG_BLK_DEV_IDE_PMAC 82#ifdef CONFIG_BLK_DEV_IDE_PMAC
82 ide_hwif_t *cd_port; 83 ide_hwif_t *cd_port;
83 void __iomem *cd_base; 84 void __iomem *cd_base;
84 int cd_irq; 85 int cd_irq;
85 int cd_retry; 86 int cd_retry;
86#endif 87#endif
87#if defined(CONFIG_BLK_DEV_IDE_PMAC) || defined(CONFIG_MAC_FLOPPY) 88#if defined(CONFIG_BLK_DEV_IDE_PMAC)
88 int cd_index; 89 int cd_index;
89#endif 90#endif
90}; 91};
@@ -417,6 +418,7 @@ static void poll_media_bay(struct media_bay_info* bay)
417 } 418 }
418} 419}
419 420
421#ifdef CONFIG_BLK_DEV_IDE_PMAC
420int check_media_bay(struct device_node *which_bay, int what) 422int check_media_bay(struct device_node *which_bay, int what)
421{ 423{
422 int i; 424 int i;
@@ -432,7 +434,6 @@ int check_media_bay(struct device_node *which_bay, int what)
432} 434}
433EXPORT_SYMBOL(check_media_bay); 435EXPORT_SYMBOL(check_media_bay);
434 436
435#ifdef CONFIG_BLK_DEV_IDE_PMAC
436int check_media_bay_by_base(unsigned long base, int what) 437int check_media_bay_by_base(unsigned long base, int what)
437{ 438{
438 int i; 439 int i;
@@ -459,27 +460,27 @@ int media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base,
459 if (bay->mdev && which_bay == bay->mdev->ofdev.node) { 460 if (bay->mdev && which_bay == bay->mdev->ofdev.node) {
460 int timeout = 5000, index = hwif->index; 461 int timeout = 5000, index = hwif->index;
461 462
462 down(&bay->lock); 463 mutex_lock(&bay->lock);
463 464
464 bay->cd_port = hwif; 465 bay->cd_port = hwif;
465 bay->cd_base = (void __iomem *) base; 466 bay->cd_base = (void __iomem *) base;
466 bay->cd_irq = irq; 467 bay->cd_irq = irq;
467 468
468 if ((MB_CD != bay->content_id) || bay->state != mb_up) { 469 if ((MB_CD != bay->content_id) || bay->state != mb_up) {
469 up(&bay->lock); 470 mutex_unlock(&bay->lock);
470 return 0; 471 return 0;
471 } 472 }
472 printk(KERN_DEBUG "Registered ide%d for media bay %d\n", index, i); 473 printk(KERN_DEBUG "Registered ide%d for media bay %d\n", index, i);
473 do { 474 do {
474 if (MB_IDE_READY(i)) { 475 if (MB_IDE_READY(i)) {
475 bay->cd_index = index; 476 bay->cd_index = index;
476 up(&bay->lock); 477 mutex_unlock(&bay->lock);
477 return 0; 478 return 0;
478 } 479 }
479 mdelay(1); 480 mdelay(1);
480 } while(--timeout); 481 } while(--timeout);
481 printk(KERN_DEBUG "Timeount waiting IDE in bay %d\n", i); 482 printk(KERN_DEBUG "Timeount waiting IDE in bay %d\n", i);
482 up(&bay->lock); 483 mutex_unlock(&bay->lock);
483 return -ENODEV; 484 return -ENODEV;
484 } 485 }
485 } 486 }
@@ -556,7 +557,8 @@ static void media_bay_step(int i)
556 printk("mediabay %d, registering IDE...\n", i); 557 printk("mediabay %d, registering IDE...\n", i);
557 pmu_suspend(); 558 pmu_suspend();
558 ide_port_scan(bay->cd_port); 559 ide_port_scan(bay->cd_port);
559 bay->cd_index = bay->cd_port->index; 560 if (bay->cd_port->present)
561 bay->cd_index = bay->cd_port->index;
560 pmu_resume(); 562 pmu_resume();
561 } 563 }
562 if (bay->cd_index == -1) { 564 if (bay->cd_index == -1) {
@@ -616,10 +618,10 @@ static int media_bay_task(void *x)
616 618
617 while (!kthread_should_stop()) { 619 while (!kthread_should_stop()) {
618 for (i = 0; i < media_bay_count; ++i) { 620 for (i = 0; i < media_bay_count; ++i) {
619 down(&media_bays[i].lock); 621 mutex_lock(&media_bays[i].lock);
620 if (!media_bays[i].sleeping) 622 if (!media_bays[i].sleeping)
621 media_bay_step(i); 623 media_bay_step(i);
622 up(&media_bays[i].lock); 624 mutex_unlock(&media_bays[i].lock);
623 } 625 }
624 626
625 msleep_interruptible(MB_POLL_DELAY); 627 msleep_interruptible(MB_POLL_DELAY);
@@ -659,7 +661,7 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_de
659 bay->index = i; 661 bay->index = i;
660 bay->ops = match->data; 662 bay->ops = match->data;
661 bay->sleeping = 0; 663 bay->sleeping = 0;
662 init_MUTEX(&bay->lock); 664 mutex_init(&bay->lock);
663 665
664 /* Init HW probing */ 666 /* Init HW probing */
665 if (bay->ops->init) 667 if (bay->ops->init)
@@ -697,10 +699,10 @@ static int media_bay_suspend(struct macio_dev *mdev, pm_message_t state)
697 699
698 if (state.event != mdev->ofdev.dev.power.power_state.event 700 if (state.event != mdev->ofdev.dev.power.power_state.event
699 && (state.event & PM_EVENT_SLEEP)) { 701 && (state.event & PM_EVENT_SLEEP)) {
700 down(&bay->lock); 702 mutex_lock(&bay->lock);
701 bay->sleeping = 1; 703 bay->sleeping = 1;
702 set_mb_power(bay, 0); 704 set_mb_power(bay, 0);
703 up(&bay->lock); 705 mutex_unlock(&bay->lock);
704 msleep(MB_POLL_DELAY); 706 msleep(MB_POLL_DELAY);
705 mdev->ofdev.dev.power.power_state = state; 707 mdev->ofdev.dev.power.power_state = state;
706 } 708 }
@@ -719,12 +721,12 @@ static int media_bay_resume(struct macio_dev *mdev)
719 they seem to help the 3400 get it right. 721 they seem to help the 3400 get it right.
720 */ 722 */
721 /* Force MB power to 0 */ 723 /* Force MB power to 0 */
722 down(&bay->lock); 724 mutex_lock(&bay->lock);
723 set_mb_power(bay, 0); 725 set_mb_power(bay, 0);
724 msleep(MB_POWER_DELAY); 726 msleep(MB_POWER_DELAY);
725 if (bay->ops->content(bay) != bay->content_id) { 727 if (bay->ops->content(bay) != bay->content_id) {
726 printk("mediabay%d: content changed during sleep...\n", bay->index); 728 printk("mediabay%d: content changed during sleep...\n", bay->index);
727 up(&bay->lock); 729 mutex_unlock(&bay->lock);
728 return 0; 730 return 0;
729 } 731 }
730 set_mb_power(bay, 1); 732 set_mb_power(bay, 1);
@@ -740,7 +742,7 @@ static int media_bay_resume(struct macio_dev *mdev)
740 } while((bay->state != mb_empty) && 742 } while((bay->state != mb_empty) &&
741 (bay->state != mb_up)); 743 (bay->state != mb_up));
742 bay->sleeping = 0; 744 bay->sleeping = 0;
743 up(&bay->lock); 745 mutex_unlock(&bay->lock);
744 } 746 }
745 return 0; 747 return 0;
746} 748}
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index 77ad192962c5..96faa799b82a 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -19,6 +19,7 @@
19 * the userland interface 19 * the userland interface
20 */ 20 */
21 21
22#include <linux/smp_lock.h>
22#include <linux/types.h> 23#include <linux/types.h>
23#include <linux/kernel.h> 24#include <linux/kernel.h>
24#include <linux/device.h> 25#include <linux/device.h>
@@ -35,6 +36,8 @@
35#include <linux/sysdev.h> 36#include <linux/sysdev.h>
36#include <linux/poll.h> 37#include <linux/poll.h>
37#include <linux/mutex.h> 38#include <linux/mutex.h>
39#include <linux/of_device.h>
40#include <linux/of_platform.h>
38 41
39#include <asm/byteorder.h> 42#include <asm/byteorder.h>
40#include <asm/io.h> 43#include <asm/io.h>
@@ -45,8 +48,6 @@
45#include <asm/sections.h> 48#include <asm/sections.h>
46#include <asm/abs_addr.h> 49#include <asm/abs_addr.h>
47#include <asm/uaccess.h> 50#include <asm/uaccess.h>
48#include <asm/of_device.h>
49#include <asm/of_platform.h>
50 51
51#define VERSION "0.7" 52#define VERSION "0.7"
52#define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp." 53#define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp."
@@ -474,6 +475,7 @@ int __init smu_init (void)
474{ 475{
475 struct device_node *np; 476 struct device_node *np;
476 const u32 *data; 477 const u32 *data;
478 int ret = 0;
477 479
478 np = of_find_node_by_type(NULL, "smu"); 480 np = of_find_node_by_type(NULL, "smu");
479 if (np == NULL) 481 if (np == NULL)
@@ -483,13 +485,11 @@ int __init smu_init (void)
483 485
484 if (smu_cmdbuf_abs == 0) { 486 if (smu_cmdbuf_abs == 0) {
485 printk(KERN_ERR "SMU: Command buffer not allocated !\n"); 487 printk(KERN_ERR "SMU: Command buffer not allocated !\n");
486 return -EINVAL; 488 ret = -EINVAL;
489 goto fail_np;
487 } 490 }
488 491
489 smu = alloc_bootmem(sizeof(struct smu_device)); 492 smu = alloc_bootmem(sizeof(struct smu_device));
490 if (smu == NULL)
491 return -ENOMEM;
492 memset(smu, 0, sizeof(*smu));
493 493
494 spin_lock_init(&smu->lock); 494 spin_lock_init(&smu->lock);
495 INIT_LIST_HEAD(&smu->cmd_list); 495 INIT_LIST_HEAD(&smu->cmd_list);
@@ -507,14 +507,14 @@ int __init smu_init (void)
507 smu->db_node = of_find_node_by_name(NULL, "smu-doorbell"); 507 smu->db_node = of_find_node_by_name(NULL, "smu-doorbell");
508 if (smu->db_node == NULL) { 508 if (smu->db_node == NULL) {
509 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n"); 509 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n");
510 goto fail; 510 ret = -ENXIO;
511 goto fail_bootmem;
511 } 512 }
512 data = of_get_property(smu->db_node, "reg", NULL); 513 data = of_get_property(smu->db_node, "reg", NULL);
513 if (data == NULL) { 514 if (data == NULL) {
514 of_node_put(smu->db_node);
515 smu->db_node = NULL;
516 printk(KERN_ERR "SMU: Can't find doorbell GPIO address !\n"); 515 printk(KERN_ERR "SMU: Can't find doorbell GPIO address !\n");
517 goto fail; 516 ret = -ENXIO;
517 goto fail_db_node;
518 } 518 }
519 519
520 /* Current setup has one doorbell GPIO that does both doorbell 520 /* Current setup has one doorbell GPIO that does both doorbell
@@ -548,7 +548,8 @@ int __init smu_init (void)
548 smu->db_buf = ioremap(0x8000860c, 0x1000); 548 smu->db_buf = ioremap(0x8000860c, 0x1000);
549 if (smu->db_buf == NULL) { 549 if (smu->db_buf == NULL) {
550 printk(KERN_ERR "SMU: Can't map doorbell buffer pointer !\n"); 550 printk(KERN_ERR "SMU: Can't map doorbell buffer pointer !\n");
551 goto fail; 551 ret = -ENXIO;
552 goto fail_msg_node;
552 } 553 }
553 554
554 /* U3 has an issue with NAP mode when issuing SMU commands */ 555 /* U3 has an issue with NAP mode when issuing SMU commands */
@@ -559,10 +560,17 @@ int __init smu_init (void)
559 sys_ctrler = SYS_CTRLER_SMU; 560 sys_ctrler = SYS_CTRLER_SMU;
560 return 0; 561 return 0;
561 562
562 fail: 563fail_msg_node:
564 if (smu->msg_node)
565 of_node_put(smu->msg_node);
566fail_db_node:
567 of_node_put(smu->db_node);
568fail_bootmem:
569 free_bootmem((unsigned long)smu, sizeof(struct smu_device));
563 smu = NULL; 570 smu = NULL;
564 return -ENXIO; 571fail_np:
565 572 of_node_put(np);
573 return ret;
566} 574}
567 575
568 576
@@ -1083,10 +1091,12 @@ static int smu_open(struct inode *inode, struct file *file)
1083 pp->mode = smu_file_commands; 1091 pp->mode = smu_file_commands;
1084 init_waitqueue_head(&pp->wait); 1092 init_waitqueue_head(&pp->wait);
1085 1093
1094 lock_kernel();
1086 spin_lock_irqsave(&smu_clist_lock, flags); 1095 spin_lock_irqsave(&smu_clist_lock, flags);
1087 list_add(&pp->list, &smu_clist); 1096 list_add(&pp->list, &smu_clist);
1088 spin_unlock_irqrestore(&smu_clist_lock, flags); 1097 spin_unlock_irqrestore(&smu_clist_lock, flags);
1089 file->private_data = pp; 1098 file->private_data = pp;
1099 unlock_kernel();
1090 1100
1091 return 0; 1101 return 0;
1092} 1102}
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index 54f4942a2968..22bf981d393b 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -24,13 +24,13 @@
24#include <linux/kthread.h> 24#include <linux/kthread.h>
25#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
26#include <linux/freezer.h> 26#include <linux/freezer.h>
27#include <linux/of_platform.h>
27 28
28#include <asm/prom.h> 29#include <asm/prom.h>
29#include <asm/machdep.h> 30#include <asm/machdep.h>
30#include <asm/io.h> 31#include <asm/io.h>
31#include <asm/system.h> 32#include <asm/system.h>
32#include <asm/sections.h> 33#include <asm/sections.h>
33#include <asm/of_platform.h>
34 34
35#undef DEBUG 35#undef DEBUG
36 36
@@ -562,18 +562,24 @@ thermostat_init(void)
562 therm_type = ADT7460; 562 therm_type = ADT7460;
563 else if (of_device_is_compatible(np, "adt7467")) 563 else if (of_device_is_compatible(np, "adt7467"))
564 therm_type = ADT7467; 564 therm_type = ADT7467;
565 else 565 else {
566 of_node_put(np);
566 return -ENODEV; 567 return -ENODEV;
568 }
567 569
568 prop = of_get_property(np, "hwsensor-params-version", NULL); 570 prop = of_get_property(np, "hwsensor-params-version", NULL);
569 printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop, 571 printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop,
570 (*prop == 1)?"":"un"); 572 (*prop == 1)?"":"un");
571 if (*prop != 1) 573 if (*prop != 1) {
574 of_node_put(np);
572 return -ENODEV; 575 return -ENODEV;
576 }
573 577
574 prop = of_get_property(np, "reg", NULL); 578 prop = of_get_property(np, "reg", NULL);
575 if (!prop) 579 if (!prop) {
580 of_node_put(np);
576 return -ENODEV; 581 return -ENODEV;
582 }
577 583
578 /* look for bus either by path or using "reg" */ 584 /* look for bus either by path or using "reg" */
579 if (strstr(np->full_name, "/i2c-bus@") != NULL) { 585 if (strstr(np->full_name, "/i2c-bus@") != NULL) {
@@ -610,6 +616,7 @@ thermostat_init(void)
610 616
611 if (of_dev == NULL) { 617 if (of_dev == NULL) {
612 printk(KERN_ERR "Can't register temperatures device !\n"); 618 printk(KERN_ERR "Can't register temperatures device !\n");
619 of_node_put(np);
613 return -ENODEV; 620 return -ENODEV;
614 } 621 }
615 622
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index ddfb426a9abd..817607e2af6a 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -123,14 +123,14 @@
123#include <linux/i2c.h> 123#include <linux/i2c.h>
124#include <linux/kthread.h> 124#include <linux/kthread.h>
125#include <linux/mutex.h> 125#include <linux/mutex.h>
126#include <linux/of_device.h>
127#include <linux/of_platform.h>
126#include <asm/prom.h> 128#include <asm/prom.h>
127#include <asm/machdep.h> 129#include <asm/machdep.h>
128#include <asm/io.h> 130#include <asm/io.h>
129#include <asm/system.h> 131#include <asm/system.h>
130#include <asm/sections.h> 132#include <asm/sections.h>
131#include <asm/of_device.h>
132#include <asm/macio.h> 133#include <asm/macio.h>
133#include <asm/of_platform.h>
134 134
135#include "therm_pm72.h" 135#include "therm_pm72.h"
136 136
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index d11821af3b8d..3da0a02efd76 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -37,13 +37,13 @@
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/kthread.h> 39#include <linux/kthread.h>
40#include <linux/of_platform.h>
40 41
41#include <asm/prom.h> 42#include <asm/prom.h>
42#include <asm/machdep.h> 43#include <asm/machdep.h>
43#include <asm/io.h> 44#include <asm/io.h>
44#include <asm/system.h> 45#include <asm/system.h>
45#include <asm/sections.h> 46#include <asm/sections.h>
46#include <asm/of_platform.h>
47#include <asm/macio.h> 47#include <asm/macio.h>
48 48
49#define LOG_TEMP 0 /* continously log temperature */ 49#define LOG_TEMP 0 /* continously log temperature */
@@ -62,7 +62,7 @@ static struct {
62 volatile int running; 62 volatile int running;
63 struct task_struct *poll_task; 63 struct task_struct *poll_task;
64 64
65 struct semaphore lock; 65 struct mutex lock;
66 struct of_device *of_dev; 66 struct of_device *of_dev;
67 67
68 struct i2c_client *thermostat; 68 struct i2c_client *thermostat;
@@ -286,23 +286,23 @@ restore_regs( void )
286 286
287static int control_loop(void *dummy) 287static int control_loop(void *dummy)
288{ 288{
289 down(&x.lock); 289 mutex_lock(&x.lock);
290 setup_hardware(); 290 setup_hardware();
291 up(&x.lock); 291 mutex_unlock(&x.lock);
292 292
293 for (;;) { 293 for (;;) {
294 msleep_interruptible(8000); 294 msleep_interruptible(8000);
295 if (kthread_should_stop()) 295 if (kthread_should_stop())
296 break; 296 break;
297 297
298 down(&x.lock); 298 mutex_lock(&x.lock);
299 poll_temp(); 299 poll_temp();
300 up(&x.lock); 300 mutex_unlock(&x.lock);
301 } 301 }
302 302
303 down(&x.lock); 303 mutex_lock(&x.lock);
304 restore_regs(); 304 restore_regs();
305 up(&x.lock); 305 mutex_unlock(&x.lock);
306 306
307 return 0; 307 return 0;
308} 308}
@@ -489,7 +489,7 @@ g4fan_init( void )
489 const struct apple_thermal_info *info; 489 const struct apple_thermal_info *info;
490 struct device_node *np; 490 struct device_node *np;
491 491
492 init_MUTEX( &x.lock ); 492 mutex_init(&x.lock);
493 493
494 if( !(np=of_find_node_by_name(NULL, "power-mgt")) ) 494 if( !(np=of_find_node_by_name(NULL, "power-mgt")) )
495 return -ENODEV; 495 return -ENODEV;
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index d6365a9f0637..d524dc245a2c 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -18,6 +18,7 @@
18 * 18 *
19 */ 19 */
20#include <stdarg.h> 20#include <stdarg.h>
21#include <linux/smp_lock.h>
21#include <linux/types.h> 22#include <linux/types.h>
22#include <linux/errno.h> 23#include <linux/errno.h>
23#include <linux/kernel.h> 24#include <linux/kernel.h>
@@ -2047,6 +2048,7 @@ pmu_open(struct inode *inode, struct file *file)
2047 pp->rb_get = pp->rb_put = 0; 2048 pp->rb_get = pp->rb_put = 0;
2048 spin_lock_init(&pp->lock); 2049 spin_lock_init(&pp->lock);
2049 init_waitqueue_head(&pp->wait); 2050 init_waitqueue_head(&pp->wait);
2051 lock_kernel();
2050 spin_lock_irqsave(&all_pvt_lock, flags); 2052 spin_lock_irqsave(&all_pvt_lock, flags);
2051#if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) 2053#if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
2052 pp->backlight_locker = 0; 2054 pp->backlight_locker = 0;
@@ -2054,6 +2056,7 @@ pmu_open(struct inode *inode, struct file *file)
2054 list_add(&pp->list, &all_pmu_pvt); 2056 list_add(&pp->list, &all_pmu_pvt);
2055 spin_unlock_irqrestore(&all_pvt_lock, flags); 2057 spin_unlock_irqrestore(&all_pvt_lock, flags);
2056 file->private_data = pp; 2058 file->private_data = pp;
2059 unlock_kernel();
2057 return 0; 2060 return 0;
2058} 2061}
2059 2062
diff --git a/drivers/macintosh/via-pmu68k.c b/drivers/macintosh/via-pmu68k.c
index e2f84da09e7c..b64741c95ac4 100644
--- a/drivers/macintosh/via-pmu68k.c
+++ b/drivers/macintosh/via-pmu68k.c
@@ -101,7 +101,6 @@ static int pmu_kind = PMU_UNKNOWN;
101static int pmu_fully_inited; 101static int pmu_fully_inited;
102 102
103int asleep; 103int asleep;
104BLOCKING_NOTIFIER_HEAD(sleep_notifier_list);
105 104
106static int pmu_probe(void); 105static int pmu_probe(void);
107static int pmu_init(void); 106static int pmu_init(void);
@@ -741,8 +740,8 @@ pmu_handle_data(unsigned char *data, int len)
741 } 740 }
742} 741}
743 742
744int backlight_level = -1; 743static int backlight_level = -1;
745int backlight_enabled = 0; 744static int backlight_enabled = 0;
746 745
747#define LEVEL_TO_BRIGHT(lev) ((lev) < 1? 0x7f: 0x4a - ((lev) << 1)) 746#define LEVEL_TO_BRIGHT(lev) ((lev) < 1? 0x7f: 0x4a - ((lev) << 1))
748 747