diff options
Diffstat (limited to 'drivers/ieee1394/config_roms.c')
-rw-r--r-- | drivers/ieee1394/config_roms.c | 93 |
1 files changed, 26 insertions, 67 deletions
diff --git a/drivers/ieee1394/config_roms.c b/drivers/ieee1394/config_roms.c index e2de6fa0c9fe..1b981207fa76 100644 --- a/drivers/ieee1394/config_roms.c +++ b/drivers/ieee1394/config_roms.c | |||
@@ -26,12 +26,6 @@ struct hpsb_config_rom_entry { | |||
26 | /* Base initialization, called at module load */ | 26 | /* Base initialization, called at module load */ |
27 | int (*init)(void); | 27 | int (*init)(void); |
28 | 28 | ||
29 | /* Add entry to specified host */ | ||
30 | int (*add)(struct hpsb_host *host); | ||
31 | |||
32 | /* Remove entry from specified host */ | ||
33 | void (*remove)(struct hpsb_host *host); | ||
34 | |||
35 | /* Cleanup called at module exit */ | 29 | /* Cleanup called at module exit */ |
36 | void (*cleanup)(void); | 30 | void (*cleanup)(void); |
37 | 31 | ||
@@ -39,7 +33,7 @@ struct hpsb_config_rom_entry { | |||
39 | unsigned int flag; | 33 | unsigned int flag; |
40 | }; | 34 | }; |
41 | 35 | ||
42 | 36 | /* The default host entry. This must succeed. */ | |
43 | int hpsb_default_host_entry(struct hpsb_host *host) | 37 | int hpsb_default_host_entry(struct hpsb_host *host) |
44 | { | 38 | { |
45 | struct csr1212_keyval *root; | 39 | struct csr1212_keyval *root; |
@@ -63,9 +57,9 @@ int hpsb_default_host_entry(struct hpsb_host *host) | |||
63 | return -ENOMEM; | 57 | return -ENOMEM; |
64 | } | 58 | } |
65 | 59 | ||
66 | ret = csr1212_associate_keyval(vend_id, text); | 60 | csr1212_associate_keyval(vend_id, text); |
67 | csr1212_release_keyval(text); | 61 | csr1212_release_keyval(text); |
68 | ret |= csr1212_attach_keyval_to_directory(root, vend_id); | 62 | ret = csr1212_attach_keyval_to_directory(root, vend_id); |
69 | csr1212_release_keyval(vend_id); | 63 | csr1212_release_keyval(vend_id); |
70 | if (ret != CSR1212_SUCCESS) { | 64 | if (ret != CSR1212_SUCCESS) { |
71 | csr1212_destroy_csr(host->csr.rom); | 65 | csr1212_destroy_csr(host->csr.rom); |
@@ -78,7 +72,7 @@ int hpsb_default_host_entry(struct hpsb_host *host) | |||
78 | } | 72 | } |
79 | 73 | ||
80 | 74 | ||
81 | #ifdef CONFIG_IEEE1394_CONFIG_ROM_IP1394 | 75 | #ifdef CONFIG_IEEE1394_ETH1394_ROM_ENTRY |
82 | #include "eth1394.h" | 76 | #include "eth1394.h" |
83 | 77 | ||
84 | static struct csr1212_keyval *ip1394_ud; | 78 | static struct csr1212_keyval *ip1394_ud; |
@@ -103,10 +97,12 @@ static int config_rom_ip1394_init(void) | |||
103 | if (!ip1394_ud || !spec_id || !spec_desc || !ver || !ver_desc) | 97 | if (!ip1394_ud || !spec_id || !spec_desc || !ver || !ver_desc) |
104 | goto ip1394_fail; | 98 | goto ip1394_fail; |
105 | 99 | ||
106 | if (csr1212_associate_keyval(spec_id, spec_desc) == CSR1212_SUCCESS && | 100 | csr1212_associate_keyval(spec_id, spec_desc); |
107 | csr1212_associate_keyval(ver, ver_desc) == CSR1212_SUCCESS && | 101 | csr1212_associate_keyval(ver, ver_desc); |
108 | csr1212_attach_keyval_to_directory(ip1394_ud, spec_id) == CSR1212_SUCCESS && | 102 | if (csr1212_attach_keyval_to_directory(ip1394_ud, spec_id) |
109 | csr1212_attach_keyval_to_directory(ip1394_ud, ver) == CSR1212_SUCCESS) | 103 | == CSR1212_SUCCESS && |
104 | csr1212_attach_keyval_to_directory(ip1394_ud, ver) | ||
105 | == CSR1212_SUCCESS) | ||
110 | ret = 0; | 106 | ret = 0; |
111 | 107 | ||
112 | ip1394_fail: | 108 | ip1394_fail: |
@@ -135,7 +131,7 @@ static void config_rom_ip1394_cleanup(void) | |||
135 | } | 131 | } |
136 | } | 132 | } |
137 | 133 | ||
138 | static int config_rom_ip1394_add(struct hpsb_host *host) | 134 | int hpsb_config_rom_ip1394_add(struct hpsb_host *host) |
139 | { | 135 | { |
140 | if (!ip1394_ud) | 136 | if (!ip1394_ud) |
141 | return -ENODEV; | 137 | return -ENODEV; |
@@ -144,92 +140,55 @@ static int config_rom_ip1394_add(struct hpsb_host *host) | |||
144 | ip1394_ud) != CSR1212_SUCCESS) | 140 | ip1394_ud) != CSR1212_SUCCESS) |
145 | return -ENOMEM; | 141 | return -ENOMEM; |
146 | 142 | ||
143 | host->config_roms |= HPSB_CONFIG_ROM_ENTRY_IP1394; | ||
144 | host->update_config_rom = 1; | ||
147 | return 0; | 145 | return 0; |
148 | } | 146 | } |
147 | EXPORT_SYMBOL_GPL(hpsb_config_rom_ip1394_add); | ||
149 | 148 | ||
150 | static void config_rom_ip1394_remove(struct hpsb_host *host) | 149 | void hpsb_config_rom_ip1394_remove(struct hpsb_host *host) |
151 | { | 150 | { |
152 | csr1212_detach_keyval_from_directory(host->csr.rom->root_kv, ip1394_ud); | 151 | csr1212_detach_keyval_from_directory(host->csr.rom->root_kv, ip1394_ud); |
152 | host->config_roms &= ~HPSB_CONFIG_ROM_ENTRY_IP1394; | ||
153 | host->update_config_rom = 1; | ||
153 | } | 154 | } |
155 | EXPORT_SYMBOL_GPL(hpsb_config_rom_ip1394_remove); | ||
154 | 156 | ||
155 | static struct hpsb_config_rom_entry ip1394_entry = { | 157 | static struct hpsb_config_rom_entry ip1394_entry = { |
156 | .name = "ip1394", | 158 | .name = "ip1394", |
157 | .init = config_rom_ip1394_init, | 159 | .init = config_rom_ip1394_init, |
158 | .add = config_rom_ip1394_add, | ||
159 | .remove = config_rom_ip1394_remove, | ||
160 | .cleanup = config_rom_ip1394_cleanup, | 160 | .cleanup = config_rom_ip1394_cleanup, |
161 | .flag = HPSB_CONFIG_ROM_ENTRY_IP1394, | 161 | .flag = HPSB_CONFIG_ROM_ENTRY_IP1394, |
162 | }; | 162 | }; |
163 | #endif /* CONFIG_IEEE1394_CONFIG_ROM_IP1394 */ | ||
164 | 163 | ||
164 | #endif /* CONFIG_IEEE1394_ETH1394_ROM_ENTRY */ | ||
165 | 165 | ||
166 | static struct hpsb_config_rom_entry *const config_rom_entries[] = { | 166 | static struct hpsb_config_rom_entry *const config_rom_entries[] = { |
167 | #ifdef CONFIG_IEEE1394_CONFIG_ROM_IP1394 | 167 | #ifdef CONFIG_IEEE1394_ETH1394_ROM_ENTRY |
168 | &ip1394_entry, | 168 | &ip1394_entry, |
169 | #endif | 169 | #endif |
170 | NULL, | ||
171 | }; | 170 | }; |
172 | 171 | ||
173 | 172 | /* Initialize all config roms */ | |
174 | int hpsb_init_config_roms(void) | 173 | int hpsb_init_config_roms(void) |
175 | { | 174 | { |
176 | int i, error = 0; | 175 | int i, error = 0; |
177 | 176 | ||
178 | for (i = 0; config_rom_entries[i]; i++) { | 177 | for (i = 0; i < ARRAY_SIZE(config_rom_entries); i++) |
179 | if (!config_rom_entries[i]->init) | ||
180 | continue; | ||
181 | |||
182 | if (config_rom_entries[i]->init()) { | 178 | if (config_rom_entries[i]->init()) { |
183 | HPSB_ERR("Failed to initialize config rom entry `%s'", | 179 | HPSB_ERR("Failed to initialize config rom entry `%s'", |
184 | config_rom_entries[i]->name); | 180 | config_rom_entries[i]->name); |
185 | error = -1; | 181 | error = -1; |
186 | } else | ||
187 | HPSB_DEBUG("Initialized config rom entry `%s'", | ||
188 | config_rom_entries[i]->name); | ||
189 | } | ||
190 | |||
191 | return error; | ||
192 | } | ||
193 | |||
194 | void hpsb_cleanup_config_roms(void) | ||
195 | { | ||
196 | int i; | ||
197 | |||
198 | for (i = 0; config_rom_entries[i]; i++) { | ||
199 | if (config_rom_entries[i]->cleanup) | ||
200 | config_rom_entries[i]->cleanup(); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | int hpsb_add_extra_config_roms(struct hpsb_host *host) | ||
205 | { | ||
206 | int i, error = 0; | ||
207 | |||
208 | for (i = 0; config_rom_entries[i]; i++) { | ||
209 | if (config_rom_entries[i]->add(host)) { | ||
210 | HPSB_ERR("fw-host%d: Failed to attach config rom entry `%s'", | ||
211 | host->id, config_rom_entries[i]->name); | ||
212 | error = -1; | ||
213 | } else { | ||
214 | host->config_roms |= config_rom_entries[i]->flag; | ||
215 | host->update_config_rom = 1; | ||
216 | } | 182 | } |
217 | } | ||
218 | 183 | ||
219 | return error; | 184 | return error; |
220 | } | 185 | } |
221 | 186 | ||
222 | void hpsb_remove_extra_config_roms(struct hpsb_host *host) | 187 | /* Cleanup all config roms */ |
188 | void hpsb_cleanup_config_roms(void) | ||
223 | { | 189 | { |
224 | int i; | 190 | int i; |
225 | 191 | ||
226 | for (i = 0; config_rom_entries[i]; i++) { | 192 | for (i = 0; i < ARRAY_SIZE(config_rom_entries); i++) |
227 | if (!(host->config_roms & config_rom_entries[i]->flag)) | 193 | config_rom_entries[i]->cleanup(); |
228 | continue; | ||
229 | |||
230 | config_rom_entries[i]->remove(host); | ||
231 | |||
232 | host->config_roms &= ~config_rom_entries[i]->flag; | ||
233 | host->update_config_rom = 1; | ||
234 | } | ||
235 | } | 194 | } |