diff options
Diffstat (limited to 'drivers/ieee1394')
-rw-r--r-- | drivers/ieee1394/config_roms.c | 14 | ||||
-rw-r--r-- | drivers/ieee1394/csr1212.c | 67 | ||||
-rw-r--r-- | drivers/ieee1394/csr1212.h | 4 |
3 files changed, 34 insertions, 51 deletions
diff --git a/drivers/ieee1394/config_roms.c b/drivers/ieee1394/config_roms.c index 6a87a2700c9d..556658a1db29 100644 --- a/drivers/ieee1394/config_roms.c +++ b/drivers/ieee1394/config_roms.c | |||
@@ -63,9 +63,9 @@ int hpsb_default_host_entry(struct hpsb_host *host) | |||
63 | return -ENOMEM; | 63 | return -ENOMEM; |
64 | } | 64 | } |
65 | 65 | ||
66 | ret = csr1212_associate_keyval(vend_id, text); | 66 | csr1212_associate_keyval(vend_id, text); |
67 | csr1212_release_keyval(text); | 67 | csr1212_release_keyval(text); |
68 | ret |= csr1212_attach_keyval_to_directory(root, vend_id); | 68 | ret = csr1212_attach_keyval_to_directory(root, vend_id); |
69 | csr1212_release_keyval(vend_id); | 69 | csr1212_release_keyval(vend_id); |
70 | if (ret != CSR1212_SUCCESS) { | 70 | if (ret != CSR1212_SUCCESS) { |
71 | csr1212_destroy_csr(host->csr.rom); | 71 | csr1212_destroy_csr(host->csr.rom); |
@@ -103,10 +103,12 @@ static int config_rom_ip1394_init(void) | |||
103 | if (!ip1394_ud || !spec_id || !spec_desc || !ver || !ver_desc) | 103 | if (!ip1394_ud || !spec_id || !spec_desc || !ver || !ver_desc) |
104 | goto ip1394_fail; | 104 | goto ip1394_fail; |
105 | 105 | ||
106 | if (csr1212_associate_keyval(spec_id, spec_desc) == CSR1212_SUCCESS && | 106 | csr1212_associate_keyval(spec_id, spec_desc); |
107 | csr1212_associate_keyval(ver, ver_desc) == CSR1212_SUCCESS && | 107 | csr1212_associate_keyval(ver, ver_desc); |
108 | csr1212_attach_keyval_to_directory(ip1394_ud, spec_id) == CSR1212_SUCCESS && | 108 | if (csr1212_attach_keyval_to_directory(ip1394_ud, spec_id) |
109 | csr1212_attach_keyval_to_directory(ip1394_ud, ver) == CSR1212_SUCCESS) | 109 | == CSR1212_SUCCESS && |
110 | csr1212_attach_keyval_to_directory(ip1394_ud, ver) | ||
111 | == CSR1212_SUCCESS) | ||
110 | ret = 0; | 112 | ret = 0; |
111 | 113 | ||
112 | ip1394_fail: | 114 | ip1394_fail: |
diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c index 65be507f4ee3..54408cbe8f8f 100644 --- a/drivers/ieee1394/csr1212.c +++ b/drivers/ieee1394/csr1212.c | |||
@@ -35,6 +35,7 @@ | |||
35 | 35 | ||
36 | #include <linux/errno.h> | 36 | #include <linux/errno.h> |
37 | #include <linux/string.h> | 37 | #include <linux/string.h> |
38 | #include <asm/bug.h> | ||
38 | #include <asm/byteorder.h> | 39 | #include <asm/byteorder.h> |
39 | 40 | ||
40 | #include "csr1212.h" | 41 | #include "csr1212.h" |
@@ -305,43 +306,29 @@ struct csr1212_keyval *csr1212_new_directory(u8 key) | |||
305 | return kv; | 306 | return kv; |
306 | } | 307 | } |
307 | 308 | ||
308 | int csr1212_associate_keyval(struct csr1212_keyval *kv, | 309 | void csr1212_associate_keyval(struct csr1212_keyval *kv, |
309 | struct csr1212_keyval *associate) | 310 | struct csr1212_keyval *associate) |
310 | { | 311 | { |
311 | if (!kv || !associate) | 312 | BUG_ON(!kv || !associate || kv->key.id == CSR1212_KV_ID_DESCRIPTOR || |
312 | return -EINVAL; | 313 | (associate->key.id != CSR1212_KV_ID_DESCRIPTOR && |
313 | 314 | associate->key.id != CSR1212_KV_ID_DEPENDENT_INFO && | |
314 | if (kv->key.id == CSR1212_KV_ID_DESCRIPTOR || | 315 | associate->key.id != CSR1212_KV_ID_EXTENDED_KEY && |
315 | (associate->key.id != CSR1212_KV_ID_DESCRIPTOR && | 316 | associate->key.id != CSR1212_KV_ID_EXTENDED_DATA && |
316 | associate->key.id != CSR1212_KV_ID_DEPENDENT_INFO && | 317 | associate->key.id < 0x30) || |
317 | associate->key.id != CSR1212_KV_ID_EXTENDED_KEY && | 318 | (kv->key.id == CSR1212_KV_ID_EXTENDED_KEY_SPECIFIER_ID && |
318 | associate->key.id != CSR1212_KV_ID_EXTENDED_DATA && | 319 | associate->key.id != CSR1212_KV_ID_EXTENDED_KEY) || |
319 | associate->key.id < 0x30)) | 320 | (kv->key.id == CSR1212_KV_ID_EXTENDED_KEY && |
320 | return -EINVAL; | 321 | associate->key.id != CSR1212_KV_ID_EXTENDED_DATA) || |
321 | 322 | (associate->key.id == CSR1212_KV_ID_EXTENDED_KEY && | |
322 | if (kv->key.id == CSR1212_KV_ID_EXTENDED_KEY_SPECIFIER_ID && | 323 | kv->key.id != CSR1212_KV_ID_EXTENDED_KEY_SPECIFIER_ID) || |
323 | associate->key.id != CSR1212_KV_ID_EXTENDED_KEY) | 324 | (associate->key.id == CSR1212_KV_ID_EXTENDED_DATA && |
324 | return -EINVAL; | 325 | kv->key.id != CSR1212_KV_ID_EXTENDED_KEY)); |
325 | |||
326 | if (kv->key.id == CSR1212_KV_ID_EXTENDED_KEY && | ||
327 | associate->key.id != CSR1212_KV_ID_EXTENDED_DATA) | ||
328 | return -EINVAL; | ||
329 | |||
330 | if (associate->key.id == CSR1212_KV_ID_EXTENDED_KEY && | ||
331 | kv->key.id != CSR1212_KV_ID_EXTENDED_KEY_SPECIFIER_ID) | ||
332 | return -EINVAL; | ||
333 | |||
334 | if (associate->key.id == CSR1212_KV_ID_EXTENDED_DATA && | ||
335 | kv->key.id != CSR1212_KV_ID_EXTENDED_KEY) | ||
336 | return -EINVAL; | ||
337 | 326 | ||
338 | if (kv->associate) | 327 | if (kv->associate) |
339 | csr1212_release_keyval(kv->associate); | 328 | csr1212_release_keyval(kv->associate); |
340 | 329 | ||
341 | associate->refcnt++; | 330 | associate->refcnt++; |
342 | kv->associate = associate; | 331 | kv->associate = associate; |
343 | |||
344 | return CSR1212_SUCCESS; | ||
345 | } | 332 | } |
346 | 333 | ||
347 | int csr1212_attach_keyval_to_directory(struct csr1212_keyval *dir, | 334 | int csr1212_attach_keyval_to_directory(struct csr1212_keyval *dir, |
@@ -349,8 +336,7 @@ int csr1212_attach_keyval_to_directory(struct csr1212_keyval *dir, | |||
349 | { | 336 | { |
350 | struct csr1212_dentry *dentry; | 337 | struct csr1212_dentry *dentry; |
351 | 338 | ||
352 | if (!kv || !dir || dir->key.type != CSR1212_KV_TYPE_DIRECTORY) | 339 | BUG_ON(!kv || !dir || dir->key.type != CSR1212_KV_TYPE_DIRECTORY); |
353 | return -EINVAL; | ||
354 | 340 | ||
355 | dentry = CSR1212_MALLOC(sizeof(*dentry)); | 341 | dentry = CSR1212_MALLOC(sizeof(*dentry)); |
356 | if (!dentry) | 342 | if (!dentry) |
@@ -611,9 +597,8 @@ static int csr1212_append_new_cache(struct csr1212_csr *csr, size_t romsize) | |||
611 | struct csr1212_csr_rom_cache *cache; | 597 | struct csr1212_csr_rom_cache *cache; |
612 | u64 csr_addr; | 598 | u64 csr_addr; |
613 | 599 | ||
614 | if (!csr || !csr->ops || !csr->ops->allocate_addr_range || | 600 | BUG_ON(!csr || !csr->ops || !csr->ops->allocate_addr_range || |
615 | !csr->ops->release_addr || csr->max_rom < 1) | 601 | !csr->ops->release_addr || csr->max_rom < 1); |
616 | return -EINVAL; | ||
617 | 602 | ||
618 | /* ROM size must be a multiple of csr->max_rom */ | 603 | /* ROM size must be a multiple of csr->max_rom */ |
619 | romsize = (romsize + (csr->max_rom - 1)) & ~(csr->max_rom - 1); | 604 | romsize = (romsize + (csr->max_rom - 1)) & ~(csr->max_rom - 1); |
@@ -950,8 +935,7 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr) | |||
950 | int ret; | 935 | int ret; |
951 | int init_offset; | 936 | int init_offset; |
952 | 937 | ||
953 | if (!csr) | 938 | BUG_ON(!csr); |
954 | return -EINVAL; | ||
955 | 939 | ||
956 | cache = csr->cache_head; | 940 | cache = csr->cache_head; |
957 | 941 | ||
@@ -1011,8 +995,7 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr) | |||
1011 | 995 | ||
1012 | /* Make sure the Extended ROM leaf is a multiple of | 996 | /* Make sure the Extended ROM leaf is a multiple of |
1013 | * max_rom in size. */ | 997 | * max_rom in size. */ |
1014 | if (csr->max_rom < 1) | 998 | BUG_ON(csr->max_rom < 1); |
1015 | return -EINVAL; | ||
1016 | leaf_size = (cache->len + (csr->max_rom - 1)) & | 999 | leaf_size = (cache->len + (csr->max_rom - 1)) & |
1017 | ~(csr->max_rom - 1); | 1000 | ~(csr->max_rom - 1); |
1018 | 1001 | ||
@@ -1278,8 +1261,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) | |||
1278 | u32 *cache_ptr; | 1261 | u32 *cache_ptr; |
1279 | u16 kv_len = 0; | 1262 | u16 kv_len = 0; |
1280 | 1263 | ||
1281 | if (!csr || !kv || csr->max_rom < 1) | 1264 | BUG_ON(!csr || !kv || csr->max_rom < 1); |
1282 | return -EINVAL; | ||
1283 | 1265 | ||
1284 | /* First find which cache the data should be in (or go in if not read | 1266 | /* First find which cache the data should be in (or go in if not read |
1285 | * yet). */ | 1267 | * yet). */ |
@@ -1436,8 +1418,7 @@ int csr1212_parse_csr(struct csr1212_csr *csr) | |||
1436 | struct csr1212_dentry *dentry; | 1418 | struct csr1212_dentry *dentry; |
1437 | int ret; | 1419 | int ret; |
1438 | 1420 | ||
1439 | if (!csr || !csr->ops || !csr->ops->bus_read) | 1421 | BUG_ON(!csr || !csr->ops || !csr->ops->bus_read); |
1440 | return -EINVAL; | ||
1441 | 1422 | ||
1442 | ret = csr1212_parse_bus_info_block(csr); | 1423 | ret = csr1212_parse_bus_info_block(csr); |
1443 | if (ret != CSR1212_SUCCESS) | 1424 | if (ret != CSR1212_SUCCESS) |
diff --git a/drivers/ieee1394/csr1212.h b/drivers/ieee1394/csr1212.h index aa9e924fd189..4ef0949589c7 100644 --- a/drivers/ieee1394/csr1212.h +++ b/drivers/ieee1394/csr1212.h | |||
@@ -283,8 +283,8 @@ extern struct csr1212_keyval *csr1212_new_string_descriptor_leaf(const char *s); | |||
283 | * Take care with subsequent ROM modifications: There is no function to remove | 283 | * Take care with subsequent ROM modifications: There is no function to remove |
284 | * previously specified associations. | 284 | * previously specified associations. |
285 | */ | 285 | */ |
286 | extern int csr1212_associate_keyval(struct csr1212_keyval *kv, | 286 | extern void csr1212_associate_keyval(struct csr1212_keyval *kv, |
287 | struct csr1212_keyval *associate); | 287 | struct csr1212_keyval *associate); |
288 | 288 | ||
289 | 289 | ||
290 | /* The following functions manage the association of a keyval and directories. | 290 | /* The following functions manage the association of a keyval and directories. |