int ram_block_discard_disable(bool state)
{
    int old;

    if (!state) {
        qatomic_dec(&ram_block_discard_disabled);
        return 0;
    }

    do {
        old = qatomic_read(&ram_block_discard_disabled);
        if (old < 0) {
            return -EBUSY;
        }
    } while (qatomic_cmpxchg(&ram_block_discard_disabled,
                             old, old + 1) != old);
    return 0;
}
int ram_block_discard_disable(bool state)
{
    int old;

    if (!state) {
        qatomic_dec(&ram_block_discard_disabled);
        return 0;
    }

    do {
        old = qatomic_read(&ram_block_discard_disabled);
        if (old < 0) {
            return -EBUSY;
        }
    } while (qatomic_cmpxchg(&ram_block_discard_disabled,
                             old, old + 1) != old);
    return 0;
}