diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2007-04-23 23:53:04 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-04-24 08:09:02 -0400 |
commit | 30686ba6d56858657829d3eb524ed73e5dc98d2b (patch) | |
tree | 42bf3cea4dc7028fec30377560b367cd8274825e /sound/ppc | |
parent | 1658ab66781d918f604c6069c5cf9a94b6f52f84 (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/ppc')
-rw-r--r-- | sound/ppc/pmac.c | 27 | ||||
-rw-r--r-- | sound/ppc/tumbler.c | 35 |
2 files changed, 41 insertions, 21 deletions
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 | */ |
864 | static int __init snd_pmac_detect(struct snd_pmac *chip) | 865 | static 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 */ |
1032 | static struct device_node *find_audio_device(const char *name) | 1032 | static 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 */ |
1048 | static struct device_node *find_compatible_audio_device(const char *name) | 1052 | static 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 | ||