ia64/linux-2.6.18-xen.hg

view drivers/ieee1394/config_roms.c @ 893:f994bfe9b93b

linux/blktap2: reduce TLB flush scope

c/s 885 added very coarse TLB flushing. Since these flushes always
follow single page updates, single page flushes (when available) are
sufficient.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 04 10:32:57 2009 +0100 (2009-06-04)
parents 831230e53067
children
line source
1 /*
2 * IEEE 1394 for Linux
3 *
4 * ConfigROM entries
5 *
6 * Copyright (C) 2004 Ben Collins
7 *
8 * This code is licensed under the GPL. See the file COPYING in the root
9 * directory of the kernel sources for details.
10 */
12 #include <linux/types.h>
14 #include "csr1212.h"
15 #include "ieee1394.h"
16 #include "ieee1394_types.h"
17 #include "hosts.h"
18 #include "ieee1394_core.h"
19 #include "highlevel.h"
20 #include "csr.h"
21 #include "config_roms.h"
23 struct hpsb_config_rom_entry {
24 const char *name;
26 /* Base initialization, called at module load */
27 int (*init)(void);
29 /* Add entry to specified host */
30 int (*add)(struct hpsb_host *host);
32 /* Remove entry from specified host */
33 void (*remove)(struct hpsb_host *host);
35 /* Cleanup called at module exit */
36 void (*cleanup)(void);
38 /* The flag added to host->config_roms */
39 unsigned int flag;
40 };
43 int hpsb_default_host_entry(struct hpsb_host *host)
44 {
45 struct csr1212_keyval *root;
46 struct csr1212_keyval *vend_id = NULL;
47 struct csr1212_keyval *text = NULL;
48 char csr_name[128];
49 int ret;
51 sprintf(csr_name, "Linux - %s", host->driver->name);
52 root = host->csr.rom->root_kv;
54 vend_id = csr1212_new_immediate(CSR1212_KV_ID_VENDOR, host->csr.guid_hi >> 8);
55 text = csr1212_new_string_descriptor_leaf(csr_name);
57 if (!vend_id || !text) {
58 if (vend_id)
59 csr1212_release_keyval(vend_id);
60 if (text)
61 csr1212_release_keyval(text);
62 csr1212_destroy_csr(host->csr.rom);
63 return -ENOMEM;
64 }
66 ret = csr1212_associate_keyval(vend_id, text);
67 csr1212_release_keyval(text);
68 ret |= csr1212_attach_keyval_to_directory(root, vend_id);
69 csr1212_release_keyval(vend_id);
70 if (ret != CSR1212_SUCCESS) {
71 csr1212_destroy_csr(host->csr.rom);
72 return -ENOMEM;
73 }
75 host->update_config_rom = 1;
77 return 0;
78 }
81 #ifdef CONFIG_IEEE1394_CONFIG_ROM_IP1394
82 #include "eth1394.h"
84 static struct csr1212_keyval *ip1394_ud;
86 static int config_rom_ip1394_init(void)
87 {
88 struct csr1212_keyval *spec_id = NULL;
89 struct csr1212_keyval *spec_desc = NULL;
90 struct csr1212_keyval *ver = NULL;
91 struct csr1212_keyval *ver_desc = NULL;
92 int ret = -ENOMEM;
94 ip1394_ud = csr1212_new_directory(CSR1212_KV_ID_UNIT);
96 spec_id = csr1212_new_immediate(CSR1212_KV_ID_SPECIFIER_ID,
97 ETHER1394_GASP_SPECIFIER_ID);
98 spec_desc = csr1212_new_string_descriptor_leaf("IANA");
99 ver = csr1212_new_immediate(CSR1212_KV_ID_VERSION,
100 ETHER1394_GASP_VERSION);
101 ver_desc = csr1212_new_string_descriptor_leaf("IPv4");
103 if (!ip1394_ud || !spec_id || !spec_desc || !ver || !ver_desc)
104 goto ip1394_fail;
106 if (csr1212_associate_keyval(spec_id, spec_desc) == CSR1212_SUCCESS &&
107 csr1212_associate_keyval(ver, ver_desc) == CSR1212_SUCCESS &&
108 csr1212_attach_keyval_to_directory(ip1394_ud, spec_id) == CSR1212_SUCCESS &&
109 csr1212_attach_keyval_to_directory(ip1394_ud, ver) == CSR1212_SUCCESS)
110 ret = 0;
112 ip1394_fail:
113 if (ret && ip1394_ud) {
114 csr1212_release_keyval(ip1394_ud);
115 ip1394_ud = NULL;
116 }
118 if (spec_id)
119 csr1212_release_keyval(spec_id);
120 if (spec_desc)
121 csr1212_release_keyval(spec_desc);
122 if (ver)
123 csr1212_release_keyval(ver);
124 if (ver_desc)
125 csr1212_release_keyval(ver_desc);
127 return ret;
128 }
130 static void config_rom_ip1394_cleanup(void)
131 {
132 if (ip1394_ud) {
133 csr1212_release_keyval(ip1394_ud);
134 ip1394_ud = NULL;
135 }
136 }
138 static int config_rom_ip1394_add(struct hpsb_host *host)
139 {
140 if (!ip1394_ud)
141 return -ENODEV;
143 if (csr1212_attach_keyval_to_directory(host->csr.rom->root_kv,
144 ip1394_ud) != CSR1212_SUCCESS)
145 return -ENOMEM;
147 return 0;
148 }
150 static void config_rom_ip1394_remove(struct hpsb_host *host)
151 {
152 csr1212_detach_keyval_from_directory(host->csr.rom->root_kv, ip1394_ud);
153 }
155 static struct hpsb_config_rom_entry ip1394_entry = {
156 .name = "ip1394",
157 .init = config_rom_ip1394_init,
158 .add = config_rom_ip1394_add,
159 .remove = config_rom_ip1394_remove,
160 .cleanup = config_rom_ip1394_cleanup,
161 .flag = HPSB_CONFIG_ROM_ENTRY_IP1394,
162 };
163 #endif /* CONFIG_IEEE1394_CONFIG_ROM_IP1394 */
166 static struct hpsb_config_rom_entry *const config_rom_entries[] = {
167 #ifdef CONFIG_IEEE1394_CONFIG_ROM_IP1394
168 &ip1394_entry,
169 #endif
170 NULL,
171 };
174 int hpsb_init_config_roms(void)
175 {
176 int i, error = 0;
178 for (i = 0; config_rom_entries[i]; i++) {
179 if (!config_rom_entries[i]->init)
180 continue;
182 if (config_rom_entries[i]->init()) {
183 HPSB_ERR("Failed to initialize config rom entry `%s'",
184 config_rom_entries[i]->name);
185 error = -1;
186 } else
187 HPSB_DEBUG("Initialized config rom entry `%s'",
188 config_rom_entries[i]->name);
189 }
191 return error;
192 }
194 void hpsb_cleanup_config_roms(void)
195 {
196 int i;
198 for (i = 0; config_rom_entries[i]; i++) {
199 if (config_rom_entries[i]->cleanup)
200 config_rom_entries[i]->cleanup();
201 }
202 }
204 int hpsb_add_extra_config_roms(struct hpsb_host *host)
205 {
206 int i, error = 0;
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 }
217 }
219 return error;
220 }
222 void hpsb_remove_extra_config_roms(struct hpsb_host *host)
223 {
224 int i;
226 for (i = 0; config_rom_entries[i]; i++) {
227 if (!(host->config_roms & config_rom_entries[i]->flag))
228 continue;
230 config_rom_entries[i]->remove(host);
232 host->config_roms &= ~config_rom_entries[i]->flag;
233 host->update_config_rom = 1;
234 }
235 }