350 ASSERT(fp != NULL);
351 mutex_enter(&fp->femh_lock);
352 sp = fp->femh_list;
353 return (sp);
354 }
355
356 static void
357 fem_unlock(struct fem_head *fp)
358 {
359 ASSERT(fp != NULL);
360 mutex_exit(&fp->femh_lock);
361 }
362
363 /*
364 * Addref can only be called while its head->lock is held.
365 */
366
367 static void
368 fem_addref(struct fem_list *sp)
369 {
370 atomic_add_32(&sp->feml_refc, 1);
371 }
372
373 static uint32_t
374 fem_delref(struct fem_list *sp)
375 {
376 return (atomic_add_32_nv(&sp->feml_refc, -1));
377 }
378
379 static struct fem_list *
380 fem_get(struct fem_head *fp)
381 {
382 struct fem_list *sp = NULL;
383
384 if (fp != NULL) {
385 if ((sp = fem_lock(fp)) != NULL) {
386 fem_addref(sp);
387 }
388 fem_unlock(fp);
389 }
390 return (sp);
391 }
392
393 static void
394 fem_release(struct fem_list *sp)
395 {
396 int i;
|
350 ASSERT(fp != NULL);
351 mutex_enter(&fp->femh_lock);
352 sp = fp->femh_list;
353 return (sp);
354 }
355
356 static void
357 fem_unlock(struct fem_head *fp)
358 {
359 ASSERT(fp != NULL);
360 mutex_exit(&fp->femh_lock);
361 }
362
363 /*
364 * Addref can only be called while its head->lock is held.
365 */
366
367 static void
368 fem_addref(struct fem_list *sp)
369 {
370 atomic_inc_32(&sp->feml_refc);
371 }
372
373 static uint32_t
374 fem_delref(struct fem_list *sp)
375 {
376 return (atomic_dec_32_nv(&sp->feml_refc));
377 }
378
379 static struct fem_list *
380 fem_get(struct fem_head *fp)
381 {
382 struct fem_list *sp = NULL;
383
384 if (fp != NULL) {
385 if ((sp = fem_lock(fp)) != NULL) {
386 fem_addref(sp);
387 }
388 fem_unlock(fp);
389 }
390 return (sp);
391 }
392
393 static void
394 fem_release(struct fem_list *sp)
395 {
396 int i;
|