return ret;
}
-/* Note: callers invoking this in a loop must use a compiler barrier,
- * for example cpu_relax(). Callers must hold producer_lock.
- */
-static inline int __ptr_ring_check_produce(struct ptr_ring *r)
-{
- if (unlikely(!r->size))
- return -EINVAL;
-
- if (data_race(r->queue[r->producer]))
- return -ENOSPC;
-
- return 0;
-}
-
/* Note: callers invoking this in a loop must use a compiler barrier,
* for example cpu_relax(). Callers must hold producer_lock.
* Callers are responsible for making sure pointer that is being queued
*/
static inline int __ptr_ring_produce(struct ptr_ring *r, void *ptr)
{
- int p = __ptr_ring_check_produce(r);
-
- if (p)
- return p;
+ if (unlikely(!r->size) || data_race(r->queue[r->producer]))
+ return -ENOSPC;
/* Make sure the pointer we are storing points to a valid data. */
/* Pairs with the dependency ordering in __ptr_ring_consume. */