aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/oss/dmasound/dmasound_awacs.c90
-rw-r--r--sound/oss/dmasound/tas_common.c5
-rw-r--r--sound/ppc/pmac.c27
-rw-r--r--sound/ppc/tumbler.c35
4 files changed, 103 insertions, 54 deletions
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c
index 977b91cea603..730fa1d001a5 100644
--- a/sound/oss/dmasound/dmasound_awacs.c
+++ b/sound/oss/dmasound/dmasound_awacs.c
@@ -346,14 +346,16 @@ int gpio_headphone_irq;
346int 346int
347setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int* gpio_pol) 347setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int* gpio_pol)
348{ 348{
349 struct device_node *gpiop;
349 struct device_node *np; 350 struct device_node *np;
350 const u32* pp; 351 const u32* pp;
352 int ret = -ENODEV;
351 353
352 np = find_devices("gpio"); 354 gpiop = of_find_node_by_name(NULL, "gpio");
353 if (!np) 355 if (!gpiop)
354 return -ENODEV; 356 goto done;
355 357
356 np = np->child; 358 np = of_get_next_child(gpiop, NULL);
357 while(np != 0) { 359 while(np != 0) {
358 if (name) { 360 if (name) {
359 const char *property = 361 const char *property =
@@ -362,20 +364,24 @@ setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int*
362 break; 364 break;
363 } else if (compatible && device_is_compatible(np, compatible)) 365 } else if (compatible && device_is_compatible(np, compatible))
364 break; 366 break;
365 np = np->sibling; 367 np = of_get_next_child(gpiop, np);
366 } 368 }
367 if (!np) 369 if (!np)
368 return -ENODEV; 370 goto done;
369 pp = of_get_property(np, "AAPL,address", NULL); 371 pp = of_get_property(np, "AAPL,address", NULL);
370 if (!pp) 372 if (!pp)
371 return -ENODEV; 373 goto done;
372 *gpio_addr = (*pp) & 0x0000ffff; 374 *gpio_addr = (*pp) & 0x0000ffff;
373 pp = of_get_property(np, "audio-gpio-active-state", NULL); 375 pp = of_get_property(np, "audio-gpio-active-state", NULL);
374 if (pp) 376 if (pp)
375 *gpio_pol = *pp; 377 *gpio_pol = *pp;
376 else 378 else
377 *gpio_pol = 1; 379 *gpio_pol = 1;
378 return irq_of_parse_and_map(np, 0); 380 ret = irq_of_parse_and_map(np, 0);
381done:
382 of_node_put(np);
383 of_node_put(gpiop);
384 return ret;
379} 385}
380 386
381static inline void 387static inline void
@@ -2552,32 +2558,33 @@ set_model(void)
2552static struct device_node* __init 2558static struct device_node* __init
2553get_snd_io_node(void) 2559get_snd_io_node(void)
2554{ 2560{
2555 struct device_node *np = NULL; 2561 struct device_node *np;
2556 2562
2557 /* set up awacs_node for early OF which doesn't have a full set of 2563 /* set up awacs_node for early OF which doesn't have a full set of
2558 * properties on davbus 2564 * properties on davbus
2559 */ 2565 */
2560 2566 awacs_node = of_find_node_by_name(NULL, "awacs");
2561 awacs_node = find_devices("awacs");
2562 if (awacs_node) 2567 if (awacs_node)
2563 awacs_revision = AWACS_AWACS; 2568 awacs_revision = AWACS_AWACS;
2564 2569
2565 /* powermac models after 9500 (other than those which use DACA or 2570 /* powermac models after 9500 (other than those which use DACA or
2566 * Tumbler) have a node called "davbus". 2571 * Tumbler) have a node called "davbus".
2567 */ 2572 */
2568 np = find_devices("davbus"); 2573 np = of_find_node_by_name(NULL, "davbus");
2569 /* 2574 /*
2570 * if we didn't find a davbus device, try 'i2s-a' since 2575 * if we didn't find a davbus device, try 'i2s-a' since
2571 * this seems to be what iBooks (& Tumbler) have. 2576 * this seems to be what iBooks (& Tumbler) have.
2572 */ 2577 */
2573 if (np == NULL) 2578 if (np == NULL) {
2574 np = i2s_node = find_devices("i2s-a"); 2579 i2s_node = of_find_node_by_name(NULL, "i2s-a");
2580 np = of_node_get(i2s_node);
2581 }
2575 2582
2576 /* if we didn't find this - perhaps we are on an early model 2583 /* if we didn't find this - perhaps we are on an early model
2577 * which _only_ has an 'awacs' node 2584 * which _only_ has an 'awacs' node
2578 */ 2585 */
2579 if (np == NULL && awacs_node) 2586 if (np == NULL && awacs_node)
2580 np = awacs_node ; 2587 np = of_node_get(awacs_node);
2581 2588
2582 /* if we failed all these return null - this will cause the 2589 /* if we failed all these return null - this will cause the
2583 * driver to give up... 2590 * driver to give up...
@@ -2596,9 +2603,9 @@ get_snd_info_node(struct device_node *io)
2596{ 2603{
2597 struct device_node *info; 2604 struct device_node *info;
2598 2605
2599 info = find_devices("sound"); 2606 for_each_node_by_name(info, "sound")
2600 while (info && info->parent != io) 2607 if (info->parent == io)
2601 info = info->next; 2608 break;
2602 return info; 2609 return info;
2603} 2610}
2604 2611
@@ -2634,11 +2641,17 @@ get_codec_type(struct device_node *info)
2634static void __init 2641static void __init
2635get_expansion_type(void) 2642get_expansion_type(void)
2636{ 2643{
2637 if (find_devices("perch") != NULL) 2644 struct device_node *dn;
2645
2646 dn = of_find_node_by_name(NULL, "perch");
2647 if (dn != NULL)
2638 has_perch = 1; 2648 has_perch = 1;
2649 of_node_put(dn);
2639 2650
2640 if (find_devices("pb-ziva-pc") != NULL) 2651 dn = of_find_node_by_name(NULL, "pb-ziva-pc");
2652 if (dn != NULL)
2641 has_ziva = 1; 2653 has_ziva = 1;
2654 of_node_put(dn);
2642 /* need to work out how we deal with iMac SRS module */ 2655 /* need to work out how we deal with iMac SRS module */
2643} 2656}
2644 2657
@@ -2827,7 +2840,7 @@ int __init dmasound_awacs_init(void)
2827#ifdef DEBUG_DMASOUND 2840#ifdef DEBUG_DMASOUND
2828printk("dmasound_pmac: couldn't find sound io OF node\n"); 2841printk("dmasound_pmac: couldn't find sound io OF node\n");
2829#endif 2842#endif
2830 return -ENODEV ; 2843 goto no_device;
2831 } 2844 }
2832 2845
2833 /* find the OF node that tells us about the sound sub-system 2846 /* find the OF node that tells us about the sound sub-system
@@ -2839,7 +2852,7 @@ printk("dmasound_pmac: couldn't find sound io OF node\n");
2839#ifdef DEBUG_DMASOUND 2852#ifdef DEBUG_DMASOUND
2840printk("dmasound_pmac: couldn't find 'sound' OF node\n"); 2853printk("dmasound_pmac: couldn't find 'sound' OF node\n");
2841#endif 2854#endif
2842 return -ENODEV ; 2855 goto no_device;
2843 } 2856 }
2844 } 2857 }
2845 2858
@@ -2848,7 +2861,7 @@ printk("dmasound_pmac: couldn't find 'sound' OF node\n");
2848#ifdef DEBUG_DMASOUND 2861#ifdef DEBUG_DMASOUND
2849printk("dmasound_pmac: couldn't find a Codec we can handle\n"); 2862printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2850#endif 2863#endif
2851 return -ENODEV ; /* we don't know this type of h/w */ 2864 goto no_device; /* we don't know this type of h/w */
2852 } 2865 }
2853 2866
2854 /* set up perch, ziva, SRS or whatever else we have as sound 2867 /* set up perch, ziva, SRS or whatever else we have as sound
@@ -2866,11 +2879,12 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2866 * machines). 2879 * machines).
2867 */ 2880 */
2868 if (awacs_node) { 2881 if (awacs_node) {
2869 io = awacs_node ; 2882 of_node_put(io);
2883 io = of_node_get(awacs_node);
2870 if (of_get_address(io, 2, NULL, NULL) == NULL) { 2884 if (of_get_address(io, 2, NULL, NULL) == NULL) {
2871 printk("dmasound_pmac: can't use %s\n", 2885 printk("dmasound_pmac: can't use %s\n",
2872 io->full_name); 2886 io->full_name);
2873 return -ENODEV; 2887 goto no_device;
2874 } 2888 }
2875 } else 2889 } else
2876 printk("dmasound_pmac: can't use %s\n", io->full_name); 2890 printk("dmasound_pmac: can't use %s\n", io->full_name);
@@ -2881,7 +2895,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2881 awacs_rsrc[0].end - awacs_rsrc[0].start + 1, 2895 awacs_rsrc[0].end - awacs_rsrc[0].start + 1,
2882 " (IO)") == NULL) { 2896 " (IO)") == NULL) {
2883 printk(KERN_ERR "dmasound: can't request IO resource !\n"); 2897 printk(KERN_ERR "dmasound: can't request IO resource !\n");
2884 return -ENODEV; 2898 goto no_device;
2885 } 2899 }
2886 if (of_address_to_resource(io, 1, &awacs_rsrc[1]) || 2900 if (of_address_to_resource(io, 1, &awacs_rsrc[1]) ||
2887 request_mem_region(awacs_rsrc[1].start, 2901 request_mem_region(awacs_rsrc[1].start,
@@ -2890,7 +2904,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2890 release_mem_region(awacs_rsrc[0].start, 2904 release_mem_region(awacs_rsrc[0].start,
2891 awacs_rsrc[0].end - awacs_rsrc[0].start + 1); 2905 awacs_rsrc[0].end - awacs_rsrc[0].start + 1);
2892 printk(KERN_ERR "dmasound: can't request Tx DMA resource !\n"); 2906 printk(KERN_ERR "dmasound: can't request Tx DMA resource !\n");
2893 return -ENODEV; 2907 goto no_device;
2894 } 2908 }
2895 if (of_address_to_resource(io, 2, &awacs_rsrc[2]) || 2909 if (of_address_to_resource(io, 2, &awacs_rsrc[2]) ||
2896 request_mem_region(awacs_rsrc[2].start, 2910 request_mem_region(awacs_rsrc[2].start,
@@ -2901,7 +2915,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2901 release_mem_region(awacs_rsrc[1].start, 2915 release_mem_region(awacs_rsrc[1].start,
2902 awacs_rsrc[1].end - awacs_rsrc[1].start + 1); 2916 awacs_rsrc[1].end - awacs_rsrc[1].start + 1);
2903 printk(KERN_ERR "dmasound: can't request Rx DMA resource !\n"); 2917 printk(KERN_ERR "dmasound: can't request Rx DMA resource !\n");
2904 return -ENODEV; 2918 goto no_device;
2905 } 2919 }
2906 2920
2907 awacs_beep_dev = input_allocate_device(); 2921 awacs_beep_dev = input_allocate_device();
@@ -2913,7 +2927,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2913 release_mem_region(awacs_rsrc[2].start, 2927 release_mem_region(awacs_rsrc[2].start,
2914 awacs_rsrc[2].end - awacs_rsrc[2].start + 1); 2928 awacs_rsrc[2].end - awacs_rsrc[2].start + 1);
2915 printk(KERN_ERR "dmasound: can't allocate input device !\n"); 2929 printk(KERN_ERR "dmasound: can't allocate input device !\n");
2916 return -ENOMEM; 2930 goto no_device;
2917 } 2931 }
2918 2932
2919 awacs_beep_dev->name = "dmasound beeper"; 2933 awacs_beep_dev->name = "dmasound beeper";
@@ -2941,7 +2955,8 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2941 awacs_rx_irq = irq_of_parse_and_map(io, 2); 2955 awacs_rx_irq = irq_of_parse_and_map(io, 2);
2942 2956
2943 /* Hack for legacy crap that will be killed someday */ 2957 /* Hack for legacy crap that will be killed someday */
2944 awacs_node = io; 2958 of_node_put(awacs_node);
2959 awacs_node = of_node_get(io);
2945 2960
2946 /* if we have an awacs or screamer - probe the chip to make 2961 /* if we have an awacs or screamer - probe the chip to make
2947 * sure we have the right revision. 2962 * sure we have the right revision.
@@ -2990,6 +3005,8 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev);
2990 3005
2991 /* if it's there use it to set up frame rates */ 3006 /* if it's there use it to set up frame rates */
2992 init_frame_rates(prop, l) ; 3007 init_frame_rates(prop, l) ;
3008 of_node_put(info);
3009 info = NULL;
2993 } 3010 }
2994 3011
2995 if (awacs) 3012 if (awacs)
@@ -3159,7 +3176,16 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev);
3159 */ 3176 */
3160 input_register_device(awacs_beep_dev); 3177 input_register_device(awacs_beep_dev);
3161 3178
3179 of_node_put(io);
3180
3162 return dmasound_init(); 3181 return dmasound_init();
3182
3183no_device:
3184 of_node_put(info);
3185 of_node_put(awacs_node);
3186 of_node_put(i2s_node);
3187 of_node_put(io);
3188 return -ENODEV ;
3163} 3189}
3164 3190
3165static void __exit dmasound_awacs_cleanup(void) 3191static void __exit dmasound_awacs_cleanup(void)
@@ -3178,6 +3204,8 @@ static void __exit dmasound_awacs_cleanup(void)
3178 } 3204 }
3179 dmasound_deinit(); 3205 dmasound_deinit();
3180 3206
3207 of_node_put(awacs_node);
3208 of_node_put(i2s_node);
3181} 3209}
3182 3210
3183MODULE_DESCRIPTION("PowerMac built-in audio driver."); 3211MODULE_DESCRIPTION("PowerMac built-in audio driver.");
diff --git a/sound/oss/dmasound/tas_common.c b/sound/oss/dmasound/tas_common.c
index 11257600d6d0..b295ef682192 100644
--- a/sound/oss/dmasound/tas_common.c
+++ b/sound/oss/dmasound/tas_common.c
@@ -41,7 +41,6 @@
41 41
42static u8 tas_i2c_address = 0x34; 42static u8 tas_i2c_address = 0x34;
43static struct i2c_client *tas_client; 43static struct i2c_client *tas_client;
44static struct device_node* tas_node;
45 44
46static int tas_attach_adapter(struct i2c_adapter *); 45static int tas_attach_adapter(struct i2c_adapter *);
47static int tas_detach_client(struct i2c_client *); 46static int tas_detach_client(struct i2c_client *);
@@ -191,13 +190,14 @@ int __init
191tas_init(int driver_id, const char *driver_name) 190tas_init(int driver_id, const char *driver_name)
192{ 191{
193 const u32* paddr; 192 const u32* paddr;
193 struct device_node *tas_node;
194 194
195 printk(KERN_INFO "tas driver [%s])\n", driver_name); 195 printk(KERN_INFO "tas driver [%s])\n", driver_name);
196 196
197#ifndef CONFIG_I2C_POWERMAC 197#ifndef CONFIG_I2C_POWERMAC
198 request_module("i2c-powermac"); 198 request_module("i2c-powermac");
199#endif 199#endif
200 tas_node = find_devices("deq"); 200 tas_node = of_find_node_by_name("deq");
201 if (tas_node == NULL) 201 if (tas_node == NULL)
202 return -ENODEV; 202 return -ENODEV;
203 paddr = of_get_property(tas_node, "i2c-address", NULL); 203 paddr = of_get_property(tas_node, "i2c-address", NULL);
@@ -208,6 +208,7 @@ tas_init(int driver_id, const char *driver_name)
208 } else 208 } else
209 printk(KERN_INFO "using i2c address: 0x%x (default)\n", 209 printk(KERN_INFO "using i2c address: 0x%x (default)\n",
210 tas_i2c_address); 210 tas_i2c_address);
211 of_node_put(tas_node);
211 212
212 return i2c_add_driver(&tas_driver); 213 return i2c_add_driver(&tas_driver);
213} 214}
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 5e829683d1ad..2bae9c1a2b54 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -816,6 +816,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
816 816
817 if (chip->pdev) 817 if (chip->pdev)
818 pci_dev_put(chip->pdev); 818 pci_dev_put(chip->pdev);
819 of_node_put(chip->node);
819 kfree(chip); 820 kfree(chip);
820 return 0; 821 return 0;
821} 822}
@@ -863,7 +864,8 @@ static void __init detect_byte_swap(struct snd_pmac *chip)
863 */ 864 */
864static int __init snd_pmac_detect(struct snd_pmac *chip) 865static int __init snd_pmac_detect(struct snd_pmac *chip)
865{ 866{
866 struct device_node *sound = NULL; 867 struct device_node *sound;
868 struct device_node *dn;
867 const unsigned int *prop; 869 const unsigned int *prop;
868 unsigned int l; 870 unsigned int l;
869 struct macio_chip* macio; 871 struct macio_chip* macio;
@@ -891,22 +893,21 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
891 else if (machine_is_compatible("PowerBook1,1") 893 else if (machine_is_compatible("PowerBook1,1")
892 || machine_is_compatible("AAPL,PowerBook1998")) 894 || machine_is_compatible("AAPL,PowerBook1998"))
893 chip->is_pbook_G3 = 1; 895 chip->is_pbook_G3 = 1;
894 chip->node = find_devices("awacs"); 896 chip->node = of_find_node_by_name(NULL, "awacs");
895 if (chip->node) 897 sound = of_node_get(chip->node);
896 sound = chip->node;
897 898
898 /* 899 /*
899 * powermac G3 models have a node called "davbus" 900 * powermac G3 models have a node called "davbus"
900 * with a child called "sound". 901 * with a child called "sound".
901 */ 902 */
902 if (!chip->node) 903 if (!chip->node)
903 chip->node = find_devices("davbus"); 904 chip->node = of_find_node_by_name(NULL, "davbus");
904 /* 905 /*
905 * if we didn't find a davbus device, try 'i2s-a' since 906 * if we didn't find a davbus device, try 'i2s-a' since
906 * this seems to be what iBooks have 907 * this seems to be what iBooks have
907 */ 908 */
908 if (! chip->node) { 909 if (! chip->node) {
909 chip->node = find_devices("i2s-a"); 910 chip->node = of_find_node_by_name(NULL, "i2s-a");
910 if (chip->node && chip->node->parent && 911 if (chip->node && chip->node->parent &&
911 chip->node->parent->parent) { 912 chip->node->parent->parent) {
912 if (device_is_compatible(chip->node->parent->parent, 913 if (device_is_compatible(chip->node->parent->parent,
@@ -918,12 +919,14 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
918 return -ENODEV; 919 return -ENODEV;
919 920
920 if (!sound) { 921 if (!sound) {
921 sound = find_devices("sound"); 922 sound = of_find_node_by_name(NULL, "sound");
922 while (sound && sound->parent != chip->node) 923 while (sound && sound->parent != chip->node)
923 sound = sound->next; 924 sound = of_find_node_by_name(sound, "sound");
924 } 925 }
925 if (! sound) 926 if (! sound) {
927 of_node_put(chip->node);
926 return -ENODEV; 928 return -ENODEV;
929 }
927 prop = of_get_property(sound, "sub-frame", NULL); 930 prop = of_get_property(sound, "sub-frame", NULL);
928 if (prop && *prop < 16) 931 if (prop && *prop < 16)
929 chip->subframe = *prop; 932 chip->subframe = *prop;
@@ -934,6 +937,7 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
934 printk(KERN_INFO "snd-powermac no longer handles any " 937 printk(KERN_INFO "snd-powermac no longer handles any "
935 "machines with a layout-id property " 938 "machines with a layout-id property "
936 "in the device-tree, use snd-aoa.\n"); 939 "in the device-tree, use snd-aoa.\n");
940 of_node_put(chip->node);
937 return -ENODEV; 941 return -ENODEV;
938 } 942 }
939 /* This should be verified on older screamers */ 943 /* This should be verified on older screamers */
@@ -971,7 +975,9 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
971 prop = of_get_property(sound, "device-id", NULL); 975 prop = of_get_property(sound, "device-id", NULL);
972 if (prop) 976 if (prop)
973 chip->device_id = *prop; 977 chip->device_id = *prop;
974 chip->has_iic = (find_devices("perch") != NULL); 978 dn = of_find_node_by_name(NULL, "perch");
979 chip->has_iic = (dn != NULL);
980 of_node_put(dn);
975 981
976 /* We need the PCI device for DMA allocations, let's use a crude method 982 /* We need the PCI device for DMA allocations, let's use a crude method
977 * for now ... 983 * for now ...
@@ -1021,6 +1027,7 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
1021 chip->freqs_ok = 1; 1027 chip->freqs_ok = 1;
1022 } 1028 }
1023 1029
1030 of_node_put(sound);
1024 return 0; 1031 return 0;
1025} 1032}
1026 1033
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index 8e01b558131d..54e333fbb1d0 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -1031,32 +1031,40 @@ static irqreturn_t headphone_intr(int irq, void *devid)
1031/* look for audio-gpio device */ 1031/* look for audio-gpio device */
1032static struct device_node *find_audio_device(const char *name) 1032static struct device_node *find_audio_device(const char *name)
1033{ 1033{
1034 struct device_node *gpiop;
1034 struct device_node *np; 1035 struct device_node *np;
1035 1036
1036 if (! (np = find_devices("gpio"))) 1037 gpiop = of_find_node_by_name(NULL, "gpio");
1038 if (! gpiop)
1037 return NULL; 1039 return NULL;
1038 1040
1039 for (np = np->child; np; np = np->sibling) { 1041 for (np = of_get_next_child(gpiop, NULL); np;
1042 np = of_get_next_child(gpiop, np)) {
1040 const char *property = of_get_property(np, "audio-gpio", NULL); 1043 const char *property = of_get_property(np, "audio-gpio", NULL);
1041 if (property && strcmp(property, name) == 0) 1044 if (property && strcmp(property, name) == 0)
1042 return np; 1045 break;
1043 } 1046 }
1044 return NULL; 1047 of_node_put(gpiop);
1048 return np;
1045} 1049}
1046 1050
1047/* look for audio-gpio device */ 1051/* look for audio-gpio device */
1048static struct device_node *find_compatible_audio_device(const char *name) 1052static struct device_node *find_compatible_audio_device(const char *name)
1049{ 1053{
1054 struct device_node *gpiop;
1050 struct device_node *np; 1055 struct device_node *np;
1051 1056
1052 if (! (np = find_devices("gpio"))) 1057 gpiop = of_find_node_by_name(NULL, "gpio");
1058 if (!gpiop)
1053 return NULL; 1059 return NULL;
1054 1060
1055 for (np = np->child; np; np = np->sibling) { 1061 for (np = of_get_next_child(gpiop, NULL); np;
1062 np = of_get_next_child(gpiop, np)) {
1056 if (device_is_compatible(np, name)) 1063 if (device_is_compatible(np, name))
1057 return np; 1064 break;
1058 } 1065 }
1059 return NULL; 1066 of_node_put(gpiop);
1067 return np;
1060} 1068}
1061 1069
1062/* find an audio device and get its address */ 1070/* find an audio device and get its address */
@@ -1066,6 +1074,7 @@ static long tumbler_find_device(const char *device, const char *platform,
1066 struct device_node *node; 1074 struct device_node *node;
1067 const u32 *base; 1075 const u32 *base;
1068 u32 addr; 1076 u32 addr;
1077 long ret;
1069 1078
1070 if (is_compatible) 1079 if (is_compatible)
1071 node = find_compatible_audio_device(device); 1080 node = find_compatible_audio_device(device);
@@ -1083,6 +1092,7 @@ static long tumbler_find_device(const char *device, const char *platform,
1083 if (!base) { 1092 if (!base) {
1084 DBG("(E) cannot find address for device %s !\n", device); 1093 DBG("(E) cannot find address for device %s !\n", device);
1085 snd_printd("cannot find address for device %s\n", device); 1094 snd_printd("cannot find address for device %s\n", device);
1095 of_node_put(node);
1086 return -ENODEV; 1096 return -ENODEV;
1087 } 1097 }
1088 addr = *base; 1098 addr = *base;
@@ -1124,7 +1134,9 @@ static long tumbler_find_device(const char *device, const char *platform,
1124 DBG("(I) GPIO device %s found, offset: %x, active state: %d !\n", 1134 DBG("(I) GPIO device %s found, offset: %x, active state: %d !\n",
1125 device, gp->addr, gp->active_state); 1135 device, gp->addr, gp->active_state);
1126 1136
1127 return irq_of_parse_and_map(node, 0); 1137 ret = irq_of_parse_and_map(node, 0);
1138 of_node_put(node);
1139 return ret;
1128} 1140}
1129 1141
1130/* reset audio */ 1142/* reset audio */
@@ -1342,9 +1354,9 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1342 return err; 1354 return err;
1343 1355
1344 /* set up TAS */ 1356 /* set up TAS */
1345 tas_node = find_devices("deq"); 1357 tas_node = of_find_node_by_name(NULL, "deq");
1346 if (tas_node == NULL) 1358 if (tas_node == NULL)
1347 tas_node = find_devices("codec"); 1359 tas_node = of_find_node_by_name(NULL, "codec");
1348 if (tas_node == NULL) 1360 if (tas_node == NULL)
1349 return -ENODEV; 1361 return -ENODEV;
1350 1362
@@ -1355,6 +1367,7 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1355 mix->i2c.addr = (*paddr) >> 1; 1367 mix->i2c.addr = (*paddr) >> 1;
1356 else 1368 else
1357 mix->i2c.addr = TAS_I2C_ADDR; 1369 mix->i2c.addr = TAS_I2C_ADDR;
1370 of_node_put(tas_node);
1358 1371
1359 DBG("(I) TAS i2c address is: %x\n", mix->i2c.addr); 1372 DBG("(I) TAS i2c address is: %x\n", mix->i2c.addr);
1360 1373