aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/csr1212.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ieee1394/csr1212.c')
-rw-r--r--drivers/ieee1394/csr1212.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c
index 54408cbe8f8f..6c2f55bb9463 100644
--- a/drivers/ieee1394/csr1212.c
+++ b/drivers/ieee1394/csr1212.c
@@ -518,7 +518,7 @@ void csr1212_detach_keyval_from_directory(struct csr1212_keyval *dir,
518 * will be destroyed as well if their respective refcnts are 0. By means of 518 * will be destroyed as well if their respective refcnts are 0. By means of
519 * list manipulation, this routine will descend a directory structure in a 519 * list manipulation, this routine will descend a directory structure in a
520 * non-recursive manner. */ 520 * non-recursive manner. */
521void _csr1212_destroy_keyval(struct csr1212_keyval *kv) 521static void csr1212_destroy_keyval(struct csr1212_keyval *kv)
522{ 522{
523 struct csr1212_keyval *k, *a; 523 struct csr1212_keyval *k, *a;
524 struct csr1212_dentry dentry; 524 struct csr1212_dentry dentry;
@@ -566,6 +566,14 @@ void _csr1212_destroy_keyval(struct csr1212_keyval *kv)
566 } 566 }
567} 567}
568 568
569void csr1212_release_keyval(struct csr1212_keyval *kv)
570{
571 if (kv->refcnt > 1)
572 kv->refcnt--;
573 else
574 csr1212_destroy_keyval(kv);
575}
576
569void csr1212_destroy_csr(struct csr1212_csr *csr) 577void csr1212_destroy_csr(struct csr1212_csr *csr)
570{ 578{
571 struct csr1212_csr_rom_cache *c, *oc; 579 struct csr1212_csr_rom_cache *c, *oc;
@@ -1251,7 +1259,8 @@ fail:
1251 return ret; 1259 return ret;
1252} 1260}
1253 1261
1254int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) 1262static int
1263csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
1255{ 1264{
1256 struct csr1212_cache_region *cr, *ncr, *newcr = NULL; 1265 struct csr1212_cache_region *cr, *ncr, *newcr = NULL;
1257 struct csr1212_keyval_img *kvi = NULL; 1266 struct csr1212_keyval_img *kvi = NULL;
@@ -1412,6 +1421,17 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
1412 return csr1212_parse_keyval(kv, cache); 1421 return csr1212_parse_keyval(kv, cache);
1413} 1422}
1414 1423
1424struct csr1212_keyval *
1425csr1212_get_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
1426{
1427 if (!kv)
1428 return NULL;
1429 if (!kv->valid)
1430 if (csr1212_read_keyval(csr, kv) != CSR1212_SUCCESS)
1431 return NULL;
1432 return kv;
1433}
1434
1415int csr1212_parse_csr(struct csr1212_csr *csr) 1435int csr1212_parse_csr(struct csr1212_csr *csr)
1416{ 1436{
1417 static const int mr_map[] = { 4, 64, 1024, 0 }; 1437 static const int mr_map[] = { 4, 64, 1024, 0 };
@@ -1443,7 +1463,7 @@ int csr1212_parse_csr(struct csr1212_csr *csr)
1443 csr->root_kv->valid = 0; 1463 csr->root_kv->valid = 0;
1444 csr->root_kv->next = csr->root_kv; 1464 csr->root_kv->next = csr->root_kv;
1445 csr->root_kv->prev = csr->root_kv; 1465 csr->root_kv->prev = csr->root_kv;
1446 ret = _csr1212_read_keyval(csr, csr->root_kv); 1466 ret = csr1212_read_keyval(csr, csr->root_kv);
1447 if (ret != CSR1212_SUCCESS) 1467 if (ret != CSR1212_SUCCESS)
1448 return ret; 1468 return ret;
1449 1469
@@ -1453,7 +1473,7 @@ int csr1212_parse_csr(struct csr1212_csr *csr)
1453 dentry; dentry = dentry->next) { 1473 dentry; dentry = dentry->next) {
1454 if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM && 1474 if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM &&
1455 !dentry->kv->valid) { 1475 !dentry->kv->valid) {
1456 ret = _csr1212_read_keyval(csr, dentry->kv); 1476 ret = csr1212_read_keyval(csr, dentry->kv);
1457 if (ret != CSR1212_SUCCESS) 1477 if (ret != CSR1212_SUCCESS)
1458 return ret; 1478 return ret;
1459 } 1479 }