The code forgot to initialise all of these.Thanks. Don't proceed for now, I'll work up new patches.
It just so happens that the all-bits-zero pattern works correctly for all
current architectures, so the code should work OK. But there is no reason
(I hope) why an architecture cannot implement atomic_t as
struct atomic_t {
int counter;
spinlock_t lock;
};
in which case the results of ATOMIC_INIT() may _not_ be all-zeroes, in
which case the code will deadlock.
So. It works, but it's grubby. Do you still wish to proceed?