Lines Matching +full:error +full:- +full:counter

1 // SPDX-License-Identifier: GPL-2.0
13 * It's implemented as an unsigned 32-bit value. The low order bits are
14 * designated to hold an error code (between 0 and -MAX_ERRNO). The upper bits
15 * are used as a counter. This is done with atomics instead of locking so that
23 * frequently, since we have so few bits to use as a counter.
27 * the counter if no one has sampled it since the last time an error was
31 * is the special (but common) case where there has never been an error. An all
33 * has ever been an error set since it was first initialized.
36 /* The low bits are designated for error code (max of MAX_ERRNO) */
43 #define ERRNO_MASK (ERRSEQ_SEEN - 1)
45 /* The lowest bit of the counter */
49 * errseq_set - set a errseq_t for later reporting
51 * @err: error to set (must be between -1 and -MAX_ERRNO)
53 * This function sets the error in @eseq, and increments the sequence counter
56 * Any error set will always overwrite an existing error.
68 * Ensure the error code actually fits where we want it to go. If it in errseq_set()
71 * previous error. in errseq_set()
75 if (WARN(unlikely(err == 0 || (unsigned int)-err > MAX_ERRNO), in errseq_set()
82 /* Clear out error bits and set new error */ in errseq_set()
83 new = (old & ~(ERRNO_MASK | ERRSEQ_SEEN)) | -err; in errseq_set()
113 * errseq_sample() - Grab current errseq_t value.
117 * If the error has been "seen", new callers will not see an old error.
118 * If there is an unseen error in @eseq, the caller of this function will
119 * see it the next time it checks for an error.
128 /* If nobody has seen this error yet, then we can be the first. */ in errseq_sample()
136 * errseq_check() - Has an error occurred since a particular sample point?
138 * @since: Previously-sampled errseq_t from which to check.
144 * Return: The latest error set in the errseq_t or 0 if it hasn't changed.
152 return -(cur & ERRNO_MASK); in errseq_check()
157 * errseq_check_and_advance() - Check an errseq_t and advance to current value.
159 * @since: Pointer to previously-sampled errseq_t to check against and advance.
166 * "since" value, and return whatever the error portion is set to.
173 * Return: Negative errno if one has been stored, or 0 if no new error has
183 * so that the common case of no error is handled without needing in errseq_check_and_advance()
195 * counter or resetting the error), or another reader who is in errseq_check_and_advance()
197 * can advance "since" and return an error based on what we in errseq_check_and_advance()
204 err = -(new & ERRNO_MASK); in errseq_check_and_advance()