aboutsummaryrefslogtreecommitdiffstats
path: root/sound/oss/dmasound/dmasound_awacs.c
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2007-04-23 23:53:04 -0400
committerPaul Mackerras <paulus@samba.org>2007-04-24 08:09:02 -0400
commit30686ba6d56858657829d3eb524ed73e5dc98d2b (patch)
tree42bf3cea4dc7028fec30377560b367cd8274825e /sound/oss/dmasound/dmasound_awacs.c
parent1658ab66781d918f604c6069c5cf9a94b6f52f84 (diff)
[POWERPC] Remove old interface find_devices
Replace uses with of_find_node_by_name and for_each_node_by_name. Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'sound/oss/dmasound/dmasound_awacs.c')
-rw-r--r--sound/oss/dmasound/dmasound_awacs.c90
1 files changed, 59 insertions, 31 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.");