aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh/smu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/macintosh/smu.c')
-rw-r--r--drivers/macintosh/smu.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index 32cb0298f88e..96faa799b82a 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -36,6 +36,8 @@
36#include <linux/sysdev.h> 36#include <linux/sysdev.h>
37#include <linux/poll.h> 37#include <linux/poll.h>
38#include <linux/mutex.h> 38#include <linux/mutex.h>
39#include <linux/of_device.h>
40#include <linux/of_platform.h>
39 41
40#include <asm/byteorder.h> 42#include <asm/byteorder.h>
41#include <asm/io.h> 43#include <asm/io.h>
@@ -46,8 +48,6 @@
46#include <asm/sections.h> 48#include <asm/sections.h>
47#include <asm/abs_addr.h> 49#include <asm/abs_addr.h>
48#include <asm/uaccess.h> 50#include <asm/uaccess.h>
49#include <asm/of_device.h>
50#include <asm/of_platform.h>
51 51
52#define VERSION "0.7" 52#define VERSION "0.7"
53#define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp." 53#define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp."
@@ -475,6 +475,7 @@ int __init smu_init (void)
475{ 475{
476 struct device_node *np; 476 struct device_node *np;
477 const u32 *data; 477 const u32 *data;
478 int ret = 0;
478 479
479 np = of_find_node_by_type(NULL, "smu"); 480 np = of_find_node_by_type(NULL, "smu");
480 if (np == NULL) 481 if (np == NULL)
@@ -484,16 +485,11 @@ int __init smu_init (void)
484 485
485 if (smu_cmdbuf_abs == 0) { 486 if (smu_cmdbuf_abs == 0) {
486 printk(KERN_ERR "SMU: Command buffer not allocated !\n"); 487 printk(KERN_ERR "SMU: Command buffer not allocated !\n");
487 of_node_put(np); 488 ret = -EINVAL;
488 return -EINVAL; 489 goto fail_np;
489 } 490 }
490 491
491 smu = alloc_bootmem(sizeof(struct smu_device)); 492 smu = alloc_bootmem(sizeof(struct smu_device));
492 if (smu == NULL) {
493 of_node_put(np);
494 return -ENOMEM;
495 }
496 memset(smu, 0, sizeof(*smu));
497 493
498 spin_lock_init(&smu->lock); 494 spin_lock_init(&smu->lock);
499 INIT_LIST_HEAD(&smu->cmd_list); 495 INIT_LIST_HEAD(&smu->cmd_list);
@@ -511,14 +507,14 @@ int __init smu_init (void)
511 smu->db_node = of_find_node_by_name(NULL, "smu-doorbell"); 507 smu->db_node = of_find_node_by_name(NULL, "smu-doorbell");
512 if (smu->db_node == NULL) { 508 if (smu->db_node == NULL) {
513 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n"); 509 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n");
514 goto fail; 510 ret = -ENXIO;
511 goto fail_bootmem;
515 } 512 }
516 data = of_get_property(smu->db_node, "reg", NULL); 513 data = of_get_property(smu->db_node, "reg", NULL);
517 if (data == NULL) { 514 if (data == NULL) {
518 of_node_put(smu->db_node);
519 smu->db_node = NULL;
520 printk(KERN_ERR "SMU: Can't find doorbell GPIO address !\n"); 515 printk(KERN_ERR "SMU: Can't find doorbell GPIO address !\n");
521 goto fail; 516 ret = -ENXIO;
517 goto fail_db_node;
522 } 518 }
523 519
524 /* Current setup has one doorbell GPIO that does both doorbell 520 /* Current setup has one doorbell GPIO that does both doorbell
@@ -552,7 +548,8 @@ int __init smu_init (void)
552 smu->db_buf = ioremap(0x8000860c, 0x1000); 548 smu->db_buf = ioremap(0x8000860c, 0x1000);
553 if (smu->db_buf == NULL) { 549 if (smu->db_buf == NULL) {
554 printk(KERN_ERR "SMU: Can't map doorbell buffer pointer !\n"); 550 printk(KERN_ERR "SMU: Can't map doorbell buffer pointer !\n");
555 goto fail; 551 ret = -ENXIO;
552 goto fail_msg_node;
556 } 553 }
557 554
558 /* U3 has an issue with NAP mode when issuing SMU commands */ 555 /* U3 has an issue with NAP mode when issuing SMU commands */
@@ -563,10 +560,17 @@ int __init smu_init (void)
563 sys_ctrler = SYS_CTRLER_SMU; 560 sys_ctrler = SYS_CTRLER_SMU;
564 return 0; 561 return 0;
565 562
566 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));
567 smu = NULL; 570 smu = NULL;
568 return -ENXIO; 571fail_np:
569 572 of_node_put(np);
573 return ret;
570} 574}
571 575
572 576