aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ieee1394/csr1212.c28
-rw-r--r--drivers/ieee1394/csr1212.h28
-rw-r--r--drivers/ieee1394/ieee1394_core.c9
3 files changed, 33 insertions, 32 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 }
diff --git a/drivers/ieee1394/csr1212.h b/drivers/ieee1394/csr1212.h
index 4ef0949589c7..655827527ecc 100644
--- a/drivers/ieee1394/csr1212.h
+++ b/drivers/ieee1394/csr1212.h
@@ -313,15 +313,11 @@ extern int csr1212_parse_keyval(struct csr1212_keyval *kv,
313 struct csr1212_csr_rom_cache *cache); 313 struct csr1212_csr_rom_cache *cache);
314extern int csr1212_parse_csr(struct csr1212_csr *csr); 314extern int csr1212_parse_csr(struct csr1212_csr *csr);
315 315
316/* These are internal functions referenced by inline functions below. */
317extern int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv);
318extern void _csr1212_destroy_keyval(struct csr1212_keyval *kv);
319
320 316
321/* This function allocates a new cache which may be used for either parsing or 317/* This function allocates a new cache which may be used for either parsing or
322 * generating sub-sets of Configuration ROM images. */ 318 * generating sub-sets of Configuration ROM images. */
323static inline struct csr1212_csr_rom_cache *csr1212_rom_cache_malloc(u32 offset, 319static inline struct csr1212_csr_rom_cache *
324 size_t size) 320csr1212_rom_cache_malloc(u32 offset, size_t size)
325{ 321{
326 struct csr1212_csr_rom_cache *cache; 322 struct csr1212_csr_rom_cache *cache;
327 323
@@ -345,16 +341,8 @@ static inline struct csr1212_csr_rom_cache *csr1212_rom_cache_malloc(u32 offset,
345 341
346/* This function ensures that a keyval contains data when referencing a keyval 342/* This function ensures that a keyval contains data when referencing a keyval
347 * created by parsing a Configuration ROM. */ 343 * created by parsing a Configuration ROM. */
348static inline struct csr1212_keyval *csr1212_get_keyval(struct csr1212_csr *csr, 344extern struct csr1212_keyval *
349 struct csr1212_keyval *kv) 345csr1212_get_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv);
350{
351 if (!kv)
352 return NULL;
353 if (!kv->valid)
354 if (_csr1212_read_keyval(csr, kv) != CSR1212_SUCCESS)
355 return NULL;
356 return kv;
357}
358 346
359 347
360/* This function increments the reference count for a keyval should there be a 348/* This function increments the reference count for a keyval should there be a
@@ -369,13 +357,7 @@ static inline void csr1212_keep_keyval(struct csr1212_keyval *kv)
369 * keyval when there are no more users of the keyval. This should be called by 357 * keyval when there are no more users of the keyval. This should be called by
370 * any code that calls csr1212_keep_keyval() or any of the keyval creation 358 * any code that calls csr1212_keep_keyval() or any of the keyval creation
371 * routines csr1212_new_*(). */ 359 * routines csr1212_new_*(). */
372static inline void csr1212_release_keyval(struct csr1212_keyval *kv) 360extern void csr1212_release_keyval(struct csr1212_keyval *kv);
373{
374 if (kv->refcnt > 1)
375 kv->refcnt--;
376 else
377 _csr1212_destroy_keyval(kv);
378}
379 361
380 362
381/* 363/*
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index 857e46c6e386..270885679df1 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -1372,11 +1372,10 @@ EXPORT_SYMBOL(hpsb_iso_wake);
1372EXPORT_SYMBOL(hpsb_iso_recv_flush); 1372EXPORT_SYMBOL(hpsb_iso_recv_flush);
1373 1373
1374/** csr1212.c **/ 1374/** csr1212.c **/
1375EXPORT_SYMBOL(csr1212_new_directory);
1376EXPORT_SYMBOL(csr1212_attach_keyval_to_directory); 1375EXPORT_SYMBOL(csr1212_attach_keyval_to_directory);
1377EXPORT_SYMBOL(csr1212_detach_keyval_from_directory); 1376EXPORT_SYMBOL(csr1212_detach_keyval_from_directory);
1378EXPORT_SYMBOL(csr1212_release_keyval); 1377EXPORT_SYMBOL(csr1212_get_keyval);
1379EXPORT_SYMBOL(csr1212_read); 1378EXPORT_SYMBOL(csr1212_new_directory);
1380EXPORT_SYMBOL(csr1212_parse_keyval); 1379EXPORT_SYMBOL(csr1212_parse_keyval);
1381EXPORT_SYMBOL(_csr1212_read_keyval); 1380EXPORT_SYMBOL(csr1212_read);
1382EXPORT_SYMBOL(_csr1212_destroy_keyval); 1381EXPORT_SYMBOL(csr1212_release_keyval);