i2c: move locking operations to their own struct